diff --git a/the-saloon.yaml b/the-saloon.yaml index 97ecf2d..3ea28e1 100644 --- a/the-saloon.yaml +++ b/the-saloon.yaml @@ -42,6 +42,7 @@ output: light: - platform: monochromatic + id: backlight output: backlight_output name: "LCD Backlight" restore_mode: ALWAYS_ON @@ -82,6 +83,33 @@ display: it.printf(10, 105, id(roboto), "%.0f%%", pct); } +script: + - id: update_brightness + then: + - lambda: |- + auto now = id(ha_time).now(); + if (!now.is_valid()) return; // time not synced yet + bool night = (now.hour >= 17 || now.hour < 6); + auto call = id(backlight).turn_on(); + call.set_brightness(night ? 0.05 : 1.0); // 5% at night, 100% by day + call.set_transition_length(0); + call.perform(); +time: + - platform: homeassistant + id: ha_time + on_time_sync: + - script.execute: update_brightness # applies the right level after boot + on_time: + - hours: 17 + minutes: 0 + seconds: 0 + then: + - script.execute: update_brightness + - hours: 6 + minutes: 0 + seconds: 0 + then: + - script.execute: update_brightness font: - file: "gfonts://Roboto" id: roboto @@ -89,7 +117,9 @@ font: - file: "gfonts://Roboto" id: roboto_big size: 48 - + - file: "gfonts://Roboto" + id: roboto_small + size: 16 # Data from Glances (same as before) http_request: timeout: 5s