docs(ups-hid): timer and delay functionality

Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
bullshit committed 2025-08-26 10:04:01 +02:00
1 parent ae6cf92f27
commit f3db5e1dba
3 files changed
+114 -2

No files matched your search

+1
View File
@@ -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
+98
View File
@@ -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
+15 -2
View File
@@ -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