Hello,
I have the following template sensor which tells me where my main power source is based on inverter data. I would like to run various automations based in this, but there is too much “noise” at the transition times where values often oscillate between the “old” and “new” sources.
{% if states('sensor.pv_power')|float > states('sensor.grid_power')|float
and states('sensor.pv_power')|float > -(states('sensor.battery_power')|float) %}
Solar
{% elif -(states('sensor.battery_power')|float) > states('sensor.grid_power')|float
and -(states('sensor.battery_power')|float) > states('sensor.pv_power')|float %}
Battery
{% else %}
Grid
{% endif %}
I know that I can put a “for” delay in my automations, but there are several and maintaining them while I fine-tune what an acceptable delay should be seems tedious.
I am hoping that, like the binary sensor which has “delay_on” and “delay_off” directives, that there might be a “delay_change” directive for a template sensor. Of course there isn’t, but is there another way to include that delay?
The other thought I’ve had is to create three binary sensors with the necessary delays set there and have my automations use those. However, some are based on transition from one to the other (e.g. solar to battery, battery to grid) and binary sensors with delays don’t always seem to switch evenly to the point where I can use the transition from one state to the next reliably.