I recently set up some christmas lights. As of current, I only have one smart switch (Zigbee switch in HA) running christmas lights but I set it up as a group so I can easily add more for next year. Then I setup a simple automation to turn the group on at sunset and off at 10:30PM like all of my other christmas lights (which are currently wifi switches controlled by Alexa). I also made a toggle for “christmas season”, with out outdoor christmas lights we mostly don’t need our regular exterior lighting, so this is really just there to tell tell HA to not turn on the porch light when the christmas lights are on.
Apparently, my wife (who stays up later than I do due to work schedules) has had to turn off the one switch controlled by HA every night, and I cant figure out why my automation isn’t turning it off. Any input on why this wouldn’t work as I expect is appreciated, see below for the YAML of the automation.
alias: Christmas Lights
description: >-
Turn all devices in currently used in Christmas Devices helper entity on and
off at scheduled time
trigger:
- platform: sun
event: sunset
offset: 0
condition:
- condition: state
entity_id: input_boolean.christmas
state: "on"
action:
- service: switch.turn_on
data: {}
target:
entity_id: switch.christmas_devices
- wait_for_trigger:
- platform: time
at: "22:30:00"
continue_on_timeout: false
- service: switch.turn_off
data: {}
target:
entity_id: switch.christmas_devices
mode: single
The issue with this is that, if the automation reloads midway for some reason like restart or so, the wait for trigger will be cancelled. The best way is to set another trigger and use choose action like below. Please do try it and let us know if this works.
Given that you’re simply turning a switch on/off you can use a service template to select the correct service call.
alias: Christmas Lights
description: >-
Turn all devices in currently used in Christmas Devices helper entity on and
off at scheduled time
trigger:
- platform: sun
event: sunset
offset: 0
- platform: time
at: "22:30:00"
condition:
- condition: state
entity_id: input_boolean.christmas
state: "on"
action:
- service: "switch.turn_{{ iif(trigger.platform == 'sun', 'on', 'off') }}"
data: {}
target:
entity_id: switch.christmas_devices
mode: single