Files
N22/include/automations/lys_badevaerelse.yaml
T

73 lines
1.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
- id: badevaerelse_motion_lys
alias: Badeværelse lys via bevægelse
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.badevaerelse_bevaegelse
to: "on"
action:
- choose:
# Arbejdsdag dagtid (06:0022:00)
- conditions:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: "on"
- condition: time
after: "06:00:00"
before: "22:00:00"
sequence:
- service: scene.turn_on
target:
entity_id: scene.badevaerelse_klar
# Ikke arbejdsdag dagtid (08:0022:00)
- conditions:
- condition: state
entity_id: binary_sensor.arbejdsdag
state: "off"
- condition: time
after: "08:00:00"
before: "22:00:00"
sequence:
- service: scene.turn_on
target:
entity_id: scene.badevaerelse_klar
# Nat (alle andre tidspunkter)
default:
- service: scene.turn_on
target:
entity_id: scene.badevaerelse_nat_2_lys
- id: badevaerelse_motion_sluk
alias: Sluk lys på badeværelse efter bevægelse
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.badevaerelse_bevaegelse
to: "off"
variables:
is_dag: >
{% set t = now().strftime('%H%M') | int %}
{% if is_state('binary_sensor.arbejdsdag', 'on') %}
{{ 600 <= t < 2200 }}
{% else %}
{{ 800 <= t < 2200 }}
{% endif %}
action:
- delay:
minutes: >
{{ states('input_number.badevaerelse_timeout_day') | int if is_dag
else states('input_number.badevaerelse_timeout_night') | int }}
- condition: state
entity_id: binary_sensor.badevaerelse_bevaegelse
state: "off"
- service: light.turn_off
target:
area_id: badevaerelse