Hey, I hope someone can point me in the right direction with my automation not triggering.
I have an automation to synchronize a light (my Christmas decoration outside) with some other lights (the ones in the rooms seeing the decoration). I use templates to trigger the automation, because I re-use a blueprint, which I am using often in my home. This was working perfectly.
Now, I’d like to restrict the time for my decoration to shine only in the timespan between 7:00 in the morning and some fixed delay after sunset. Because in that time, my (still offline) blinds would be open. I extended the trigger template and tested it in the developer tools and it results in what it should. I then copied the template to the automation editor and saved it. However, only the on
trigger seems to work, while the off
trigger only works when I switch the inside lights.
Could it be that the sun is not listened for changes for some reason?
Here’s the trigger section of my automation:
mode: parallel
trigger_variables:
trigger_entity:
- light.wohnzimmer_sofalicht
- light.wohnzimmer_esslicht
- switch.kuche_licht_state
trigger:
- platform: template
id: 'on'
value_template: |
{{ expand(trigger_entity)
| map(attribute = 'state')
| select('==', 'on')
| list
| length
> 0
and (
is_state('sun.sun', 'above_horizon')
or timedelta(hours=0.25) > now() - states.sun.sun.last_changed
or now().hour >= 7 and now().hour < 12
) }}
for: '00:00:00'
- platform: template
id: 'off'
value_template: |
{{ expand(trigger_entity)
| map(attribute = 'state')
| select('==', 'on')
| list
| length
<= 0
or is_state('sun.sun', 'below_horizon') }}
for: '00:15:00'