Hi there
I’d like to setup an automation that is triggered by a virtual button and then based on time of year (for example, January to June) turns on certain lights (and their associated effects) then with the same button (ideally same automation) pressed in July through September each year sets a different number of lights with different effects.
I’ve already setup how the light strips and bulbs will react color and effect wise through the button but scratching my head on how to take range of months in a year within the automation. I believe Template may be the way to go but not sure how to get started with this. Can anyone offer assistance or a script/template ?
Thanks so much
You can use a Choose statement with template conditions to do different things in different months. For instance, this template would be true for January through June (inclusive)
{{ now().strftime("%m") | int < 7 }}
@atlflyer
Thats great so I could have the button stay the constant (on or off) and then use the choose statement for 3-4 different times of year to change to the specific lighting ?
How do I add day of month into that template example and also how would you straddle years (Dec through Jan) etc ?
Thanks
Also if you wanted a specific day so for example 4th July for 1 light scene but jan through July 3rd for another, 5th July through November 22nd another etc etc
Something like this for a date selection but what about specific dates etc, 1 off date if you will ?
{{ (1,10) <= (now().month, now().day) <= (10,31) }}
Choose actions check the options’ conditions sequentially, so put more specific options first:
actions:
- variables:
now: '{{ now() }}'
day: '{{ now.day }}'
month: '{{ now.month }}'
- action: choose
- alias: 4th of July
conditions:
- condition: template
value_template: '{{ (month, day) == (7, 4) }}'
sequence:
- action: scene.freedom_hell_yeah_lights
- alias: St Patrick's Day
conditions:
- condition: template
value_template: '{{ (month, day) == (3, 17) }}'
sequence:
- action: scene.lights_of_the_irish
- alias: Jan-July
conditions:
- condition: template
value_template: '{{ month <= 7 }}'
sequence:
- action: scene.jan_july_lights
Thats fantastic. Thanks so much both.
One last question. This is more integration specific but I am using the Kasa integration and there is a specific entity/ action that I can setup using an automation to layout color options etc BUT does not show up in Scenes therefore not able to capture the colors, timing etc. As mentioned I can easily do this in the automation but though that it would benefit from a Scene type of approach since then I can always adjust the color, timing centrally rather than in each automation.
What can be done in situations like this where a Device Action or Entity is not show in the Scenes setup, are there better ways to trap current specifics of a device ?
Thanks again