mcu-nspanel-office-j: dim the display at night like the bedroom panel
CI / ESPHome config validation (push) Failing after 8s
CI / YAML lint (push) Failing after 38s

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.
This commit is contained in:
randy committed 2026-09-27 20:36:59 +02:00
1 parent bdf49db1c2
commit 369578a63a
1 file changed
+35
+35
View File
@@ -38,6 +38,16 @@ external_components:
packages: packages:
common: !include common/common.yaml 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: api:
homeassistant_services: true homeassistant_services: true
homeassistant_states: true homeassistant_states: true
@@ -134,6 +144,11 @@ nspanel_lovelace:
- name: Auto-zatváranie - name: Auto-zatváranie
entity_id: switch.gate_auto_close entity_id: switch.gate_auto_close
time:
- id: !extend ha_time
on_time_sync:
- script.execute: apply_sleep_dim
binary_sensor: binary_sensor:
- platform: gpio - platform: gpio
name: Left Button name: Left Button
@@ -156,6 +171,12 @@ binary_sensor:
entity_id: light.bedside_left entity_id: light.bedside_left
- lambda: 'id(nspanel_id).render_default_page();' - 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: output:
- platform: ledc - platform: ledc
id: buzzer_out id: buzzer_out
@@ -181,6 +202,20 @@ light:
# # name: Relay 2 # # name: Relay 2
# # output: 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: switch:
- platform: gpio - platform: gpio
name: Screen Power name: Screen Power