#Automations during specific calendar time frame

1 messages · Page 1 of 1 (latest)

spiral axle
#

Hi! I recently purchased a Kasa smart plug to allow me to not have to toggle my holiday lights on and off. However, I only want these to trigger from after Thanksgiving until New Years.

Is the calendar trigger restriction possible?

broken sparrow
#

You can use a template condition for that.

#

Easy for static dates, likely more complicated for dynamic ones.

#

Example for automations running between November 27th and January 6th:

{{ (now().month == 11 and now().day >= 27)
  or (now().month == 12) 
  or (now().month == 1 and now().day <= 6) }}
spiral axle
#

That's the middle section of the automation, right?

broken sparrow
#

The conditions part, yes.

spiral axle
#

Okay, I'll put it in and give it a shot

spiral axle
#

And lastly, if I want to trigger the automation to turn on 20m before sunset, is this the right format?

broken sparrow
#

I think that would be -00:20:00

spiral axle
#

I missed my window today and am too lazy to refactor, so I'll wait for tomorrow

mystic barn
#

For the template you can compare using a tuple, which makes reading the code easier and also lets you do ranges easier.

{{ (now().month, now().day) >= (11, 27) or
  (now().month, now().day) <= (1, 6) }}
sonic gale
#

You could also create a holiday light calendar event that runs from 27th Nov to 6th Jan and just check if that's on

spiral axle
#

Okay, so it turned on tonight, which is good

#

I had disabled the date check to make sure that -00:20:00 worked

#

And already confirmed they turned off last night at 1:30AM, so fantastico 😄

high pebble
#

or trigger off the calendar directly - {{ state_attr('calendar.party_at_home', 'message') == 'Party at Home' }} or condition: state
entity_id: calendar.roof_led_schedule
state: Halloween
attribute: message