Hi,
I want to create an automation, that fires everytime, a light changes its state. Therefore I tried to use a template trigger, wich simply evaluates the number of lights, that are on. Basically it seems to work, but unfortunately, when the number of lights changes from 0 to some value >0 and not, when it changes for example from 1 to 2. I think it is because a template trigger only fires, when it changes from false to true, so I have to find a condition, which works here.
For me it is important, to have a flexible solution, that keeps on working, when a new light is added, or an entity id changes so I do not want to hardcode all my lights into the automation trigger.
alias: light state changed
description: ''
trigger:
- platform: template
value_template: >-
{{(states.light|selectattr("state","eq","on")|list|length)}}
Are there any ideas?
Thank you in advance
GW
1 post - 1 participant