Public Access
feat(ups-status-led): ups led controller component
Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
17 files changed
+1413
-243
No files matched your search
@@ -0,0 +1,112 @@
|
||||
# LED Status Component Testing Configuration
|
||||
# Tests the ups_status_led component with all features enabled
|
||||
# Uses simulation mode for testing without physical UPS hardware
|
||||
|
||||
substitutions:
|
||||
name: "led-status-test"
|
||||
friendly_name: "LED Status Test"
|
||||
|
||||
# Enable simulation for testing
|
||||
simulation_mode: "true"
|
||||
update_interval: "5s" # Fast updates for testing
|
||||
|
||||
# LED testing configuration
|
||||
led_pin: "GPIO48"
|
||||
led_brightness: "75%"
|
||||
led_color_mode: "gradient" # Test gradient mode
|
||||
|
||||
# Night mode testing
|
||||
led_night_mode_enabled: "true"
|
||||
led_night_brightness: "20%"
|
||||
led_night_start: "20:00" # Early for testing
|
||||
led_night_end: "08:00"
|
||||
|
||||
# Timezone for night mode testing
|
||||
timezone: "UTC" # Use UTC for consistent testing
|
||||
|
||||
esphome:
|
||||
name: ${name}
|
||||
friendly_name: ${friendly_name}
|
||||
|
||||
# Use minimal base UPS configuration (without all packages)
|
||||
packages:
|
||||
base_ups: !include ../base_ups.yaml
|
||||
|
||||
# Add time component for LED night mode (required by ups_status_led)
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
timezone: ${timezone}
|
||||
servers:
|
||||
- pool.ntp.org
|
||||
- time.nist.gov
|
||||
|
||||
# Add LED package manually for testing
|
||||
light:
|
||||
- platform: esp32_rmt_led_strip
|
||||
chipset: WS2812
|
||||
pin: ${led_pin}
|
||||
num_leds: 1
|
||||
rgb_order: GRB
|
||||
name: "UPS Status LED Hardware"
|
||||
id: ups_status_led_hw
|
||||
internal: true
|
||||
restore_mode: ALWAYS_OFF
|
||||
|
||||
# UPS Status LED Component
|
||||
ups_status_led:
|
||||
id: ups_led_controller
|
||||
ups_hid_id: ups_monitor
|
||||
light_id: ups_status_led_hw
|
||||
time_id: sntp_time
|
||||
|
||||
enabled: true
|
||||
brightness: ${led_brightness}
|
||||
battery_color_mode: ${led_color_mode}
|
||||
battery_low_threshold: 20
|
||||
battery_warning_threshold: 50
|
||||
|
||||
night_mode:
|
||||
enabled: ${led_night_mode_enabled}
|
||||
brightness: ${led_night_brightness}
|
||||
start_time: ${led_night_start}
|
||||
end_time: ${led_night_end}
|
||||
|
||||
# Enable required platforms for UPS HID component
|
||||
sensor:
|
||||
binary_sensor:
|
||||
button:
|
||||
|
||||
# Testing features:
|
||||
#
|
||||
# LED Pattern Testing (automatic, priority-based, solid colors):
|
||||
# LED Patterns:
|
||||
# 🔴 Critical Alert (solid red) - Low battery/fault/overload
|
||||
# 🟠 Battery Power (solid orange) - Running on battery
|
||||
# 🟡 Charging (solid yellow) - Battery charging
|
||||
# 🟢 Normal (solid green) - Normal operation
|
||||
# 🔵 UPS Offline (solid blue) - UPS disconnected
|
||||
# 🟣 No Data (solid purple) - Component connected but no data
|
||||
# ⚪ Error (solid white) - Component error
|
||||
#
|
||||
# Home Assistant Entities (auto-created):
|
||||
# - switch.led_status_test_enabled_switch (master LED control)
|
||||
# - switch.led_status_test_night_switch (night mode toggle)
|
||||
# - number.led_status_test_brightness_number (brightness slider)
|
||||
# - text_sensor.led_status_test_status_sensor (current pattern)
|
||||
#
|
||||
# Testing Capabilities:
|
||||
# ✅ All 7 LED patterns with simulated UPS states
|
||||
# ✅ Battery-aware gradient color calculation
|
||||
# ✅ Night mode with time-based scheduling
|
||||
# ✅ Home Assistant integration and control
|
||||
# ✅ Data provider pattern usage (no sensors required)
|
||||
# ✅ Performance optimization verification (10Hz updates, solid colors)
|
||||
# ✅ Hardware abstraction (WS2812 LED strip)
|
||||
#
|
||||
# Usage:
|
||||
# 1. Compile: esphome config configs/testing/led_status_test.yaml
|
||||
# 2. Flash to ESP32-S3 with connected WS2812 LED
|
||||
# 3. Monitor patterns change based on simulated UPS states
|
||||
# 4. Test Home Assistant controls through web interface
|
||||
# 5. Verify night mode activation/deactivation
|
||||
@@ -14,7 +14,7 @@ esphome:
|
||||
|
||||
# Use base UPS configuration (now has optional sensors)
|
||||
packages:
|
||||
base_ups: !include base_ups.yaml
|
||||
base_ups: !include ../base_ups.yaml
|
||||
|
||||
# ZERO sensor entities defined - testing pure data provider mode!
|
||||
|
||||
@@ -59,27 +59,27 @@ interval:
|
||||
switch(test_phase) {
|
||||
case 0: // Test critical state display
|
||||
if (id(ups_monitor).is_low_battery() || id(ups_monitor).has_fault()) {
|
||||
ESP_LOGI("led_test", "Critical state detected - RED strobe should be active");
|
||||
ESP_LOGI("led_test", "Critical state detected - RED solid should be active");
|
||||
}
|
||||
break;
|
||||
case 1: // Test battery operation
|
||||
if (id(ups_monitor).is_on_battery()) {
|
||||
ESP_LOGI("led_test", "Battery operation - ORANGE fade should be active");
|
||||
ESP_LOGI("led_test", "Battery operation - ORANGE solid should be active");
|
||||
}
|
||||
break;
|
||||
case 2: // Test charging state
|
||||
if (id(ups_monitor).is_charging()) {
|
||||
ESP_LOGI("led_test", "Charging state - YELLOW pattern should be active");
|
||||
ESP_LOGI("led_test", "Charging state - YELLOW solid should be active");
|
||||
}
|
||||
break;
|
||||
case 3: // Test normal operation
|
||||
if (id(ups_monitor).is_online()) {
|
||||
ESP_LOGI("led_test", "Normal operation - GREEN breathing should be active");
|
||||
ESP_LOGI("led_test", "Normal operation - GREEN solid should be active");
|
||||
}
|
||||
break;
|
||||
case 4: // Test offline state
|
||||
if (!id(ups_monitor).is_online()) {
|
||||
ESP_LOGI("led_test", "Offline state - BLUE fade should be active");
|
||||
ESP_LOGI("led_test", "Offline state - BLUE solid should be active");
|
||||
}
|
||||
break;
|
||||
case 5: // Data provider mode validation
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
# North American Regional Template Test Configuration
|
||||
# Tests North American regional defaults (120V/60Hz)
|
||||
# Use: esphome compile configs/testing/north_american_template_test.yaml
|
||||
|
||||
substitutions:
|
||||
name: "north-american-test"
|
||||
friendly_name: "North American Test"
|
||||
simulation_mode: "true" # Safe testing without hardware
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "Testing North American regional template (120V/60Hz)"
|
||||
|
||||
# Core ESP32 configuration
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
# Minimal logging
|
||||
logger:
|
||||
level: INFO
|
||||
baud_rate: 115200
|
||||
|
||||
# Basic network
|
||||
wifi:
|
||||
ssid: "TestNetwork"
|
||||
password: "TestPassword"
|
||||
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../../components
|
||||
|
||||
# Use North American regional template
|
||||
packages:
|
||||
regional_defaults: !include ../regional/north_american_defaults.yaml
|
||||
|
||||
# UPS component (inherits North American defaults from regional template)
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 30s
|
||||
simulation_mode: ${simulation_mode}
|
||||
# fallback_nominal_voltage comes from regional template (120V North American)
|
||||
|
||||
# Platform stubs
|
||||
binary_sensor:
|
||||
button:
|
||||
|
||||
# Test sensors to validate North American regional defaults
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Level"
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Voltage (North American 120V)"
|
||||
type: input_voltage
|
||||
unit_of_measurement: "V"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Frequency (North American 60Hz)"
|
||||
type: frequency
|
||||
unit_of_measurement: "Hz"
|
||||
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
type: status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Protocol Name"
|
||||
type: protocol
|
||||
Reference in new issue
Block a user