Files
fresh-home/automations/rooms/utility_room/utility_room_lights_to_on.yaml
T
2024-04-14 14:08:56 -04:00

56 lines
1.8 KiB
YAML

alias: Utility Room Lights to On
id: automation_utility_room_lights_to_on
mode: single
# Hide warnings when triggered while in delay.
max_exceeded: silent
trigger:
- platform: state
entity_id:
- input_select.utility_room_mode
- input_select.automatic_light_profile
- platform: state
entity_id: input_boolean.utility_room_occupied
to: "on"
# Only turn on the lights when necessary
condition:
- condition: or
conditions:
# Either when motion is detected
- condition: template
value_template: "{{ trigger.entity_id == 'input_boolean.utility_room_occupied' }}"
# Or when the scene changes while the lights are already on
- condition: and
conditions:
- condition: or
conditions:
- condition: template
value_template: "{{ trigger.entity_id == 'input_select.utility_room_mode' }}"
- condition: template
value_template: "{{ trigger.entity_id == 'input_select.automatic_light_profile' }}"
- condition: state
entity_id: light.utility_room_vanity
state: "on"
action:
- alias: "Make sure Z-Wave switch is turned on"
service: homeassistant.turn_on
target:
entity_id: switch.utility_room_motion_switch
- choose:
- conditions:
- condition: state
entity_id: input_select.utility_room_mode
state: Auto
sequence:
- service: scene.turn_on
target:
entity_id: "scene.utility_room_hue_{{states('input_select.automatic_light_profile').lower().replace(' ','_')}}"
default:
- service: scene.turn_on
target:
entity_id: "scene.utility_room_hue_{{states('input_select.utility_room_mode').lower().replace(' ','_')}}"
- delay: 1