Public Access
feat(ups-hid): setting up testing infrastructure
Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
22 files changed
+1657
-1243
No files matched your search
@@ -12,6 +12,7 @@ pip install --upgrade esphome
|
||||
# Claude Code - MCP server
|
||||
sudo -u esphome bash -c "curl -fsSL https://claude.ai/install.sh | bash -s latest"
|
||||
sudo -u esphome bash -c "/home/esphome/.local/bin/claude mcp add code npx \"@steipete/claude-code-mcp\" \"/workspace\""
|
||||
sudo pip install -r /workspace/tests/requirements.txt
|
||||
|
||||
# Set up USB permissions
|
||||
cat > /etc/udev/rules.d/99-esphome-usb.rules << 'UDEV_EOF'
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
esphome:
|
||||
name: ups-hid-beeper-test
|
||||
friendly_name: "UPS HID Beeper Test"
|
||||
comment: "USB Beeper Control Test"
|
||||
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
variant: esp32s3
|
||||
framework:
|
||||
type: esp-idf
|
||||
version: 5.3.2
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
level: DEBUG
|
||||
baud_rate: 115200
|
||||
hardware_uart: UART0
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
ups_hid.apc: DEBUG
|
||||
ups_hid.apc_hid: DEBUG
|
||||
ups_hid.generic: DEBUG
|
||||
usb_host: DEBUG
|
||||
esp32.usb_host: DEBUG
|
||||
usb: DEBUG
|
||||
usb-otg: DEBUG
|
||||
HCD: DEBUG
|
||||
USBH: DEBUG
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: !secret api_encryption_key
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: !secret ota_password
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
ap:
|
||||
ssid: "UPS-HID-Monitor"
|
||||
password: !secret ap_password
|
||||
|
||||
captive_portal:
|
||||
web_server:
|
||||
|
||||
# RGB LED for status indication
|
||||
light:
|
||||
- platform: esp32_rmt_led_strip
|
||||
chipset: WS2812
|
||||
pin: GPIO48
|
||||
num_leds: 1
|
||||
rgb_order: GRB
|
||||
name: "UPS Status LED"
|
||||
id: status_led
|
||||
effects:
|
||||
- strobe:
|
||||
name: "Critical Strobe"
|
||||
colors:
|
||||
- state: true
|
||||
brightness: 100%
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
duration: 250ms
|
||||
- state: false
|
||||
duration: 250ms
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: components
|
||||
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 30s
|
||||
auto_detect_protocol: true
|
||||
protocol_timeout: 15s
|
||||
|
||||
# Beeper control buttons
|
||||
button:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: enable
|
||||
name: "UPS Beeper Enable"
|
||||
icon: "mdi:volume-high"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: disable
|
||||
name: "UPS Beeper Disable"
|
||||
icon: "mdi:volume-off"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: mute
|
||||
name: "UPS Beeper Mute"
|
||||
icon: "mdi:volume-mute"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: test
|
||||
name: "UPS Beeper Test"
|
||||
icon: "mdi:bell-ring"
|
||||
|
||||
# Status sensors for monitoring
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
type: ups_beeper_status
|
||||
name: "UPS Beeper Status"
|
||||
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
type: battery_level
|
||||
name: "UPS Battery Level"
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
|
||||
binary_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
type: online
|
||||
name: "UPS Online"
|
||||
device_class: power
|
||||
@@ -0,0 +1,187 @@
|
||||
# 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.
|
||||
|
||||
## Modular Configuration Packages
|
||||
|
||||
### Core Packages
|
||||
|
||||
#### `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
|
||||
|
||||
#### `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)
|
||||
- Compatible with APC, CyberPower, and Generic protocols
|
||||
|
||||
#### `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
|
||||
|
||||
#### `ups_controls.yaml`
|
||||
Interactive control functionality:
|
||||
- Beeper control (enable/disable/mute/test)
|
||||
- Battery testing (quick/deep/stop)
|
||||
- Panel testing (start/stop)
|
||||
- Test result monitoring
|
||||
|
||||
### Device-Specific 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
|
||||
|
||||
#### `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
|
||||
|
||||
## Testing Configurations
|
||||
|
||||
### `testing/basic_test.yaml`
|
||||
Minimal configuration for protocol detection and basic functionality:
|
||||
```yaml
|
||||
packages:
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
```
|
||||
**Use for**: Initial device testing, protocol verification, basic connectivity
|
||||
|
||||
### `testing/beeper_test.yaml`
|
||||
Focused beeper control testing:
|
||||
```yaml
|
||||
packages:
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
controls: !include ../ups_controls.yaml
|
||||
```
|
||||
**Use for**: Testing beeper functionality, control operations
|
||||
|
||||
### `testing/simulation_test.yaml`
|
||||
Complete testing without physical hardware:
|
||||
```yaml
|
||||
packages:
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
extended: !include ../extended_sensors.yaml
|
||||
controls: !include ../ups_controls.yaml
|
||||
```
|
||||
**Use for**: Development, CI/CD testing, feature demonstration
|
||||
|
||||
## Production Examples
|
||||
|
||||
### `examples/apc-ups-monitor.yaml`
|
||||
Complete APC UPS production configuration:
|
||||
- Modular package composition
|
||||
- Device-specific optimizations
|
||||
- Custom automation examples
|
||||
- Network and notification setup
|
||||
|
||||
### `examples/rack-ups-monitor.yaml`
|
||||
Complete CyberPower UPS production configuration:
|
||||
- Advanced sensor utilization
|
||||
- Smart threshold monitoring
|
||||
- Rich data analysis
|
||||
- Enhanced automation
|
||||
|
||||
## Usage Patterns
|
||||
|
||||
### 1. Basic UPS Monitoring
|
||||
```yaml
|
||||
packages:
|
||||
base_ups: !include configs/base_ups.yaml
|
||||
essential: !include configs/essential_sensors.yaml
|
||||
```
|
||||
**Result**: ~150 lines → Essential monitoring only
|
||||
|
||||
### 2. Full-Featured UPS
|
||||
```yaml
|
||||
packages:
|
||||
base_ups: !include configs/base_ups.yaml
|
||||
essential: !include configs/essential_sensors.yaml
|
||||
extended: !include configs/extended_sensors.yaml
|
||||
controls: !include configs/ups_controls.yaml
|
||||
device: !include configs/device_types/cyberpower_cp1500.yaml
|
||||
```
|
||||
**Result**: ~300 lines → Complete functionality
|
||||
|
||||
### 3. Custom Configuration
|
||||
```yaml
|
||||
substitutions:
|
||||
name: "my-custom-ups"
|
||||
update_interval: "30s"
|
||||
|
||||
packages:
|
||||
base_ups: !include configs/base_ups.yaml
|
||||
essential: !include configs/essential_sensors.yaml
|
||||
|
||||
# Add custom sensors or overrides here
|
||||
sensor:
|
||||
- platform: template
|
||||
name: "Custom Power Calculation"
|
||||
# ... custom logic
|
||||
```
|
||||
|
||||
## Configuration Management Best Practices
|
||||
|
||||
### 1. **Start Simple**
|
||||
Begin with `basic_test.yaml` to verify device detection and protocol compatibility.
|
||||
|
||||
### 2. **Layer Functionality**
|
||||
Add packages incrementally:
|
||||
- Start with `base_ups.yaml` + `essential_sensors.yaml`
|
||||
- Add `extended_sensors.yaml` if you need advanced metrics
|
||||
- Include `ups_controls.yaml` for interactive features
|
||||
- Apply device-specific packages last
|
||||
|
||||
### 3. **Use Substitutions for Customization**
|
||||
Override defaults without modifying packages:
|
||||
```yaml
|
||||
substitutions:
|
||||
name: "office-ups"
|
||||
friendly_name: "Office UPS Monitor"
|
||||
update_interval: "30s"
|
||||
simulation_mode: "false"
|
||||
```
|
||||
|
||||
### 4. **Device-Specific Optimization**
|
||||
- **APC devices**: Use slower update intervals (15-30s)
|
||||
- **CyberPower devices**: Can handle faster updates (5-10s)
|
||||
- **Generic devices**: Start conservative (30s) and adjust
|
||||
|
||||
### 5. **Environment-Specific Files**
|
||||
```yaml
|
||||
# development.yaml
|
||||
substitutions:
|
||||
log_level: "VERBOSE"
|
||||
update_interval: "5s"
|
||||
simulation_mode: "true"
|
||||
|
||||
# production.yaml
|
||||
substitutions:
|
||||
log_level: "INFO"
|
||||
update_interval: "30s"
|
||||
simulation_mode: "false"
|
||||
```
|
||||
|
||||
### 6. **Testing Strategy**
|
||||
- **Protocol Testing**: Use `basic_test.yaml`
|
||||
- **Feature Testing**: Use specific test configurations
|
||||
- **Integration Testing**: Use `simulation_test.yaml`
|
||||
- **Production Validation**: Use device-specific examples
|
||||
@@ -0,0 +1,169 @@
|
||||
# Base UPS Configuration Package
|
||||
# Common settings for all UPS HID devices
|
||||
# Use with: packages: !include configs/base_ups.yaml
|
||||
|
||||
# Substitutions with sensible defaults
|
||||
substitutions:
|
||||
# Device identification
|
||||
friendly_name: "${name}"
|
||||
device_description: "UPS Monitor with ESP32-S3"
|
||||
|
||||
# UPS configuration
|
||||
update_interval: "10s"
|
||||
protocol_timeout: "15s"
|
||||
simulation_mode: "false"
|
||||
|
||||
# LED status pin (default for ESP32-S3-DevKitC-1)
|
||||
led_pin: "GPIO48"
|
||||
|
||||
# Logging level
|
||||
log_level: "DEBUG"
|
||||
|
||||
# Core ESP32 configuration
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
# Logging configuration
|
||||
logger:
|
||||
level: ${log_level}
|
||||
baud_rate: 115200
|
||||
hardware_uart: UART0
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
|
||||
# Network configuration
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
domain: !secret wifi_dns_domain
|
||||
ap:
|
||||
ssid: "${friendly_name} Fallback"
|
||||
password: !secret ap_password
|
||||
|
||||
captive_portal:
|
||||
|
||||
# OTA updates
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: !secret ota_password
|
||||
|
||||
# Web server for diagnostics
|
||||
web_server:
|
||||
port: 80
|
||||
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../components
|
||||
|
||||
# Main UPS HID Component
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: ${update_interval}
|
||||
protocol_timeout: ${protocol_timeout}
|
||||
auto_detect_protocol: true
|
||||
simulation_mode: ${simulation_mode}
|
||||
|
||||
# Status LED configuration
|
||||
light:
|
||||
- platform: esp32_rmt_led_strip
|
||||
chipset: WS2812
|
||||
pin: ${led_pin}
|
||||
num_leds: 1
|
||||
rgb_order: GRB
|
||||
name: "UPS Status LED"
|
||||
id: ups_status_led
|
||||
restore_mode: ALWAYS_OFF
|
||||
effects:
|
||||
- strobe:
|
||||
name: "Critical Alert"
|
||||
colors:
|
||||
- state: true
|
||||
brightness: 100%
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
duration: 200ms
|
||||
- state: false
|
||||
duration: 200ms
|
||||
- pulse:
|
||||
name: "Battery Warning"
|
||||
transition_length: 1.5s
|
||||
min_brightness: 10%
|
||||
max_brightness: 90%
|
||||
- pulse:
|
||||
name: "Normal Status"
|
||||
transition_length: 3s
|
||||
min_brightness: 20%
|
||||
max_brightness: 60%
|
||||
|
||||
# LED control automation
|
||||
interval:
|
||||
- interval: 2s
|
||||
then:
|
||||
- lambda: |-
|
||||
if (id(low_battery).state || id(ups_fault).state) {
|
||||
auto call = id(ups_status_led).turn_on();
|
||||
call.set_rgb(1.0, 0.0, 0.0);
|
||||
call.set_effect("Critical Alert");
|
||||
call.perform();
|
||||
} else if (id(on_battery).state) {
|
||||
auto call = id(ups_status_led).turn_on();
|
||||
call.set_rgb(1.0, 0.5, 0.0);
|
||||
call.set_effect("Battery Warning");
|
||||
call.perform();
|
||||
} else if (id(ups_online).state) {
|
||||
auto call = id(ups_status_led).turn_on();
|
||||
call.set_rgb(0.0, 1.0, 0.0);
|
||||
call.set_effect("Normal Status");
|
||||
call.perform();
|
||||
} else {
|
||||
id(ups_status_led).turn_off().perform();
|
||||
}
|
||||
|
||||
# Essential binary sensors (required for LED automation)
|
||||
binary_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Online"
|
||||
id: ups_online
|
||||
type: online
|
||||
device_class: connectivity
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "On Battery Power"
|
||||
id: on_battery
|
||||
type: on_battery
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Low Battery Warning"
|
||||
id: low_battery
|
||||
type: low_battery
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Fault"
|
||||
id: ups_fault
|
||||
type: fault
|
||||
device_class: problem
|
||||
|
||||
# Essential text sensors
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
id: ups_status_text
|
||||
type: status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Detected Protocol"
|
||||
id: ups_protocol
|
||||
type: protocol
|
||||
@@ -0,0 +1,67 @@
|
||||
# APC Back-UPS ES Series Configuration
|
||||
# Optimized for APC Back-UPS ES 700 (VID: 0x051D, PID: 0x0002)
|
||||
# Use with: packages: !include configs/device_types/apc_backups_es.yaml
|
||||
|
||||
substitutions:
|
||||
# Device-specific overrides
|
||||
device_description: "APC Back-UPS ES 700 Monitor"
|
||||
log_level: "DEBUG"
|
||||
|
||||
# APC-specific settings
|
||||
update_interval: "15s" # APC devices can be slower to respond
|
||||
protocol_timeout: "20s"
|
||||
|
||||
# Override UPS component with APC-specific settings
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: ${update_interval}
|
||||
protocol_timeout: ${protocol_timeout}
|
||||
auto_detect_protocol: true
|
||||
simulation_mode: ${simulation_mode}
|
||||
# Uncomment if auto-detection fails:
|
||||
# usb_vendor_id: 0x051D
|
||||
# usb_product_id: 0x0002
|
||||
|
||||
# Enhanced logging for APC protocol debugging
|
||||
logger:
|
||||
level: ${log_level}
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
ups_hid.apc: DEBUG
|
||||
ups_hid.apc_hid: DEBUG
|
||||
|
||||
# APC-specific power calculations
|
||||
sensor:
|
||||
- platform: template
|
||||
name: "UPS Load Power (APC)"
|
||||
id: ups_load_power_apc
|
||||
unit_of_measurement: "W"
|
||||
device_class: power
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
lambda: |-
|
||||
if (!std::isnan(id(load_percentage).state)) {
|
||||
// APC Back-UPS ES 700: 405W nominal power
|
||||
float apc_max_power = 405.0;
|
||||
return (apc_max_power * id(load_percentage).state) / 100.0;
|
||||
}
|
||||
return NAN;
|
||||
update_interval: 30s
|
||||
|
||||
# APC-specific monitoring scripts
|
||||
script:
|
||||
- id: apc_status_check
|
||||
then:
|
||||
- logger.log:
|
||||
format: "APC Status: Battery=%.1f%%, Load=%.1fw, Status=%s"
|
||||
args:
|
||||
- "id(battery_level).state"
|
||||
- "id(ups_load_power_apc).state"
|
||||
- "id(ups_status_text).state.c_str()"
|
||||
level: INFO
|
||||
|
||||
# APC device monitoring
|
||||
interval:
|
||||
- interval: 60s
|
||||
then:
|
||||
- script.execute: apc_status_check
|
||||
@@ -0,0 +1,133 @@
|
||||
# CyberPower CP1500 Series Configuration
|
||||
# Optimized for CyberPower CP1500EPFCLCD (VID: 0x0764, PID: 0x0501)
|
||||
# Use with: packages: !include configs/device_types/cyberpower_cp1500.yaml
|
||||
|
||||
substitutions:
|
||||
# Device-specific overrides
|
||||
device_description: "CyberPower CP1500EPFCLCD Monitor"
|
||||
log_level: "DEBUG"
|
||||
|
||||
# CyberPower-specific settings
|
||||
update_interval: "10s" # CyberPower devices respond quickly
|
||||
protocol_timeout: "15s"
|
||||
|
||||
# Override UPS component with CyberPower-specific settings
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: ${update_interval}
|
||||
protocol_timeout: ${protocol_timeout}
|
||||
auto_detect_protocol: true
|
||||
simulation_mode: ${simulation_mode}
|
||||
# Uncomment if auto-detection fails:
|
||||
# usb_vendor_id: 0x0764
|
||||
# usb_product_id: 0x0501
|
||||
|
||||
# Enhanced logging for CyberPower protocol debugging
|
||||
logger:
|
||||
level: ${log_level}
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
ups_hid.cyberpower: DEBUG
|
||||
|
||||
# CyberPower-specific threshold sensors
|
||||
sensor:
|
||||
# Battery threshold monitoring (available on CyberPower)
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Charge Low Threshold"
|
||||
id: battery_charge_low
|
||||
type: battery_charge_low
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Runtime Low Threshold"
|
||||
id: battery_runtime_low
|
||||
type: battery_runtime_low
|
||||
unit_of_measurement: "min"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# CyberPower-specific timer values
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Timer Reboot"
|
||||
id: ups_timer_reboot
|
||||
type: ups_timer_reboot
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Timer Shutdown"
|
||||
id: ups_timer_shutdown
|
||||
type: ups_timer_shutdown
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Timer Start"
|
||||
id: ups_timer_start
|
||||
type: ups_timer_start
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# CyberPower-specific enhanced device info
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Status"
|
||||
id: battery_status
|
||||
type: battery_status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Type"
|
||||
id: battery_type
|
||||
type: battery_type
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Manufacture Date"
|
||||
id: battery_mfr_date
|
||||
type: battery_mfr_date
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Manufacture Date"
|
||||
id: ups_mfr_date
|
||||
type: ups_mfr_date
|
||||
|
||||
# CyberPower-specific monitoring scripts
|
||||
script:
|
||||
- id: cyberpower_detailed_status
|
||||
then:
|
||||
- logger.log:
|
||||
format: "CyberPower Status: Battery=%.1f%% (%.1fV/%.0fV), Load=%.1f%% (%.0fW/%.0fW), Input=%.1fV, Runtime=%.1fmin"
|
||||
args:
|
||||
- "id(battery_level).state"
|
||||
- "id(battery_voltage).state"
|
||||
- "id(battery_voltage_nominal).state"
|
||||
- "id(load_percentage).state"
|
||||
- "id(ups_load_power).state"
|
||||
- "id(ups_realpower_nominal).state"
|
||||
- "id(input_voltage).state"
|
||||
- "id(runtime_remaining).state"
|
||||
level: INFO
|
||||
|
||||
# Enhanced monitoring for CyberPower features
|
||||
interval:
|
||||
- interval: 120s
|
||||
then:
|
||||
- script.execute: cyberpower_detailed_status
|
||||
@@ -0,0 +1,105 @@
|
||||
# Essential UPS Sensors Package
|
||||
# Core monitoring sensors for all UPS devices
|
||||
# Use with: packages: !include configs/essential_sensors.yaml
|
||||
|
||||
sensor:
|
||||
# Core UPS metrics - available on all protocols
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Level"
|
||||
id: battery_level
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Voltage"
|
||||
id: input_voltage
|
||||
type: input_voltage
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Output Voltage"
|
||||
id: output_voltage
|
||||
type: output_voltage
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Load Percentage"
|
||||
id: load_percentage
|
||||
type: load_percent
|
||||
unit_of_measurement: "%"
|
||||
device_class: power_factor
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Runtime Remaining"
|
||||
id: runtime_remaining
|
||||
type: runtime
|
||||
unit_of_measurement: "min"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# System monitoring
|
||||
- platform: uptime
|
||||
name: "Uptime"
|
||||
id: uptime_sensor
|
||||
update_interval: 60s
|
||||
|
||||
- platform: wifi_signal
|
||||
name: "WiFi Signal"
|
||||
id: wifi_signal_sensor
|
||||
update_interval: 60s
|
||||
|
||||
text_sensor:
|
||||
# Device identification
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Manufacturer"
|
||||
id: ups_manufacturer
|
||||
type: manufacturer
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Model"
|
||||
id: ups_model
|
||||
type: model
|
||||
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
name: "IP Address"
|
||||
id: ip_address
|
||||
|
||||
- platform: version
|
||||
name: "ESPHome Version"
|
||||
id: esphome_version
|
||||
|
||||
binary_sensor:
|
||||
# Additional status sensors
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Charging"
|
||||
id: battery_charging
|
||||
type: charging
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Overload Warning"
|
||||
id: overload_warning
|
||||
type: overload
|
||||
device_class: power
|
||||
@@ -0,0 +1,66 @@
|
||||
# Example: APC Back-UPS ES 700 Configuration
|
||||
# Complete production configuration for APC UPS
|
||||
# Copy and customize this file for your APC device
|
||||
|
||||
substitutions:
|
||||
name: "apc-ups-monitor"
|
||||
friendly_name: "Office APC UPS"
|
||||
|
||||
# Device customization
|
||||
timezone: "America/Vienna" # Replace with your timezone
|
||||
|
||||
# Testing/production mode
|
||||
simulation_mode: "false" # Set to "true" for testing without hardware
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "APC Back-UPS ES 700 Monitor"
|
||||
|
||||
# Use modular configuration packages
|
||||
packages:
|
||||
# Core functionality
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
|
||||
# Extended monitoring (optional - comment out if not needed)
|
||||
extended: !include ../extended_sensors.yaml
|
||||
|
||||
# Control buttons (optional - comment out if not needed)
|
||||
controls: !include ../ups_controls.yaml
|
||||
|
||||
# APC-specific optimizations
|
||||
apc_device: !include ../device_types/apc_backups_es.yaml
|
||||
|
||||
# Time component for accurate timestamps
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
timezone: "${timezone}"
|
||||
|
||||
# Optional: Home Assistant API (uncomment to enable)
|
||||
# api:
|
||||
# encryption:
|
||||
# key: "your_32_character_encryption_key_here=="
|
||||
|
||||
# Optional: Notification automation examples
|
||||
script:
|
||||
- id: power_outage_alert
|
||||
then:
|
||||
- logger.log:
|
||||
format: "POWER OUTAGE DETECTED - Battery at %.1f%%, Runtime: %.1f minutes"
|
||||
args:
|
||||
- "id(battery_level).state"
|
||||
- "id(runtime_remaining).state"
|
||||
level: WARN
|
||||
# Add your notification logic here (e.g., Home Assistant service call)
|
||||
|
||||
- id: power_restored_alert
|
||||
then:
|
||||
- logger.log:
|
||||
format: "POWER RESTORED - UPS back online"
|
||||
level: INFO
|
||||
# Add your notification logic here
|
||||
|
||||
# Custom automations would be handled in Home Assistant
|
||||
# The base sensors from base_ups.yaml and essential_sensors.yaml provide all the data needed
|
||||
@@ -0,0 +1,91 @@
|
||||
# Example: CyberPower CP1500EPFCLCD Configuration
|
||||
# Complete production configuration for CyberPower UPS
|
||||
# Copy and customize this file for your CyberPower device
|
||||
|
||||
substitutions:
|
||||
name: "rack-ups-monitor"
|
||||
friendly_name: "Rack CyberPower UPS"
|
||||
|
||||
# Device customization
|
||||
timezone: "America/Vienna" # Replace with your timezone
|
||||
|
||||
# Testing/production mode
|
||||
simulation_mode: "false" # Set to "true" for testing without hardware
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "CyberPower CP1500EPFCLCD Monitor"
|
||||
|
||||
# Use modular configuration packages
|
||||
packages:
|
||||
# Core functionality
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
|
||||
# Extended monitoring (recommended for CyberPower - rich sensor data)
|
||||
extended: !include ../extended_sensors.yaml
|
||||
|
||||
# Control buttons (recommended - CyberPower has excellent beeper support)
|
||||
controls: !include ../ups_controls.yaml
|
||||
|
||||
# CyberPower-specific optimizations
|
||||
cyberpower_device: !include ../device_types/cyberpower_cp1500.yaml
|
||||
|
||||
# Time component for accurate timestamps
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
timezone: "${timezone}"
|
||||
|
||||
# Optional: Home Assistant API (uncomment to enable)
|
||||
# api:
|
||||
# encryption:
|
||||
# key: "your_32_character_encryption_key_here=="
|
||||
|
||||
# CyberPower-specific automation examples
|
||||
script:
|
||||
- id: battery_threshold_alert
|
||||
then:
|
||||
- logger.log:
|
||||
format: "BATTERY THRESHOLD ALERT - Current: %.1f%%, Low Threshold: %.1f%%, Runtime Low: %.1f min"
|
||||
args:
|
||||
- "id(battery_level).state"
|
||||
- "id(battery_charge_low).state"
|
||||
- "id(battery_runtime_low).state"
|
||||
level: WARN
|
||||
|
||||
- id: advanced_power_analysis
|
||||
then:
|
||||
- logger.log:
|
||||
format: "POWER ANALYSIS - Load: %.1f%% (%.0fW/%.0fW), Input: %.1fV (%.0fV nominal), Battery: %.1fV/%.0fV"
|
||||
args:
|
||||
- "id(load_percentage).state"
|
||||
- "id(ups_load_power).state"
|
||||
- "id(ups_realpower_nominal).state"
|
||||
- "id(input_voltage).state"
|
||||
- "id(input_voltage_nominal).state"
|
||||
- "id(battery_voltage).state"
|
||||
- "id(battery_voltage_nominal).state"
|
||||
level: INFO
|
||||
|
||||
# Enhanced monitoring with CyberPower's rich data
|
||||
interval:
|
||||
- interval: 300s # Every 5 minutes
|
||||
then:
|
||||
- script.execute: advanced_power_analysis
|
||||
|
||||
# Smart threshold monitoring
|
||||
binary_sensor:
|
||||
- platform: template
|
||||
name: "Battery Below Custom Threshold"
|
||||
id: battery_custom_threshold
|
||||
lambda: |-
|
||||
// Trigger alert when battery drops below configured low threshold
|
||||
if (!std::isnan(id(battery_level).state) && !std::isnan(id(battery_charge_low).state)) {
|
||||
return id(battery_level).state <= id(battery_charge_low).state;
|
||||
}
|
||||
return false;
|
||||
on_press:
|
||||
then:
|
||||
- script.execute: battery_threshold_alert
|
||||
@@ -0,0 +1,144 @@
|
||||
# Extended UPS Sensors Package
|
||||
# Additional sensors for advanced monitoring (CyberPower optimized)
|
||||
# Use with: packages: !include configs/extended_sensors.yaml
|
||||
|
||||
sensor:
|
||||
# Advanced battery metrics
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Voltage"
|
||||
id: battery_voltage
|
||||
type: battery_voltage
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Voltage Nominal"
|
||||
id: battery_voltage_nominal
|
||||
type: battery_voltage_nominal
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# Input power analysis
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Voltage Nominal"
|
||||
id: input_voltage_nominal
|
||||
type: input_voltage_nominal
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Transfer Low"
|
||||
id: input_transfer_low
|
||||
type: input_transfer_low
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Transfer High"
|
||||
id: input_transfer_high
|
||||
type: input_transfer_high
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Frequency"
|
||||
id: input_frequency
|
||||
type: frequency
|
||||
unit_of_measurement: "Hz"
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
|
||||
# UPS configuration metrics
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Real Power Nominal"
|
||||
id: ups_realpower_nominal
|
||||
type: ups_realpower_nominal
|
||||
unit_of_measurement: "W"
|
||||
device_class: power
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Delay Shutdown"
|
||||
id: ups_delay_shutdown
|
||||
type: ups_delay_shutdown
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Delay Start"
|
||||
id: ups_delay_start
|
||||
type: ups_delay_start
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# Calculated power consumption
|
||||
- platform: template
|
||||
name: "UPS Load Power"
|
||||
id: ups_load_power
|
||||
unit_of_measurement: "W"
|
||||
device_class: power
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
lambda: |-
|
||||
if (!std::isnan(id(load_percentage).state)) {
|
||||
float ups_max_power = 700.0; // Default fallback
|
||||
|
||||
// Use HID nominal power if available
|
||||
if (!std::isnan(id(ups_realpower_nominal).state)) {
|
||||
ups_max_power = id(ups_realpower_nominal).state;
|
||||
}
|
||||
|
||||
return (ups_max_power * id(load_percentage).state) / 100.0;
|
||||
}
|
||||
return NAN;
|
||||
update_interval: 30s
|
||||
|
||||
text_sensor:
|
||||
# Extended device information
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Serial Number"
|
||||
id: ups_serial_number
|
||||
type: serial_number
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Firmware Version"
|
||||
id: ups_firmware_version
|
||||
type: firmware_version
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Beeper Status"
|
||||
id: ups_beeper_status
|
||||
type: ups_beeper_status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Sensitivity"
|
||||
id: input_sensitivity
|
||||
type: input_sensitivity
|
||||
@@ -0,0 +1,5 @@
|
||||
# Gitignore settings for ESPHome
|
||||
# This is an example and may include too much for your use-case.
|
||||
# You can modify this file to suit your needs.
|
||||
/.esphome/
|
||||
/secrets.yaml
|
||||
@@ -0,0 +1,58 @@
|
||||
# Basic UPS Testing Configuration
|
||||
# Minimal setup for protocol detection and basic functionality testing
|
||||
# Use: esphome compile configs/testing/basic_test.yaml
|
||||
|
||||
substitutions:
|
||||
name: "ups-basic-test"
|
||||
friendly_name: "UPS Basic Test"
|
||||
simulation_mode: "false"
|
||||
log_level: "DEBUG"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "Basic UPS HID functionality test"
|
||||
|
||||
# Include secrets from root directory
|
||||
<<: !include ../../secrets.yaml
|
||||
|
||||
# Use base configuration package
|
||||
packages:
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
|
||||
# Override for testing - faster updates, more verbose logging
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 5s
|
||||
protocol_timeout: 10s
|
||||
auto_detect_protocol: true
|
||||
simulation_mode: ${simulation_mode}
|
||||
|
||||
# Enhanced logging for testing
|
||||
logger:
|
||||
level: VERBOSE
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
ups_hid.apc: DEBUG
|
||||
ups_hid.cyberpower: DEBUG
|
||||
ups_hid.generic: DEBUG
|
||||
usb_host: DEBUG
|
||||
|
||||
# Simple test validation script
|
||||
script:
|
||||
- id: test_validation
|
||||
then:
|
||||
- logger.log:
|
||||
format: "TEST RESULTS - Protocol: %s, Battery: %.1f%%, Status: %s"
|
||||
args:
|
||||
- "id(ups_protocol).state.c_str()"
|
||||
- "id(battery_level).state"
|
||||
- "id(ups_status_text).state.c_str()"
|
||||
level: INFO
|
||||
|
||||
# Run validation every 30 seconds during testing
|
||||
interval:
|
||||
- interval: 30s
|
||||
then:
|
||||
- script.execute: test_validation
|
||||
@@ -0,0 +1,163 @@
|
||||
# Basic UPS Testing Configuration (Standalone)
|
||||
# Self-contained version that doesn't depend on external files for CI/CD
|
||||
# Use: esphome compile configs/testing/basic_test_standalone.yaml
|
||||
|
||||
substitutions:
|
||||
name: "ups-basic-test"
|
||||
friendly_name: "UPS Basic Test"
|
||||
simulation_mode: "false"
|
||||
log_level: "DEBUG"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "Basic UPS HID functionality test"
|
||||
|
||||
# Core ESP32 configuration
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
# Logging configuration
|
||||
logger:
|
||||
level: VERBOSE
|
||||
baud_rate: 115200
|
||||
hardware_uart: UART0
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
ups_hid.apc: DEBUG
|
||||
ups_hid.cyberpower: DEBUG
|
||||
ups_hid.generic: DEBUG
|
||||
usb_host: DEBUG
|
||||
|
||||
# Network configuration (minimal for testing)
|
||||
wifi:
|
||||
ssid: "TestNetwork"
|
||||
password: "TestPassword"
|
||||
ap:
|
||||
ssid: "${friendly_name} Fallback"
|
||||
password: "TestAPPassword"
|
||||
|
||||
captive_portal:
|
||||
|
||||
# OTA updates
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: "TestOTAPassword"
|
||||
|
||||
# Web server for diagnostics
|
||||
web_server:
|
||||
port: 80
|
||||
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../../components
|
||||
|
||||
# Main UPS HID Component
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 5s
|
||||
protocol_timeout: 10s
|
||||
auto_detect_protocol: true
|
||||
simulation_mode: ${simulation_mode}
|
||||
|
||||
# Status LED configuration
|
||||
light:
|
||||
- platform: esp32_rmt_led_strip
|
||||
chipset: WS2812
|
||||
pin: GPIO48
|
||||
num_leds: 1
|
||||
rgb_order: GRB
|
||||
name: "UPS Status LED"
|
||||
id: ups_status_led
|
||||
restore_mode: ALWAYS_OFF
|
||||
|
||||
# Required platform components (fix compilation errors)
|
||||
button:
|
||||
|
||||
# Essential binary sensors
|
||||
binary_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Online"
|
||||
id: ups_online
|
||||
type: online
|
||||
device_class: connectivity
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "On Battery Power"
|
||||
id: on_battery
|
||||
type: on_battery
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Low Battery Warning"
|
||||
id: low_battery
|
||||
type: low_battery
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Fault"
|
||||
id: ups_fault
|
||||
type: fault
|
||||
device_class: problem
|
||||
|
||||
# Essential text sensors
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
id: ups_status_text
|
||||
type: status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Detected Protocol"
|
||||
id: ups_protocol
|
||||
type: protocol
|
||||
|
||||
# Core UPS metrics
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Level"
|
||||
id: battery_level
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Runtime Remaining"
|
||||
id: runtime_remaining
|
||||
type: runtime
|
||||
unit_of_measurement: "min"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# Simple test validation script
|
||||
script:
|
||||
- id: test_validation
|
||||
then:
|
||||
- logger.log:
|
||||
format: "TEST RESULTS - Protocol: %s, Battery: %.1f%%, Status: %s"
|
||||
args:
|
||||
- "id(ups_protocol).state.c_str()"
|
||||
- "id(battery_level).state"
|
||||
- "id(ups_status_text).state.c_str()"
|
||||
level: INFO
|
||||
|
||||
# Run validation every 30 seconds during testing
|
||||
interval:
|
||||
- interval: 30s
|
||||
then:
|
||||
- script.execute: test_validation
|
||||
@@ -0,0 +1,57 @@
|
||||
# UPS Beeper Control Testing Configuration
|
||||
# Focused testing for beeper functionality
|
||||
# Use: esphome compile configs/testing/beeper_test.yaml
|
||||
|
||||
substitutions:
|
||||
name: "ups-beeper-test"
|
||||
friendly_name: "UPS Beeper Test"
|
||||
simulation_mode: "false"
|
||||
log_level: "DEBUG"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "UPS beeper control functionality test"
|
||||
|
||||
# Include secrets from root directory
|
||||
<<: !include ../../secrets.yaml
|
||||
|
||||
# Use base configuration and controls package
|
||||
packages:
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
controls: !include ../ups_controls.yaml
|
||||
|
||||
# Override for testing - faster response
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 5s
|
||||
protocol_timeout: 10s
|
||||
auto_detect_protocol: true
|
||||
simulation_mode: ${simulation_mode}
|
||||
|
||||
# Beeper-focused logging
|
||||
logger:
|
||||
level: DEBUG
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
ups_hid.apc: DEBUG
|
||||
ups_hid.cyberpower: DEBUG
|
||||
button: DEBUG
|
||||
|
||||
# Beeper status monitoring
|
||||
script:
|
||||
- id: beeper_status_check
|
||||
then:
|
||||
- logger.log:
|
||||
format: "BEEPER STATUS: %s (Protocol: %s)"
|
||||
args:
|
||||
- "id(ups_beeper_status).state.c_str()"
|
||||
- "id(ups_protocol).state.c_str()"
|
||||
level: INFO
|
||||
|
||||
# Monitor beeper status changes
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
- script.execute: beeper_status_check
|
||||
@@ -0,0 +1,33 @@
|
||||
# Auto-generated test config for ESPHome matrix testing
|
||||
substitutions:
|
||||
device_name: "ups-matrix-test"
|
||||
friendly_name: "UPS Matrix Test"
|
||||
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
friendly_name: ${friendly_name}
|
||||
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
framework:
|
||||
type: esp-idf
|
||||
version: 5.3.0
|
||||
|
||||
logger:
|
||||
level: INFO
|
||||
|
||||
external_components:
|
||||
- source: components/
|
||||
components: [ ups_hid ]
|
||||
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 30s
|
||||
simulation_mode: true
|
||||
auto_detect_protocol: true
|
||||
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
type: battery_level
|
||||
name: "Battery Level"
|
||||
@@ -0,0 +1,61 @@
|
||||
# Minimal UPS Simulation Configuration
|
||||
# Simplest possible config for testing core functionality
|
||||
# Use: esphome compile configs/testing/minimal_simulation.yaml
|
||||
|
||||
substitutions:
|
||||
name: "ups-minimal-sim"
|
||||
friendly_name: "UPS Minimal Simulation"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "Minimal UPS simulation test"
|
||||
|
||||
# Core ESP32 configuration
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
# Minimal logging
|
||||
logger:
|
||||
level: INFO
|
||||
baud_rate: 115200
|
||||
|
||||
# Minimal network
|
||||
wifi:
|
||||
ssid: "TestNetwork"
|
||||
password: "TestPassword"
|
||||
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../../components
|
||||
|
||||
# UPS component only
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 10s
|
||||
protocol_timeout: 5s
|
||||
auto_detect_protocol: true
|
||||
simulation_mode: true
|
||||
|
||||
# Required platform components (fix compilation errors)
|
||||
button:
|
||||
binary_sensor:
|
||||
|
||||
# Single sensor test
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Level"
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
|
||||
# Single text sensor test
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
type: status
|
||||
@@ -0,0 +1,57 @@
|
||||
# UPS Simulation Testing Configuration
|
||||
# Testing without physical hardware using simulation mode
|
||||
# Use: esphome compile configs/testing/simulation_test.yaml
|
||||
|
||||
substitutions:
|
||||
name: "ups-simulation-test"
|
||||
friendly_name: "UPS Simulation Test"
|
||||
simulation_mode: "true" # Enable simulation mode
|
||||
log_level: "INFO"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "UPS simulation mode test (no hardware required)"
|
||||
|
||||
# Include secrets from root directory
|
||||
<<: !include ../../secrets.yaml
|
||||
|
||||
# Use base configuration packages
|
||||
packages:
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
extended: !include ../extended_sensors.yaml
|
||||
controls: !include ../ups_controls.yaml
|
||||
|
||||
# Override for simulation testing
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 5s # Fast updates for demo
|
||||
protocol_timeout: 5s
|
||||
auto_detect_protocol: true
|
||||
simulation_mode: ${simulation_mode}
|
||||
|
||||
# Reduced logging for simulation
|
||||
logger:
|
||||
level: ${log_level}
|
||||
logs:
|
||||
ups_hid: INFO
|
||||
|
||||
# Simulation validation script
|
||||
script:
|
||||
- id: simulation_demo
|
||||
then:
|
||||
- logger.log:
|
||||
format: "SIMULATION DATA - Battery: %.1f%%, Load: %.1f%%, Input: %.1fV, Output: %.1fV"
|
||||
args:
|
||||
- "id(battery_level).state"
|
||||
- "id(load_percentage).state"
|
||||
- "id(input_voltage).state"
|
||||
- "id(output_voltage).state"
|
||||
level: INFO
|
||||
|
||||
# Demo data updates every 10 seconds
|
||||
interval:
|
||||
- interval: 10s
|
||||
then:
|
||||
- script.execute: simulation_demo
|
||||
@@ -0,0 +1,190 @@
|
||||
# UPS Simulation Testing Configuration (Standalone)
|
||||
# Testing without physical hardware using simulation mode
|
||||
# Use: esphome compile configs/testing/simulation_test_standalone.yaml
|
||||
|
||||
substitutions:
|
||||
name: "ups-simulation-test"
|
||||
friendly_name: "UPS Simulation Test"
|
||||
simulation_mode: "true" # Enable simulation mode
|
||||
log_level: "INFO"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "UPS simulation mode test (no hardware required)"
|
||||
|
||||
# Core ESP32 configuration
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
# Reduced logging for simulation
|
||||
logger:
|
||||
level: ${log_level}
|
||||
baud_rate: 115200
|
||||
hardware_uart: UART0
|
||||
logs:
|
||||
ups_hid: INFO
|
||||
|
||||
# Network configuration (minimal for testing)
|
||||
wifi:
|
||||
ssid: "TestNetwork"
|
||||
password: "TestPassword"
|
||||
ap:
|
||||
ssid: "${friendly_name} Fallback"
|
||||
password: "TestAPPassword"
|
||||
|
||||
captive_portal:
|
||||
|
||||
# OTA updates
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: "TestOTAPassword"
|
||||
|
||||
# Web server for diagnostics
|
||||
web_server:
|
||||
port: 80
|
||||
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../../components
|
||||
|
||||
# Required platform components (fix compilation errors)
|
||||
button:
|
||||
|
||||
# Override for simulation testing
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 5s # Fast updates for demo
|
||||
protocol_timeout: 5s
|
||||
auto_detect_protocol: true
|
||||
simulation_mode: ${simulation_mode}
|
||||
|
||||
# Status LED configuration
|
||||
light:
|
||||
- platform: esp32_rmt_led_strip
|
||||
chipset: WS2812
|
||||
pin: GPIO48
|
||||
num_leds: 1
|
||||
rgb_order: GRB
|
||||
name: "UPS Status LED"
|
||||
id: ups_status_led
|
||||
restore_mode: ALWAYS_OFF
|
||||
|
||||
# Essential binary sensors
|
||||
binary_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Online"
|
||||
id: ups_online
|
||||
type: online
|
||||
device_class: connectivity
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "On Battery Power"
|
||||
id: on_battery
|
||||
type: on_battery
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Low Battery Warning"
|
||||
id: low_battery
|
||||
type: low_battery
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Fault"
|
||||
id: ups_fault
|
||||
type: fault
|
||||
device_class: problem
|
||||
|
||||
# Essential text sensors
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
id: ups_status_text
|
||||
type: status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Detected Protocol"
|
||||
id: ups_protocol
|
||||
type: protocol
|
||||
|
||||
# Core UPS metrics - available on all protocols
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Level"
|
||||
id: battery_level
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Voltage"
|
||||
id: input_voltage
|
||||
type: input_voltage
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Output Voltage"
|
||||
id: output_voltage
|
||||
type: output_voltage
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Load Percentage"
|
||||
id: load_percentage
|
||||
type: load_percent
|
||||
unit_of_measurement: "%"
|
||||
device_class: power_factor
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Runtime Remaining"
|
||||
id: runtime_remaining
|
||||
type: runtime
|
||||
unit_of_measurement: "min"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# Simulation validation script
|
||||
script:
|
||||
- id: simulation_demo
|
||||
then:
|
||||
- logger.log:
|
||||
format: "SIMULATION DATA - Battery: %.1f%%, Load: %.1f%%, Input: %.1fV, Output: %.1fV"
|
||||
args:
|
||||
- "id(battery_level).state"
|
||||
- "id(load_percentage).state"
|
||||
- "id(input_voltage).state"
|
||||
- "id(output_voltage).state"
|
||||
level: INFO
|
||||
|
||||
# Demo data updates every 10 seconds
|
||||
interval:
|
||||
- interval: 10s
|
||||
then:
|
||||
- script.execute: simulation_demo
|
||||
@@ -0,0 +1,70 @@
|
||||
# UPS Control Buttons Package
|
||||
# Beeper control and UPS testing functionality
|
||||
# Use with: packages: !include configs/ups_controls.yaml
|
||||
|
||||
button:
|
||||
# Beeper control buttons
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: enable
|
||||
name: "UPS Beeper Enable"
|
||||
icon: "mdi:volume-high"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: disable
|
||||
name: "UPS Beeper Disable"
|
||||
icon: "mdi:volume-off"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: mute
|
||||
name: "UPS Beeper Mute"
|
||||
icon: "mdi:volume-mute"
|
||||
# Note: Only effective during active alarms
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: test
|
||||
name: "UPS Beeper Test"
|
||||
icon: "mdi:bell-ring"
|
||||
|
||||
# UPS testing buttons
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: battery_quick
|
||||
name: "UPS Quick Battery Test"
|
||||
icon: "mdi:battery-check"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: battery_deep
|
||||
name: "UPS Deep Battery Test"
|
||||
icon: "mdi:battery-plus"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: battery_stop
|
||||
name: "UPS Stop Battery Test"
|
||||
icon: "mdi:battery-remove"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: ups_test
|
||||
name: "UPS Panel Test"
|
||||
icon: "mdi:test-tube"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: ups_stop
|
||||
name: "UPS Stop Panel Test"
|
||||
icon: "mdi:stop"
|
||||
|
||||
# Test result monitoring
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Test Result"
|
||||
id: ups_test_result
|
||||
type: ups_test_result
|
||||
icon: "mdi:test-tube"
|
||||
-847
@@ -1,847 +0,0 @@
|
||||
substitutions:
|
||||
name: ups-hid-monitor-full-test
|
||||
friendly_name: "UPS HID Monitor"
|
||||
timezone: "America/New_York"
|
||||
dns_suffix: !secret wifi_dns_domain
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "Full test configuration for UPS HID Component with ESP32-S3"
|
||||
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
flash_size: 16MB
|
||||
framework:
|
||||
type: esp-idf
|
||||
version: 5.3.2
|
||||
|
||||
# Enable logging with verbose output for debugging
|
||||
logger:
|
||||
level: VERBOSE
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
usb_host: VERBOSE
|
||||
usb-host: VERBOSE
|
||||
USB_HOST: VERBOSE
|
||||
hcd: VERBOSE
|
||||
HCD: VERBOSE
|
||||
hub: VERBOSE
|
||||
HUB: VERBOSE
|
||||
usbh: VERBOSE
|
||||
USBH: VERBOSE
|
||||
baud_rate: 115200
|
||||
hardware_uart: UART0
|
||||
|
||||
# Enable Home Assistant API
|
||||
#api:
|
||||
# encryption:
|
||||
# key: !secret api_encryption_key
|
||||
|
||||
# Enable OTA updates
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: !secret ota_password
|
||||
|
||||
# WiFi configuration
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
domain: "${dns_suffix}"
|
||||
use_address: "${name}${dns_suffix}"
|
||||
ap:
|
||||
ssid: "${friendly_name} Fallback"
|
||||
password: !secret ap_password
|
||||
|
||||
# Captive portal for easy WiFi setup
|
||||
captive_portal:
|
||||
|
||||
# Optional web server for local monitoring
|
||||
web_server:
|
||||
port: 80
|
||||
|
||||
# Time component for accurate timestamps
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
timezone: "${timezone}"
|
||||
|
||||
# RGB LED for UPS status indication (GPIO38 on ESP32-S3-DevKitC-1)
|
||||
light:
|
||||
- platform: esp32_rmt_led_strip
|
||||
chipset: WS2812
|
||||
pin: GPIO48
|
||||
num_leds: 1
|
||||
rgb_order: GRB
|
||||
name: "UPS Status LED"
|
||||
id: ups_status_led
|
||||
restore_mode: ALWAYS_OFF
|
||||
effects:
|
||||
# Critical conditions - Fast red strobe (unmistakable emergency pattern)
|
||||
- strobe:
|
||||
name: "Critical Alert"
|
||||
colors:
|
||||
- state: true
|
||||
brightness: 100%
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
duration: 150ms
|
||||
- state: false
|
||||
duration: 150ms
|
||||
|
||||
# Battery operation - Slow orange fade (amber warning pattern)
|
||||
- pulse:
|
||||
name: "Battery Warning"
|
||||
transition_length: 1.5s
|
||||
update_interval: 1.5s
|
||||
min_brightness: 10%
|
||||
max_brightness: 95%
|
||||
|
||||
# Charging status - Quick yellow double-blink (charging pattern)
|
||||
- strobe:
|
||||
name: "Charging Pattern"
|
||||
colors:
|
||||
- state: true
|
||||
brightness: 80%
|
||||
red: 100%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
duration: 200ms
|
||||
- state: false
|
||||
duration: 200ms
|
||||
- state: true
|
||||
brightness: 80%
|
||||
red: 100%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
duration: 200ms
|
||||
- state: false
|
||||
duration: 1400ms
|
||||
|
||||
# Normal operation - Slow green breathing (peaceful pattern)
|
||||
- pulse:
|
||||
name: "Normal Status"
|
||||
transition_length: 3s
|
||||
update_interval: 3s
|
||||
min_brightness: 20%
|
||||
max_brightness: 60%
|
||||
|
||||
# Fault/offline - Blue fade (distinct from other states)
|
||||
- pulse:
|
||||
name: "System Offline"
|
||||
transition_length: 2s
|
||||
update_interval: 2s
|
||||
min_brightness: 5%
|
||||
max_brightness: 40%
|
||||
|
||||
# External components - using local path for development
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: components
|
||||
|
||||
# Main UPS HID Component Configuration
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 10s
|
||||
|
||||
# Component now auto-detects all USB devices and protocols
|
||||
# Manual USB IDs only needed for troubleshooting when auto-detection fails:
|
||||
#usb_vendor_id: 0x051d # APC vendor ID (uncomment if auto-detection fails)
|
||||
#usb_product_id: 0x0002 # APC Back-UPS ES series
|
||||
#usb_vendor_id: 0x0764 # CyberPower (uncomment if auto-detection fails)
|
||||
#usb_product_id: 0x0501 # CP1500 AVR UPS
|
||||
|
||||
# Protocol Configuration
|
||||
auto_detect_protocol: true
|
||||
protocol_timeout: 15s
|
||||
|
||||
# Development/Testing Configuration
|
||||
simulation_mode: false # Set to false for production with real hardware
|
||||
|
||||
# Numeric Sensors
|
||||
sensor:
|
||||
# Essential UPS metrics
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Level"
|
||||
id: battery_level
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Voltage"
|
||||
id: input_voltage
|
||||
type: input_voltage
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Output Voltage"
|
||||
id: output_voltage
|
||||
type: output_voltage
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Load Percentage"
|
||||
id: load_percentage
|
||||
type: load_percent
|
||||
unit_of_measurement: "%"
|
||||
device_class: power_factor
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Runtime Remaining"
|
||||
id: runtime_remaining
|
||||
type: runtime
|
||||
unit_of_measurement: "min"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Frequency"
|
||||
id: input_frequency
|
||||
type: frequency
|
||||
unit_of_measurement: "Hz"
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
# Note: Input frequency is not available on CyberPower CP1500 model
|
||||
|
||||
# Additional CyberPower sensors (newly implemented)
|
||||
# All sensors based on NUT debug data for CP1500EPFCLCD model
|
||||
# Available sensor types: battery_voltage, battery_voltage_nominal,
|
||||
# input_voltage_nominal, input_transfer_low, input_transfer_high,
|
||||
# ups_realpower_nominal, ups_delay_shutdown, ups_delay_start
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Voltage"
|
||||
id: battery_voltage
|
||||
type: battery_voltage
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Voltage Nominal"
|
||||
id: battery_voltage_nominal
|
||||
type: battery_voltage_nominal
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Voltage Nominal"
|
||||
id: input_voltage_nominal
|
||||
type: input_voltage_nominal
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Transfer Low"
|
||||
id: input_transfer_low
|
||||
type: input_transfer_low
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Transfer High"
|
||||
id: input_transfer_high
|
||||
type: input_transfer_high
|
||||
unit_of_measurement: "V"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Real Power Nominal"
|
||||
id: ups_realpower_nominal
|
||||
type: ups_realpower_nominal
|
||||
unit_of_measurement: "W"
|
||||
device_class: power
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Delay Shutdown"
|
||||
id: ups_delay_shutdown
|
||||
type: ups_delay_shutdown
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Delay Start"
|
||||
id: ups_delay_start
|
||||
type: ups_delay_start
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# New missing dynamic values from NUT analysis
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Charge Low Threshold"
|
||||
id: battery_charge_low
|
||||
type: battery_charge_low
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Charge Warning Threshold"
|
||||
id: battery_charge_warning
|
||||
type: battery_charge_warning
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Runtime Low Threshold"
|
||||
id: battery_runtime_low
|
||||
type: battery_runtime_low
|
||||
unit_of_measurement: "min"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Timer Reboot"
|
||||
id: ups_timer_reboot
|
||||
type: ups_timer_reboot
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Timer Shutdown"
|
||||
id: ups_timer_shutdown
|
||||
type: ups_timer_shutdown
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Timer Start"
|
||||
id: ups_timer_start
|
||||
type: ups_timer_start
|
||||
unit_of_measurement: "s"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# System sensors for monitoring ESP32 health
|
||||
- platform: uptime
|
||||
name: "Uptime"
|
||||
id: uptime_sensor
|
||||
update_interval: 60s
|
||||
|
||||
- platform: wifi_signal
|
||||
name: "WiFi Signal"
|
||||
id: wifi_signal_sensor
|
||||
update_interval: 60s
|
||||
|
||||
# Internal ESP32 temperature sensor
|
||||
- platform: internal_temperature
|
||||
name: "ESP32 Temperature"
|
||||
id: esp32_temp
|
||||
update_interval: 30s
|
||||
|
||||
# Power calculations
|
||||
- platform: template
|
||||
name: "UPS Load Power"
|
||||
id: ups_load_power
|
||||
unit_of_measurement: "W"
|
||||
device_class: power
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
lambda: |-
|
||||
if (!std::isnan(id(load_percentage).state)) {
|
||||
float ups_max_power = 700.0; // Default fallback
|
||||
|
||||
// Try to use HID nominal power data (CyberPower)
|
||||
if (!std::isnan(id(ups_realpower_nominal).state)) {
|
||||
ups_max_power = id(ups_realpower_nominal).state;
|
||||
}
|
||||
// Otherwise, estimate based on detected protocol/manufacturer
|
||||
else {
|
||||
std::string manufacturer = id(ups_manufacturer).state;
|
||||
std::string model = id(ups_model).state;
|
||||
|
||||
// CyberPower models
|
||||
if (manufacturer == "CPS") {
|
||||
if (model.find("CP1500") != std::string::npos) {
|
||||
ups_max_power = 900.0; // CP1500EPFCLCD: 900W
|
||||
} else if (model.find("CP1000") != std::string::npos) {
|
||||
ups_max_power = 600.0; // CP1000 series: ~600W
|
||||
} else if (model.find("CP750") != std::string::npos) {
|
||||
ups_max_power = 450.0; // CP750 series: ~450W
|
||||
}
|
||||
}
|
||||
// APC models
|
||||
else if (manufacturer == "APC") {
|
||||
if (model.find("ES 700") != std::string::npos || model.find("Back-UPS ES") != std::string::npos) {
|
||||
ups_max_power = 405.0; // APC Back-UPS ES 700: 405W
|
||||
} else if (model.find("ES 550") != std::string::npos) {
|
||||
ups_max_power = 330.0; // APC Back-UPS ES 550: 330W
|
||||
} else if (model.find("ES 750") != std::string::npos) {
|
||||
ups_max_power = 450.0; // APC Back-UPS ES 750: 450W
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float current_power = (ups_max_power * id(load_percentage).state) / 100.0;
|
||||
return current_power;
|
||||
}
|
||||
return NAN;
|
||||
update_interval: 30s
|
||||
|
||||
# Binary Sensors for UPS status
|
||||
binary_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Online"
|
||||
id: ups_online
|
||||
type: online
|
||||
device_class: connectivity
|
||||
on_press:
|
||||
then:
|
||||
- script.execute: power_restored
|
||||
on_release:
|
||||
then:
|
||||
- logger.log:
|
||||
format: "POWER OUTAGE: UPS switched to battery power"
|
||||
level: WARN
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "On Battery Power"
|
||||
id: on_battery
|
||||
type: on_battery
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Low Battery Warning"
|
||||
id: low_battery
|
||||
type: low_battery
|
||||
device_class: battery
|
||||
on_press:
|
||||
then:
|
||||
- script.execute: ups_shutdown_warning
|
||||
- script.execute: notify_critical
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Fault"
|
||||
id: ups_fault
|
||||
type: fault
|
||||
device_class: problem
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Charging"
|
||||
id: battery_charging
|
||||
type: charging
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Overload Warning"
|
||||
id: overload_warning
|
||||
type: overload
|
||||
device_class: power
|
||||
|
||||
# Temperature warning
|
||||
- platform: template
|
||||
name: "High Temperature Warning"
|
||||
id: high_temp_warning
|
||||
device_class: heat
|
||||
lambda: |-
|
||||
if (!std::isnan(id(esp32_temp).state)) {
|
||||
return id(esp32_temp).state > 70.0; // Warning at 70°C
|
||||
}
|
||||
return false;
|
||||
|
||||
# Text Sensors for UPS information
|
||||
#
|
||||
# DEVICE INFORMATION CAPABILITIES BY PROTOCOL:
|
||||
#
|
||||
# APC HID Protocol (VID: 0x051D):
|
||||
# ✅ manufacturer, model, status, protocol
|
||||
# ⚠️ serial_number, firmware_version (basic support - may be limited)
|
||||
# ⚠️ ups_beeper_status, input_sensitivity (basic support - may be limited)
|
||||
#
|
||||
# CyberPower HID Protocol (VID: 0x0764):
|
||||
# ✅ manufacturer, model, status, protocol
|
||||
# ✅ serial_number, firmware_version (full HID report parsing)
|
||||
# ✅ ups_beeper_status, input_sensitivity (full HID report parsing)
|
||||
#
|
||||
# Generic HID Protocol (All other vendors):
|
||||
# ✅ manufacturer, model, status, protocol
|
||||
# ⚠️ serial_number, firmware_version (generic parsing - device dependent)
|
||||
# ⚠️ ups_beeper_status, input_sensitivity (generic parsing - device dependent)
|
||||
#
|
||||
# Legend: ✅ = Full Support, ⚠️ = Basic/Limited Support
|
||||
#
|
||||
text_sensor:
|
||||
# === DEVICE IDENTIFICATION (Protocol-Independent) ===
|
||||
# Available on all protocols - basic device identification
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Manufacturer"
|
||||
id: ups_manufacturer
|
||||
type: manufacturer
|
||||
icon: "mdi:factory"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Model"
|
||||
id: ups_model
|
||||
type: model
|
||||
icon: "mdi:information-outline"
|
||||
|
||||
# === PROTOCOL-SPECIFIC DEVICE INFO ===
|
||||
# Serial Number - Available on: CyberPower (full), APC (limited), Generic (basic)
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Serial Number"
|
||||
id: ups_serial_number
|
||||
type: serial_number
|
||||
icon: "mdi:identifier"
|
||||
|
||||
# Firmware Version - Available on: CyberPower (full), APC (limited), Generic (basic)
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Firmware Version"
|
||||
id: ups_firmware_version
|
||||
type: firmware_version
|
||||
icon: "mdi:chip"
|
||||
|
||||
# === COMMUNICATION STATUS ===
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
id: ups_status_text
|
||||
type: status
|
||||
icon: "mdi:power-standby"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Detected Protocol"
|
||||
id: ups_protocol
|
||||
type: protocol
|
||||
icon: "mdi:connection"
|
||||
|
||||
# === HID-SPECIFIC CONFIGURATION ===
|
||||
# UPS Beeper Status - Available on: CyberPower (full), APC (limited), Generic (basic)
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Beeper Status"
|
||||
id: ups_beeper_status
|
||||
type: ups_beeper_status
|
||||
icon: "mdi:volume-high"
|
||||
|
||||
# Input Sensitivity - Available on: CyberPower (full), APC (limited), Generic (basic)
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Sensitivity"
|
||||
id: input_sensitivity
|
||||
type: input_sensitivity
|
||||
icon: "mdi:tune-vertical"
|
||||
|
||||
# New missing text sensors from NUT analysis
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Status"
|
||||
id: battery_status
|
||||
type: battery_status
|
||||
icon: "mdi:battery-check"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Type"
|
||||
id: battery_type
|
||||
type: battery_type
|
||||
icon: "mdi:battery-outline"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Manufacture Date"
|
||||
id: battery_mfr_date
|
||||
type: battery_mfr_date
|
||||
icon: "mdi:calendar-check"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Manufacture Date"
|
||||
id: ups_mfr_date
|
||||
type: ups_mfr_date
|
||||
icon: "mdi:calendar-check"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Firmware Auxiliary"
|
||||
id: ups_firmware_aux
|
||||
type: ups_firmware_aux
|
||||
icon: "mdi:chip"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Test Result"
|
||||
id: ups_test_result
|
||||
type: ups_test_result
|
||||
icon: "mdi:test-tube"
|
||||
|
||||
# System text sensors
|
||||
- platform: version
|
||||
name: "ESPHome Version"
|
||||
id: esphome_version
|
||||
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
name: "IP Address"
|
||||
id: ip_address
|
||||
ssid:
|
||||
name: "Connected SSID"
|
||||
id: connected_ssid
|
||||
|
||||
# Last event timestamp
|
||||
- platform: template
|
||||
name: "Last UPS Event"
|
||||
id: last_ups_event
|
||||
lambda: |-
|
||||
static std::string last_event = "System Started";
|
||||
static bool last_online = true;
|
||||
static bool last_low_battery = false;
|
||||
|
||||
if (id(ups_online).state != last_online) {
|
||||
if (id(ups_online).state) {
|
||||
last_event = "UPS Online";
|
||||
} else {
|
||||
last_event = "UPS Offline";
|
||||
}
|
||||
last_online = id(ups_online).state;
|
||||
}
|
||||
|
||||
if (id(low_battery).state != last_low_battery) {
|
||||
if (id(low_battery).state) {
|
||||
last_event = "Low Battery Alert";
|
||||
} else {
|
||||
last_event = "Battery Level Normal";
|
||||
}
|
||||
last_low_battery = id(low_battery).state;
|
||||
}
|
||||
|
||||
return last_event;
|
||||
|
||||
# Advanced LED Status Control with Priorities
|
||||
interval:
|
||||
- interval: 2s
|
||||
then:
|
||||
- lambda: |-
|
||||
// Enhanced UPS status LED control with distinct visual patterns
|
||||
// Each state now has a unique color and pattern combination
|
||||
|
||||
// CRITICAL CONDITIONS (Priority 1) - Fast red strobe
|
||||
if (id(low_battery).state || id(ups_fault).state || id(overload_warning).state) {
|
||||
auto call = id(ups_status_led).turn_on();
|
||||
call.set_rgb(1.0, 0.0, 0.0); // Bright red
|
||||
call.set_effect("Critical Alert");
|
||||
call.perform();
|
||||
}
|
||||
// BATTERY OPERATION (Priority 2) - Orange slow fade
|
||||
else if (id(on_battery).state && !id(low_battery).state) {
|
||||
auto call = id(ups_status_led).turn_on();
|
||||
call.set_rgb(1.0, 0.5, 0.0); // Orange amber
|
||||
call.set_effect("Battery Warning");
|
||||
call.perform();
|
||||
}
|
||||
// CHARGING STATUS (Priority 3) - Yellow double-blink pattern
|
||||
else if (id(battery_charging).state && id(ups_online).state) {
|
||||
auto call = id(ups_status_led).turn_on();
|
||||
call.set_rgb(1.0, 1.0, 0.0); // Yellow
|
||||
call.set_effect("Charging Pattern");
|
||||
call.perform();
|
||||
}
|
||||
// NORMAL OPERATION (Priority 4) - Gentle green breathing
|
||||
else if (id(ups_online).state && !id(on_battery).state) {
|
||||
auto call = id(ups_status_led).turn_on();
|
||||
call.set_rgb(0.0, 1.0, 0.0); // Green
|
||||
call.set_effect("Normal Status");
|
||||
call.perform();
|
||||
}
|
||||
// OFFLINE/UNKNOWN (Priority 5) - Dim blue fade
|
||||
else {
|
||||
auto call = id(ups_status_led).turn_on();
|
||||
call.set_rgb(0.0, 0.3, 1.0); // Blue
|
||||
call.set_effect("System Offline");
|
||||
call.perform();
|
||||
}
|
||||
|
||||
# Automated scripts for notifications and actions
|
||||
script:
|
||||
- id: notify_critical
|
||||
then:
|
||||
- logger.log:
|
||||
format: "CRITICAL UPS EVENT: Battery=%.1f%%, Runtime=%.1f min, Status=%s"
|
||||
args:
|
||||
[
|
||||
"id(battery_level).state",
|
||||
"id(runtime_remaining).state",
|
||||
"id(ups_status_text).state.c_str()",
|
||||
]
|
||||
level: ERROR
|
||||
|
||||
- id: ups_shutdown_warning
|
||||
then:
|
||||
- logger.log:
|
||||
format: "UPS SHUTDOWN WARNING: Battery critically low, runtime remaining: %.1f minutes"
|
||||
args: ["id(runtime_remaining).state"]
|
||||
level: WARN
|
||||
# Add your shutdown logic here if needed
|
||||
|
||||
- id: power_restored
|
||||
then:
|
||||
- logger.log:
|
||||
format: "POWER RESTORED: UPS back online, battery at %.1f%%"
|
||||
args: ["id(battery_level).state"]
|
||||
level: INFO
|
||||
|
||||
# Home Assistant Dashboard Integration Helper
|
||||
# Uncomment and customize for your Home Assistant setup
|
||||
# homeassistant:
|
||||
# service: notify.mobile_app_your_phone
|
||||
# data:
|
||||
# title: "UPS Alert"
|
||||
# message: "UPS is running on battery power!"
|
||||
# condition:
|
||||
# - binary_sensor.is_on: on_battery
|
||||
# - binary_sensor.is_off: low_battery
|
||||
|
||||
# Example automation for critical battery
|
||||
# on_...:
|
||||
# - platform: state
|
||||
# entity_id: binary_sensor.low_battery
|
||||
# to: "on"
|
||||
# then:
|
||||
# - script.execute: notify_critical
|
||||
|
||||
# Development/Debug helpers
|
||||
debug:
|
||||
update_interval: 30s
|
||||
|
||||
# UPS Beeper Control Buttons
|
||||
# Based on confirmed working implementation for APC and CyberPower devices
|
||||
button:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: enable
|
||||
name: "UPS Beeper Enable"
|
||||
icon: "mdi:volume-high"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: disable
|
||||
name: "UPS Beeper Disable"
|
||||
icon: "mdi:volume-off"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: mute
|
||||
name: "UPS Beeper Mute"
|
||||
icon: "mdi:volume-mute"
|
||||
# Note: Mute only works when UPS is actively beeping (during alarms)
|
||||
# Use during power outages to acknowledge and silence current alarms
|
||||
# Confirmed working: Mute button silences beeper during power loss events
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
beeper_action: test
|
||||
name: "UPS Beeper Test"
|
||||
icon: "mdi:bell-ring"
|
||||
# Note: Tests enable/disable functionality - no audible sound unless UPS has alarm condition
|
||||
# To hear actual beeper: unplug UPS briefly while beeper is enabled
|
||||
|
||||
# UPS Testing Buttons - NEW FEATURE
|
||||
# Based on NUT test command implementation for APC and CyberPower protocols
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: battery_quick
|
||||
name: "UPS Quick Battery Test"
|
||||
icon: "mdi:battery-check"
|
||||
# Performs a short battery test (typically 10 seconds)
|
||||
# Tests battery condition and capacity
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: battery_deep
|
||||
name: "UPS Deep Battery Test"
|
||||
icon: "mdi:battery-plus"
|
||||
# Performs comprehensive battery test (may run several minutes)
|
||||
# Full battery capacity and health check
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: battery_stop
|
||||
name: "UPS Stop Battery Test"
|
||||
icon: "mdi:battery-remove"
|
||||
# Aborts any running battery test
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: ups_test
|
||||
name: "UPS Panel Test"
|
||||
icon: "mdi:test-tube"
|
||||
# Tests UPS panel indicators and systems
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
test_action: ups_stop
|
||||
name: "UPS Stop Panel Test"
|
||||
icon: "mdi:stop"
|
||||
# Stops UPS panel test
|
||||
|
||||
# Enable safe mode for recovery
|
||||
safe_mode:
|
||||
disabled: false
|
||||
# Note: Additional automations can be added in Home Assistant
|
||||
@@ -1,201 +0,0 @@
|
||||
esphome:
|
||||
name: ups-hid-monitor-minimal-test
|
||||
friendly_name: "UPS HID Monitor"
|
||||
comment: "Full test configuration for UPS HID Component with ESP32-S3"
|
||||
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
variant: esp32s3
|
||||
framework:
|
||||
type: esp-idf
|
||||
version: 5.3.2
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
level: DEBUG
|
||||
baud_rate: 115200
|
||||
hardware_uart: UART0
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
ups_hid.apc: DEBUG
|
||||
ups_hid.apc_hid: DEBUG
|
||||
ups_hid.generic: DEBUG
|
||||
usb_host: DEBUG
|
||||
esp32.usb_host: DEBUG
|
||||
usb: DEBUG
|
||||
usb-otg: DEBUG
|
||||
HCD: DEBUG
|
||||
USBH: DEBUG
|
||||
|
||||
# Enable Home Assistant API
|
||||
#api:
|
||||
# encryption:
|
||||
# key: !secret api_encryption_key
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: !secret ota_password
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
ap:
|
||||
ssid: "UPS-HID-Monitor"
|
||||
password: !secret ap_password
|
||||
|
||||
captive_portal:
|
||||
web_server:
|
||||
|
||||
# RGB LED for status indication
|
||||
light:
|
||||
- platform: esp32_rmt_led_strip
|
||||
chipset: WS2812
|
||||
pin: GPIO48
|
||||
num_leds: 1
|
||||
rgb_order: GRB
|
||||
name: "UPS Status LED"
|
||||
id: status_led
|
||||
effects:
|
||||
- strobe:
|
||||
name: "Critical Strobe"
|
||||
colors:
|
||||
- state: true
|
||||
brightness: 100%
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
duration: 250ms
|
||||
- state: false
|
||||
duration: 250ms
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: components
|
||||
|
||||
# UPS HID Component
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
simulation_mode: false # Test with real hardware
|
||||
update_interval: 5s
|
||||
|
||||
# Component now auto-detects all USB devices and protocols
|
||||
# Manual USB IDs only needed for troubleshooting:
|
||||
# usb_vendor_id: 0x051d # APC vendor ID (uncomment if auto-detection fails)
|
||||
# usb_product_id: 0x0002 # APC Back-UPS ES series
|
||||
# usb_vendor_id: 0x0764 # CyberPower (uncomment if auto-detection fails)
|
||||
# usb_product_id: 0x0501 # CP1500 AVR UPS
|
||||
|
||||
protocol_timeout: 10s
|
||||
auto_detect_protocol: true
|
||||
|
||||
# Sensors
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Battery Level"
|
||||
id: ups_battery_level
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Runtime"
|
||||
id: ups_runtime
|
||||
type: runtime
|
||||
unit_of_measurement: "min"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# Test key missing dynamic values
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Charge Low Threshold"
|
||||
id: battery_charge_low
|
||||
type: battery_charge_low
|
||||
unit_of_measurement: "%"
|
||||
device_class: battery
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Runtime Low Threshold"
|
||||
id: battery_runtime_low
|
||||
type: battery_runtime_low
|
||||
unit_of_measurement: "min"
|
||||
device_class: duration
|
||||
state_class: measurement
|
||||
accuracy_decimals: 0
|
||||
|
||||
# Binary Sensors
|
||||
binary_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS On Battery"
|
||||
id: ups_on_battery
|
||||
type: on_battery
|
||||
device_class: battery
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Fault"
|
||||
id: ups_fault
|
||||
type: fault
|
||||
device_class: problem
|
||||
|
||||
# Text Sensors
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
id: ups_status
|
||||
type: status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Model"
|
||||
id: ups_model
|
||||
type: model
|
||||
|
||||
# Device Information Sensors (test APC implementation)
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Serial Number"
|
||||
id: ups_serial_number
|
||||
type: serial_number
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Firmware Version"
|
||||
id: ups_firmware_version
|
||||
type: firmware_version
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Beeper Status"
|
||||
id: ups_beeper_status
|
||||
type: ups_beeper_status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Input Sensitivity"
|
||||
id: ups_input_sensitivity
|
||||
type: input_sensitivity
|
||||
|
||||
# Test key missing dynamic values
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Type"
|
||||
id: battery_type
|
||||
type: battery_type
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Test Result"
|
||||
id: ups_test_result
|
||||
type: ups_test_result
|
||||
@@ -1,67 +0,0 @@
|
||||
substitutions:
|
||||
name: vendor-validation-test
|
||||
friendly_name: "UPS Vendor Validation Test"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "Test configuration to validate unknown vendor ID handling"
|
||||
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
flash_size: 16MB
|
||||
framework:
|
||||
type: esp-idf
|
||||
version: 5.3.2
|
||||
|
||||
logger:
|
||||
level: VERBOSE
|
||||
logs:
|
||||
ups_hid: DEBUG
|
||||
|
||||
api:
|
||||
encryption:
|
||||
key: !secret api_encryption_key
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: !secret ota_password
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: components
|
||||
|
||||
# Test with unknown vendor ID for troubleshooting mode validation
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 30s
|
||||
# Using manual USB IDs in troubleshooting mode (component will try auto-detection first)
|
||||
usb_vendor_id: 0x9999 # Unknown vendor ID - should trigger warning but still work
|
||||
usb_product_id: 0x0001
|
||||
auto_detect_protocol: true
|
||||
protocol_timeout: 15s
|
||||
simulation_mode: true
|
||||
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Level"
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
|
||||
binary_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Online"
|
||||
type: online
|
||||
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
type: status
|
||||
Reference in new issue
Block a user