mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-10-14 08:35:12 +02:00
status_led: show component errors only on a dedicated status LED (show_errors)
The ATOM LED gets them; displays and lights that are also normal lights don't, so a failed component can't take them over.
This commit is contained in:
1 parent
fb66547dd1
commit
03ca4e98b5
2 files changed
+7
-1
No files matched your search
@@ -2,6 +2,7 @@
|
||||
# Status on a visible RGB light, which stays a normal light otherwise:
|
||||
# network down red, slow blink
|
||||
# no API client (HA) orange, slow blink
|
||||
# component error purple, steady (only with show_errors: "true", for a dedicated status LED)
|
||||
# OTA blue, fast blink; green when done, 3 red blinks on error
|
||||
# back to normal green for 1 s, then the light goes back to how it was
|
||||
# packages:
|
||||
@@ -12,6 +13,7 @@
|
||||
# Needs the ota id ota_esphome (common/ota_esp32.yaml).
|
||||
defaults:
|
||||
brightness: "0.3"
|
||||
show_errors: "false" # a failed component would take over a display or a shared light for good
|
||||
|
||||
globals:
|
||||
- id: status_led_active
|
||||
@@ -71,12 +73,15 @@ interval:
|
||||
static uint8_t tick = 0;
|
||||
tick++;
|
||||
bool slow = (tick / 2) % 2 == 0; // 1 s on, 1 s off
|
||||
bool problem = !network::is_connected() || !api::global_api_server->is_connected();
|
||||
bool error = ${show_errors} && (App.get_app_state() & STATUS_LED_ERROR);
|
||||
bool problem = !network::is_connected() || !api::global_api_server->is_connected() || error;
|
||||
if (problem) id(status_led_restore)->stop();
|
||||
if (!network::is_connected()) {
|
||||
id(status_led_show)->execute(1.0f, 0.0f, 0.0f, slow);
|
||||
} else if (!api::global_api_server->is_connected()) {
|
||||
id(status_led_show)->execute(1.0f, 0.4f, 0.0f, slow);
|
||||
} else if (error) {
|
||||
id(status_led_show)->execute(0.6f, 0.0f, 1.0f, true);
|
||||
} else if (id(status_led_active) && !id(status_led_restore)->is_running()) {
|
||||
id(status_led_restore)->execute(true);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user