From 61aca67c4596549ea44a01ef2b31bd1bbf26dfbe Mon Sep 17 00:00:00 2001 From: Claus Dethlefsen Date: Sun, 5 Apr 2026 17:59:27 +0200 Subject: [PATCH] Refine kontor lighting automation --- include/automations/lys_kontor.yaml | 67 +++++++++++++++++++++++------ include/input/number/kontor.yaml | 16 ------- 2 files changed, 54 insertions(+), 29 deletions(-) delete mode 100644 include/input/number/kontor.yaml diff --git a/include/automations/lys_kontor.yaml b/include/automations/lys_kontor.yaml index 9e7bd66..960897e 100644 --- a/include/automations/lys_kontor.yaml +++ b/include/automations/lys_kontor.yaml @@ -1,4 +1,5 @@ -- alias: Kontor lys motion +- id: kontor_motion_lys + alias: Kontor lys via bevægelse mode: restart trigger: @@ -6,31 +7,71 @@ entity_id: binary_sensor.kontor_motion_bevaegelse to: "on" - variables: - timeout: > - {% if now().hour >= 6 and now().hour < 22 %} - {{ states('input_number.kontor_timeout_day') | int }} - {% else %} - {{ states('input_number.kontor_timeout_night') | int }} - {% endif %} + condition: + - condition: numeric_state + entity_id: sensor.kontor_belysningsstyrke + below: 60 action: - service: scene.turn_on target: entity_id: scene.kontor_klar +- id: kontor_motion_sluk_dag + alias: Sluk kontor lys efter 10 min uden bevægelse + mode: restart + + trigger: + - platform: state + entity_id: binary_sensor.kontor_motion_bevaegelse + to: "off" + + condition: + - condition: time + after: "06:00:00" + before: "23:59:00" + + action: - wait_for_trigger: - platform: state entity_id: binary_sensor.kontor_motion_bevaegelse - to: "off" - - - delay: - minutes: "{{ timeout }}" - + to: "on" + timeout: "00:10:00" + continue_on_timeout: true - condition: state entity_id: binary_sensor.kontor_motion_bevaegelse state: "off" + - service: light.turn_off + target: + entity_id: light.strip +- id: kontor_motion_sluk_nat + alias: Sluk kontor lys efter 5 min uden bevægelse om natten + mode: restart + + trigger: + - platform: state + entity_id: binary_sensor.kontor_motion_bevaegelse + to: "off" + + condition: + - condition: or + conditions: + - condition: time + before: "06:00:00" + - condition: time + after: "23:59:00" + + action: + - wait_for_trigger: + - platform: state + entity_id: binary_sensor.kontor_motion_bevaegelse + to: "on" + timeout: "00:05:00" + continue_on_timeout: true + - condition: state + entity_id: binary_sensor.kontor_motion_bevaegelse + state: "off" - service: light.turn_off target: entity_id: light.strip diff --git a/include/input/number/kontor.yaml b/include/input/number/kontor.yaml deleted file mode 100644 index 825692b..0000000 --- a/include/input/number/kontor.yaml +++ /dev/null @@ -1,16 +0,0 @@ -kontor_timeout_day: - name: Kontor lys timeout dag - min: 1 - max: 60 - step: 1 - unit_of_measurement: min - initial: 15 - -kontor_timeout_night: - name: Kontor lys timeout nat - min: 1 - max: 30 - step: 1 - unit_of_measurement: min - initial: 2 -