From f3db5e1dbad4e7ad3ea449cb2bdd79a04c616463 Mon Sep 17 00:00:00 2001 From: bullshit Date: Tue, 26 Aug 2025 10:04:01 +0200 Subject: [PATCH] docs(ups-hid): timer and delay functionality Signed-off-by: bullshit --- README.md | 1 + components/ups_hid/README.md | 98 ++++++++++++++++++++++++++++++++++++ configs/README.md | 17 ++++++- 3 files changed, 114 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9ddf681..b8e539a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Monitor UPS devices via direct USB connection on ESP32-S3. Supports APC, CyberPo - **Real-time UPS monitoring**: Battery, voltage, load, runtime, and 15+ sensors - **Multi-protocol support**: APC HID, CyberPower HID, Generic HID with auto-detection - **UPS Control**: Beeper control (enable/disable/mute/test) and battery testing +- โฑ๏ธ **Delay configuration**: Configure UPS shutdown, start, and reboot delays via USB HID - **Home Assistant integration**: Full device discovery and management - **Developer-friendly**: Simulation mode, comprehensive logging diff --git a/components/ups_hid/README.md b/components/ups_hid/README.md index ecccc98..77ade58 100644 --- a/components/ups_hid/README.md +++ b/components/ups_hid/README.md @@ -7,6 +7,7 @@ A ESPHome component for monitoring UPS devices via USB connection on ESP32-S3. D - ๐Ÿ”‹ **Real-time UPS monitoring**: Battery level, voltages, load, runtime, status - ๐Ÿงช **UPS self-test control**: Battery tests (quick/deep), panel tests, with real-time result monitoring - ๐Ÿ”Š **Beeper control**: Enable/disable/mute/test UPS audible alarms via HID write operations +- โฑ๏ธ **Delay configuration**: Configure UPS shutdown, start, and reboot delays via USB HID - ๐ŸŒˆ **Visual status indicator**: RGB LED with customizable status colors - ๐Ÿ  **Home Assistant integration**: Automatic entity discovery via ESPHome API - ๐Ÿ”Œ **Multi-protocol support**: APC HID, CyberPower HID, Generic HID @@ -781,6 +782,103 @@ automation: message: "UPS test completed: {{ states('text_sensor.ups_test_result') }}" ``` +### UPS Delay Configuration โญ **NEW** + +The component now supports configuring UPS delay timers via USB HID SET_REPORT operations: + +```yaml +number: + - platform: ups_hid + ups_hid_id: ups_monitor + delay_type: shutdown # Delay type: shutdown, start, reboot + name: "UPS Shutdown Delay" + min_value: 0 + max_value: 600 # Max 600 seconds (10 minutes) + step: 10 + unit_of_measurement: "s" + device_class: duration + entity_category: config + icon: "mdi:timer-settings" + mode: box + + - platform: ups_hid + ups_hid_id: ups_monitor + delay_type: start # Power-on delay after utility returns + name: "UPS Start Delay" + min_value: 0 + max_value: 600 + step: 10 + unit_of_measurement: "s" + device_class: duration + entity_category: config + icon: "mdi:timer-settings" + mode: box + + - platform: ups_hid + ups_hid_id: ups_monitor + delay_type: reboot # Delay for reboot operations + name: "UPS Reboot Delay" + min_value: 0 + max_value: 600 + step: 10 + unit_of_measurement: "s" + device_class: duration + entity_category: config + icon: "mdi:timer-settings" + mode: box +``` + +**Available delay types:** +- `shutdown`: Time UPS waits before cutting power during outage +- `start`: Time UPS waits before restoring power after utility returns +- `reboot`: Time between shutdown and restart during reboot command + +**Protocol Support:** + +| Protocol | Support Level | Report IDs | Max Delay | Features | +|----------|---------------|------------|-----------|----------| +| **CyberPower** | โœ… **Full** | 0x15 (shutdown), 0x16 (start) | 7200s (2 hours) | Complete bidirectional | +| **Generic HID** | โšก **Multi-vendor** | 0x15, 0x41, 0x57, standard HID | 7200s (2 hours) | Tries multiple report IDs | +| **APC** | โš ๏ธ **Limited** | 0x41 (shutdown), 0x40 (reboot) | 600s (10 minutes) | INPUT-ONLY fallback | + +**Configuration Examples:** + +```yaml +# Automation script to apply default delays +script: + - id: apply_default_delays + then: + - number.set: + id: ups_shutdown_delay_config + value: 60.0 # 60 seconds shutdown delay + - number.set: + id: ups_start_delay_config + value: 120.0 # 2 minutes start delay + - number.set: + id: ups_reboot_delay_config + value: 60.0 # 60 seconds reboot delay + - logger.log: "Applied default delay configuration" + +# Home Assistant automation example +automation: + - alias: "Configure UPS for Extended Outages" + trigger: + platform: state + entity_id: binary_sensor.extended_outage_predicted + to: 'on' + action: + - service: number.set_value + target: + entity_id: number.ups_shutdown_delay + data: + value: 300 # 5 minutes for extended outages +``` + +**Important Notes:** +- **Persistence**: Delay settings are stored in UPS non-volatile memory +- **APC Limitation**: INPUT-ONLY devices (like Back-UPS ES 700G) cannot be configured +- **Safety**: Start with longer delays (60+ seconds) to ensure safe shutdown +- **Testing**: Use simulation mode first, then test with non-critical systems ```yaml # Enable detailed USB debugging if needed diff --git a/configs/README.md b/configs/README.md index e6b28e9..07c519f 100644 --- a/configs/README.md +++ b/configs/README.md @@ -52,6 +52,14 @@ Complete control functionality (10 buttons + test monitoring): **UPS Testing**: `battery_quick`, `battery_deep`, `battery_stop`, `ups_test`, `ups_stop` **Test Monitoring**: `ups_test_result` text sensor +#### `delay_config.yaml` โญ **NEW** +UPS delay configuration package (3 number entities + automation scripts): + +**Delay Configuration**: `shutdown`, `start`, `reboot` delays (0-600 seconds) +**Protocol Support**: CyberPower (full), Generic HID (multi-vendor), APC (INPUT-ONLY fallback) +**Scripts**: Default delay application and configuration reading +**Home Assistant**: Number entities with proper device classes and validation + ### **Device-Specific Optimization Packages** #### `device_types/apc_backups_es.yaml` @@ -79,7 +87,8 @@ CyberPower CP1500 series optimizations: |-------------------|------------------|--------------|----------| | **Minimal** | `base_ups` + `essential_sensors` | **9 sensors** | Basic monitoring | | **Complete** | + `extended_sensors` + `ups_controls` | **27 sensors + 10 controls** | Full featured | -| **Device-Optimized** | + device-specific package | **28+ sensors + 10 controls** | Production ready | +| **Complete + Config** | + `delay_config` | **27 sensors + 10 controls + 3 number entities** | With UPS configuration | +| **Device-Optimized** | + device-specific package | **28+ sensors + 13+ controls** | Production ready | ### **Sensor Breakdown by Type:** @@ -102,6 +111,9 @@ CyberPower CP1500 series optimizations: - **Beeper (4)**: enable, disable, mute, test - **Testing (6)**: battery_quick, battery_deep, battery_stop, ups_test, ups_stop +#### **Number Controls** (3 total, all in delay_config.yaml): +- **Delay Configuration (3)**: shutdown_delay, start_delay, reboot_delay + #### **Smart Templates** (2 calculated sensors): - **Generic**: UPS Load Power (uses HID data when available) - **Device-Specific**: Device-optimized power calculations @@ -171,9 +183,10 @@ packages: essential: !include configs/essential_sensors.yaml extended: !include configs/extended_sensors.yaml controls: !include configs/ups_controls.yaml + delays: !include configs/delay_config.yaml device: !include configs/device_types/cyberpower_cp1500.yaml ``` -**Result**: ~300 lines โ†’ Complete functionality +**Result**: ~350 lines โ†’ Complete functionality with UPS configuration ### 3. Custom Configuration ```yaml