…And Home Assistant

So last year I bought a couple of smart lights to play around with. I ended up installing Home Assistant in a docker on my pi (the pi400) to control them.

I have an Office light and TV room light.

  • The TV light turns on 1/2 hour before sunset and off at 10:10 pm everyday.
  • The Office turns on 1/2 hour before sunset then fades to a calm colour at 7 pm, turning off completely at 10:10pm.
  • In the morning the Office light turns on at 7 am and the off 1/2 hour after sunset.

But I want the office light to not turn on/off in the morning when the days are long so I had to write some YAML code which I’ve had to revise several times.

This is a trigger to fire my office light (in the morning) between September 25 and May 15. It still may not be working right, but so far so good.

Edit YAML mode:


condition: template
value_template: >
  {% set n = now() %} {{ n.month == 9 and n.day >= 25 or n.month > 9
         or n.month == 5 and n.day <= 15 or n.month < 5 }}

https://community.home-assistant.io/t/automation-during-date-range/133814/50