Public Access
refactor(ups-hid): clean abstraction layers, strategy pattern for protocol selection and proper data structure
Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
41 files changed
+4768
-3013
No files matched your search
+84
-30
@@ -1,56 +1,110 @@
|
||||
# UPS HID Configuration Management
|
||||
|
||||
This directory provides a modular, maintainable approach to UPS HID device configuration using ESPHome packages. Instead of maintaining large, complex configuration files, you can compose configurations from reusable components.
|
||||
This directory provides a modular, maintainable approach to UPS HID device configuration using ESPHome packages with the new Protocol Factory system. Instead of maintaining large, complex configuration files, you can compose configurations from reusable components.
|
||||
|
||||
## Modular Configuration Packages
|
||||
## 📦 Modular Configuration Packages
|
||||
|
||||
### Core Packages
|
||||
### **Core Packages** (Always Required)
|
||||
|
||||
#### `base_ups.yaml`
|
||||
Essential foundation for all UPS devices:
|
||||
- ESP32-S3 hardware configuration
|
||||
- Network setup (WiFi, OTA, Web server)
|
||||
- UPS HID component initialization
|
||||
- Status LED with basic patterns
|
||||
- Essential binary sensors for LED automation
|
||||
- UPS HID component initialization with Protocol Factory
|
||||
- Status LED with smart patterns
|
||||
- Essential binary sensors: `online`, `on_battery`, `low_battery`, `fault`
|
||||
- Essential text sensors: `status` (as "UPS Status"), `protocol` (as "Detected Protocol")
|
||||
|
||||
#### `essential_sensors.yaml`
|
||||
Core monitoring sensors available on all UPS protocols:
|
||||
- Battery level, input/output voltage, load percentage
|
||||
- Runtime remaining, basic device information
|
||||
- System monitoring (uptime, WiFi signal)
|
||||
Core monitoring sensors (5 sensors) available on all protocols:
|
||||
- **Sensors**: `battery_level`, `input_voltage`, `output_voltage`, `load_percent`, `runtime`
|
||||
- **Text Sensors**: `manufacturer`, `model`
|
||||
- **Binary Sensors**: `charging`, `overload`
|
||||
- **System Monitoring**: uptime, WiFi signal, IP address, ESPHome version
|
||||
- Compatible with APC, CyberPower, and Generic protocols
|
||||
|
||||
### **Optional Enhancement Packages**
|
||||
|
||||
#### `extended_sensors.yaml`
|
||||
Advanced sensors for feature-rich devices:
|
||||
- Battery voltage (actual and nominal)
|
||||
- Input transfer limits and frequency
|
||||
- UPS configuration parameters
|
||||
- Power calculations and analysis
|
||||
- Optimized for CyberPower devices
|
||||
Advanced monitoring (17 additional sensors) for feature-rich devices:
|
||||
|
||||
**Enhanced Voltage Monitoring**:
|
||||
- `battery_voltage`, `battery_voltage_nominal`, `input_voltage_nominal`
|
||||
- `input_transfer_low`, `input_transfer_high`, `frequency`
|
||||
|
||||
**Power & Configuration**:
|
||||
- `ups_realpower_nominal`, `ups_delay_shutdown`, `ups_delay_start`, `ups_delay_reboot`
|
||||
|
||||
**Dynamic Timer Monitoring** (negative values = no active countdown):
|
||||
- `ups_timer_shutdown`, `ups_timer_start`, `ups_timer_reboot`
|
||||
- `battery_runtime_low`
|
||||
|
||||
**Extended Device Information**:
|
||||
- `serial_number`, `firmware_version`, `ups_beeper_status`, `input_sensitivity`
|
||||
- `ups_mfr_date`, `battery_status`, `ups_firmware_aux`
|
||||
|
||||
**Smart Template**: Calculated load power using HID nominal power when available
|
||||
|
||||
#### `ups_controls.yaml`
|
||||
Interactive control functionality:
|
||||
- Beeper control (enable/disable/mute/test)
|
||||
- Battery testing (quick/deep/stop)
|
||||
- Panel testing (start/stop)
|
||||
- Test result monitoring
|
||||
Complete control functionality (10 buttons + test monitoring):
|
||||
|
||||
### Device-Specific Packages
|
||||
**Beeper Control**: `enable`, `disable`, `mute`, `test`
|
||||
**UPS Testing**: `battery_quick`, `battery_deep`, `battery_stop`, `ups_test`, `ups_stop`
|
||||
**Test Monitoring**: `ups_test_result` text sensor
|
||||
|
||||
### **Device-Specific Optimization Packages**
|
||||
|
||||
#### `device_types/apc_backups_es.yaml`
|
||||
APC Back-UPS ES series optimizations:
|
||||
- Slower update intervals (APC devices need more time)
|
||||
- APC-specific power calculations (405W nominal)
|
||||
- Enhanced protocol debugging
|
||||
- Device-specific status monitoring
|
||||
- Slower update intervals (15s - APC devices need more time)
|
||||
- APC-specific power calculations (405W nominal for ES 700)
|
||||
- Enhanced protocol debugging (`ups_hid.apc: DEBUG`)
|
||||
- Fixed device-specific script references
|
||||
|
||||
#### `device_types/cyberpower_cp1500.yaml`
|
||||
CyberPower CP1500 series optimizations:
|
||||
- Fast update intervals (CyberPower responds quickly)
|
||||
- Advanced threshold monitoring
|
||||
- Extended device information
|
||||
- Rich sensor data utilization
|
||||
- Fast update intervals (10s - CyberPower responds quickly)
|
||||
- **Additional sensor**: `battery_charge_low` threshold
|
||||
- **Enhanced power calculation**: Uses HID nominal power when available (900W default)
|
||||
- **Device-specific text sensor**: `battery_mfr_date` (separate from UPS date)
|
||||
- Rich monitoring script with comprehensive status logging
|
||||
|
||||
---
|
||||
|
||||
## 📊 **Complete Sensor Summary**
|
||||
|
||||
### **Package Composition Options:**
|
||||
|
||||
| Configuration Level | Packages Included | Total Sensors | Use Case |
|
||||
|-------------------|------------------|--------------|----------|
|
||||
| **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 |
|
||||
|
||||
### **Sensor Breakdown by Type:**
|
||||
|
||||
#### **Numeric Sensors** (22 total available):
|
||||
- **Essential (5)**: battery_level, input_voltage, output_voltage, load_percent, runtime
|
||||
- **Extended (17)**: All enhanced voltage/power/timer/threshold monitoring
|
||||
|
||||
#### **Text Sensors** (10 total available):
|
||||
- **Base (2)**: status, protocol *(in base_ups.yaml)*
|
||||
- **Essential (2)**: manufacturer, model
|
||||
- **Extended (6)**: serial_number, firmware_version, ups_beeper_status, input_sensitivity, ups_mfr_date, battery_status, ups_firmware_aux
|
||||
- **Controls (1)**: ups_test_result *(in ups_controls.yaml)*
|
||||
- **Device-Specific (+1)**: battery_mfr_date *(CyberPower only)*
|
||||
|
||||
#### **Binary Sensors** (6 total):
|
||||
- **Base (4)**: online, on_battery, low_battery, fault
|
||||
- **Essential (2)**: charging, overload
|
||||
|
||||
#### **Button Controls** (10 total, all in ups_controls.yaml):
|
||||
- **Beeper (4)**: enable, disable, mute, test
|
||||
- **Testing (6)**: battery_quick, battery_deep, battery_stop, ups_test, ups_stop
|
||||
|
||||
#### **Smart Templates** (2 calculated sensors):
|
||||
- **Generic**: UPS Load Power (uses HID data when available)
|
||||
- **Device-Specific**: Device-optimized power calculations
|
||||
|
||||
## Testing Configurations
|
||||
|
||||
|
||||
Reference in new issue
Block a user