From 369578a63a02c9f66e21d749360f6df0843cbbd3 Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Sun, 27 Sep 2026 20:36:59 +0200 Subject: [PATCH] mcu-nspanel-office-j: dim the display at night like the bedroom panel Inactive display dim follows the sun (5 % by day, off after dusk at -6 degrees) and stays at 5 % while light.office_j_lights is on. Re-applied on time sync, at dawn/dusk and when the lights change. --- mcu-nspanel-office-j.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/mcu-nspanel-office-j.yaml b/mcu-nspanel-office-j.yaml index 3e76d17..9dbfbda 100644 --- a/mcu-nspanel-office-j.yaml +++ b/mcu-nspanel-office-j.yaml @@ -38,6 +38,16 @@ external_components: packages: common: !include common/common.yaml +script: + - id: apply_sleep_dim + then: + - lambda: |- + uint8_t dim; + if (id(bedroom_lights).state) dim = 5; // sleepOverride + else if (id(sun_id).is_above_horizon(-6)) dim = 5; // day + else dim = 0; // night + id(nspanel_id).set_display_inactive_dim(dim); + api: homeassistant_services: true homeassistant_states: true @@ -134,6 +144,11 @@ nspanel_lovelace: - name: Auto-zatváranie entity_id: switch.gate_auto_close +time: + - id: !extend ha_time + on_time_sync: + - script.execute: apply_sleep_dim + binary_sensor: - platform: gpio name: Left Button @@ -156,6 +171,12 @@ binary_sensor: entity_id: light.bedside_left - lambda: 'id(nspanel_id).render_default_page();' + - platform: homeassistant # sleepOverride + id: bedroom_lights + entity_id: light.office_j_lights + on_state: + - script.execute: apply_sleep_dim + output: - platform: ledc id: buzzer_out @@ -181,6 +202,20 @@ light: # # name: Relay 2 # # output: relay_2 +sun: + id: sun_id + time_id: ha_time + latitude: 48.15° + longitude: 17.11° + on_sunrise: + - elevation: -6° + then: + - script.execute: apply_sleep_dim + on_sunset: + - elevation: -6° + then: + - script.execute: apply_sleep_dim + switch: - platform: gpio name: Screen Power