I am pretty new to Home assistant and am trying to figure out why this automation isn’t working. The intent is to trigger several lights to turn on 2 hours before sunset with a condition to only work between November 1st and Feb 1st. This is what I have for the automation:
alias: Turn on x-mas lights
description: ""
trigger:
- platform: sun
event: sunset
offset: "-02:00:00"
enabled: true
condition:
- condition: template
value_template: "{{ (11,1) <= (now().month, now().day) <= (2,1) }}"
enabled: true
action:
- type: turn_on
device_id: 0f0991bc696b4a12e42b5029977e468b
entity_id: switch.oustide_3_plug_lights_socket
domain: switch
enabled: true
- type: turn_on
device_id: 9d54754aba2d4357a94caab4e76e2447
entity_id: switch.garage_x_mas_lights_socket
domain: switch
enabled: true
- type: turn_on
device_id: adf5bafbbe80417a9bc98d6193881190
entity_id: 1f0ccaf91325fb7a0b7e2838d85fa0f3
domain: switch
mode: single
I have other automations that trigger on lights 1 hour before sunset and just copied that, modified it to 2 hrs and tried to add the condition with the dates based on what Google Bard suggested, yet the automation doesn’t work. When I test the date template within the visual editor, it keeps giving me an error saying “conditions did not pass” even though the current date is 11/24/23. I did some digging into some other posts I could find on the topic (from 2019) and tried emulating what they had but to no avail.
What the hell am I missing? I feel like since HA went through the major updates that the templates no longer work or that maybe I’m just missing something really simple and obvious? Ugh!
In general, I am mostly used to working in the visual editor and can figure out the basics, but I am not at all confident with the Yaml stuff. I have also noticed that the stuff that I am getting from Bard don’t quite match up with the current layout and build of HA.
Any help is appreciated!
Cheers!
-Matt