Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 107652

Automation that triggers everytime a light changes state

$
0
0

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

Read full topic


Viewing all articles
Browse latest Browse all 107652

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>