Files
fresh-home/automations/rooms/utility_room/utility_room_lights_to_on.yaml
T
2025-11-21 09:42:43 -05:00

63 lines
1.9 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"
variables:
switch_name: switch.utility_room_motion_switch
light_name: utility_room_hue
mode_name: input_select.utility_room_mode
automatic_profile: input_select.automatic_light_profile
action:
- alias: "Make sure Z-Wave switch is turned on"
action: 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:
- action: scene.turn_on
target:
entity_id: "scene.{{light_name}}_{{states(automatic_profile).lower().replace(' ','_')}}"
default:
- action: scene.turn_on
target:
entity_id: "scene.{{light_name}}_{{states(mode_name).lower().replace(' ','_')}}"
- delay: 1