Yes, turning the sensor one is working, here is a screenshot of the sensor data. Each dip of the power consumption is about 4 minutes long, so should okay right?
No, the template would still decide if the binary sensor was on or off based on the sensor value.
I think it’s actually unexpected behaviour.
You were triggering on any change of sensor.sonnen_batterie_verbrauch (or its attributes) and then evaluating the template.
That was not required as the plain state based template version would update on any change of sensor.sonnen_batterie_verbrauch (but not on change of its attributes).
Your original trigger version was redundant but should have lead to the same behaviour. With the exception that your trigger would also update the template if any of the sensor’s attributes changed.
I’m a little confused as to why your trigger version did not work.
@123 , @petro , @Burningstone apologies for the ping but this is an interesting enigma you may enjoy, any idea why the original trigger based version failed to operate as expected?
But I agree, it‘s at least unexpected and not really self explenatory since automation triggers and templates in automation conditions & actions work together differently.
The first thing that comes to mind is that it doesn’t need a State Trigger because its value_template is already capable of listening to the same sensor’s state-changes.
Based on my understanding, with a State Trigger it listens for any changes to the sensor’s state. When a change is detected, it triggers and evaluates the template.
Without a trigger it also listens for any changes to the sensor’s state (because the sensor exists within the template so Home Assistant creates a listener for it) and, when a change is detected, it evaluates the template.
@yolani
Out of curiosity, which version of Home Assistant are you using? Is it recent?
(Trigger-based Template Sensor was introduced in 2021.5.
I am using the docker image with the stable tag, continuously updating through Watchtower. So currently this is equal to 2021.7.3.
BTW, the input sensor is a value I retrieve with a 2s scan interval through a REST sensor from my local house power management, so it’s quite frequently updated.