Limit automation for christmas lights

When switching my chrismas lights, I use two time regions, between sunset and midnight, or early morning and sunrise. That works perfect!
Now I wanted to limit this automation to the date regions between Advent 1st. and Epiphany (January 6th). Currently I realized this with the condition
{{ now().month in [1,12] }}
and unplug the lights manually on January 7th. But next year, I plan to go skiing that week, so I want to set the limit in automation.
And, yes, I do not know, how to adopt the condition accordingly. And, as this condition is kind of hardwired, there is no need to adopt it, such as a calendar entry could do. Hopefully, the liturgy will not change as long as HA exists.
Any simple idea?

You can use conditions like if you are home or not. Or proximity sensor, there is integration for it, and use that as condition if you know where you will be.

Post your existing automation in YAML format.

Or, if you know how to create a Template Condition, use the following in your automation.

  - condition: template 
    value_template: >
      {% set today = (now().month,now().day) %}
      {{ today >= (12,1) or today <= (1,6) }}

It’s designed to check if the current day is between December 1st and January 6th, inclusively.

1 Like

The Term, I mentioned above, is written as a template condition in gui.
I will try to replace it with your terms in the yaml editor.
Thanks!

Just for testing, as chrismas is still far away, I took another condition:
My heating closes between June 1st and September 15th, without any connection to HA. So, I exclude this time from my window sensor, which closes the thermal sensor in the room, when opened and starts heating, when closed.
I added this routine
{% set today = (now().month,now().day) %} {{ today <= (6,1) or today >= (9,15) }}
And, yes, it works perfectly!
Thanks!!

1 Like