From 8b64c0a986eac204b857f54e33c71ef6fa630285 Mon Sep 17 00:00:00 2001 From: Daniele Verducci Date: Thu, 9 Apr 2026 10:42:28 +0200 Subject: [PATCH] Battery low management --- hexagon.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/hexagon.yaml b/hexagon.yaml index 191842f..5f61dcf 100644 --- a/hexagon.yaml +++ b/hexagon.yaml @@ -34,8 +34,11 @@ esp8266: board: d1_mini_lite # Enable logging (for development) +# NOTE: Logs on the same pin of addressable leds, so may display wrong colors when enabled # logger: +deep_sleep: + api: reboot_timeout: 0s @@ -109,6 +112,11 @@ sensor: - 850.0 -> 100.0 - min: send_first_at: 3 + on_value_range: + - below: 5.0 + then: + - script.execute: battery_low + output: - platform: esp8266_pwm @@ -245,3 +253,23 @@ script: default: return "mario:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,8p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16c7,16p,16c7,16c7,p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16d#6,8p,16d6,8p,16c6"; } + - id: battery_low + then: + - logger.log: "Executing Battery Low script" + # Turn lughts on red + - light.turn_on: + id: hexagon_sections + brightness: 100% + red: 100% + green: 0% + blue: 0% + - delay: 1s + # Play battery low tune + - rtttl.play: + rtttl: Battery Low:d=8,o=6,b=600:c6,p,c5,p,2c4 + - delay: 5s + - light.turn_off: hexagon_sections + - delay: 1s + # Suspend device to avoid draining battery + - deep_sleep.enter: +