I have a gate with a contact sensor installed on it. When the gate is open, it triggers a smart bulb to turn on red. When the gate is closed it checks if the bulb is supposed to be on, it changes to color to the normal color and if the bulb is supposed to be off, it turns the bulb off. The bulb is scheduled to turn on at 6pm and turn off at midnight.
I had to make two separate automations for when the gate is closed to account for whether the bulb is supposed to be on or off.
alias: Gate Closed while Lamp is Scheduled Off
description: ''
triggers:
- trigger: door.closed
target:
area_id: back_yard
options:
behavior: each
conditions:
- condition: schedule.is_off
target:
entity_id: schedule.living_room_lamp_schedule
options:
for: '00:00:00'
actions:
- action: light.turn_off
metadata: {}
target:
area_id: living_room
data: {}
mode: single
First question is can I consolidate these two automations into one automation (if/then + elseif/then)?
If yes, should I consolidate the automations (best practice)?
An update for anyone trying to use the yaml, rgb_colorand color_temp_kelvin cannot be used at the same time (the gui currently allows both to be set but the automation still error out). Apparently color_temp_kelvin does set the bulb to “white” at that color temp.