Motion-lys: input_number parametre for gang/daniel/kontor, fix badevaerelse timeout, kompakt lys view

This commit is contained in:
2026-04-25 19:17:56 +02:00
parent 56f21f79e1
commit 9cb7550f78
7 changed files with 208 additions and 263 deletions
+62 -165
View File
@@ -1,171 +1,68 @@
- alias: 'Lys i gang - arbejdsdag - dag'
trigger:
platform: state
entity_id: binary_sensor.gang_sensor_motion
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: 'on'
- condition: numeric_state
entity_id: sensor.gang_sensor_illuminance
below: '70'
- condition: time
before: '21:30:00'
- condition: time
after: '06:30:00'
action:
- service: scene.turn_on
data:
entity_id: scene.gang_bright
# brightness: 255
# color_temp: 396
- alias: 'Sluk Lys i gang - arbejdsdag - dag'
trigger:
platform: state
entity_id: binary_sensor.gang_sensor_motion
to: 'off'
for:
minutes: 3
condition:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: 'on'
- condition: time
after: '06:30:10'
- condition: time
before: '21:30:00'
action:
service: light.turn_off
data:
entity_id: light.gang
- id: gang_motion_lys
alias: Gang lys via bevægelse
mode: restart
- alias: 'Lys i gang - ikke arbejdsdag - dag'
trigger:
platform: state
trigger:
- platform: state
entity_id: binary_sensor.gang_sensor_motion
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: 'off'
- condition: numeric_state
entity_id: sensor.gang_sensor_illuminance
below: 70
- condition: time
after: '08:00:00'
- condition: time
before: '22:00:00'
action:
- service: scene.turn_on
data:
entity_id: scene.gang_bright
# brightness: 255
# color_temp: 396
- alias: 'Sluk Lys i gang - ikke arbejdsdag - dag'
trigger:
platform: state
entity_id: binary_sensor.gang_sensor_motion
to: 'off'
for:
minutes: 3
condition:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: 'off'
- condition: time
after: '08:00:10'
- condition: time
before: '22:00:00'
action:
service: light.turn_off
target:
entity_id: light.gang
to: "on"
id: motion_on
########## NIGHT
- platform: state
entity_id: binary_sensor.gang_sensor_motion
to: "off"
id: motion_off
- alias: 'Lys i gang - arbejdsdag - nat'
trigger:
platform: state
entity_id: binary_sensor.gang_sensor_motion
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: 'on'
- condition: numeric_state
entity_id: sensor.gang_sensor_illuminance
below: '70'
- condition: time
before: '06:30:00'
after: '21:30:00'
action:
- service: scene.turn_on
data:
entity_id: scene.gang_daempet_nat
# brightness_pct: 1
# color_temp: 396
- alias: 'Sluk Lys i gang - arbejdsdag - nat'
trigger:
platform: state
entity_id: binary_sensor.gang_sensor_motion
to: 'off'
for:
minutes: 1
condition:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: 'on'
- condition: time
after: '21:30:10'
before: '06:30:00'
action:
service: light.turn_off
target:
entity_id: light.gang
variables:
lux_limit: "{{ states('input_number.gang_lux_threshold') | int }}"
is_dag: >
{% set t = now().strftime('%H%M') | int %}
{% if is_state('binary_sensor.arbejdsdag', 'on') %}
{{ 630 <= t < 2130 }}
{% else %}
{{ 800 <= t < 2200 }}
{% endif %}
- alias: 'Lys i gang - ikke arbejdsdag - nat'
trigger:
platform: state
entity_id: binary_sensor.gang_sensor_motion
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: 'off'
# - condition: numeric_state
# entity_id: sensor.gang_sensor_light_level
# below: '70'
- condition: time
after: '22:00:00'
before: '08:00:00'
action:
- service: scene.turn_on
data:
entity_id: scene.gang_daempet_nat
# brightness_pct: 1
# color_temp: 396
- alias: 'Sluk Lys i gang - ikke arbejdsdag - nat'
trigger:
platform: state
entity_id: binary_sensor.gang_sensor_motion
to: 'off'
for:
minutes: 1
condition:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: 'off'
- condition: time
after: '22:00:10'
before: '08:00:00'
action:
- service: light.turn_off
target:
entity_id: light.gang
action:
- choose:
# Motion on - dag: taend bright scene hvis lux er lavt nok
- conditions:
- condition: trigger
id: motion_on
- condition: template
value_template: "{{ is_dag }}"
- condition: template
value_template: >
{{ states('sensor.gang_sensor_illuminance') | int < lux_limit }}
sequence:
- service: scene.turn_on
target:
entity_id: scene.gang_bright
# Motion on - nat: taend daempet scene (ingen lux-check)
- conditions:
- condition: trigger
id: motion_on
- condition: template
value_template: "{{ not is_dag }}"
sequence:
- service: scene.turn_on
target:
entity_id: scene.gang_daempet_nat
# Motion off: vent timeout, sluk hvis stadig ingen bevaegelse
- conditions:
- condition: trigger
id: motion_off
sequence:
- delay:
minutes: >
{{ states('input_number.gang_timeout_day') | int if is_dag
else states('input_number.gang_timeout_night') | int }}
- condition: state
entity_id: binary_sensor.gang_sensor_motion
state: "off"
- service: light.turn_off
target:
entity_id: light.gang