I need to filter states, so that only values that are equal or higher than the previous state are accepted. I checked the filter and the statistics integration, but couldn’t find anything. Is there a way to implement that?
Background: My Zooz Plug Switches sometimes return energy (kWh) values that are zero or significantly lower than the previous ones, which fucks up the utility_meters, because they count the way back from zero to the real value as additional energy usage.
I could use the outlier filter, but maybe there is something that ignores values that are smaller than the previous ones, because that would be closer to reality.
Thank you, but, err, how do I even access the previous state in the definition of a template sensor? I know how you do it in automations, but I couldn’t find anything for template sensors.
You are right, the previous value is only available as part of the trigger in an automation. Maybe something like this would work… I’m not sure how the templates are processed by HA, so this could create some sort of race condition…
Ha, that is pretty much the workaround that I thought of too , but reading through your code I just remembered that the Z-Wave Plugs expose a “previous_reading” sensor, that I disabled globally, because I had now use for it. Until now. Guess this is a good reason to enable it again.
Really appreciate you leading me into the right direction!