Filtered sensor "freezes" with no new data

I have created a filter that smooths out changes in the grid load that is reported by my inverter. This is useful in automations which might otherwise be thrown by sudden spikes and dips in load.

However, because I am in South Africa and we get regular load shedding (2h scheduled rolling black-outs), when the grid drops, no data is reported by the inverter (I assume because there is no change in state). This seems to have the net effect that my filtered sensor “freezes” on the last calculated value.

This has the effect that some automations, which depend on knowing if there is a loss of grid supply, don’t fire. I should say that the purpose of the filter was mostly to allow for the 40W synchronisation draw from the inverter. The raw sensor report this as zeroes and spikes that are not insignificant. When everything’s operational, the filter seems to work very well.

I’ve tried to use a time-based moving average, but still, in the absence of data, nothing seems to change.

The sensor has this configuration:

(Apologies for screenshots - file editor on mobile does not allow for copy/paste :disappointed:)

Any thoughts?

One alternative would be to add in a check to see how long ago that sensor was updated and ignore it if it was updated over 1 minute ago. But I can’t work out how to add that condition to an automation - specifically how to test that something was last updated more or less than a specific time ago?

Another is to put this filtered sensor through a template which will give me complete control over it…

First prize is just to configure one thing (the filtered sensor) to just “work”…

Can you include sensor.grid_power in your history graph as well please?

image

Well, that’s your problem. Your source sensor stopped responding.

I’m not sure you’ve understood correctly: if you see the actual title, you will see that I am actually aware that there is “no new data”. The sensor reports ZERO, because, well, the inverter is not getting its power from the grid anymore.

My expectation is that the filter will look at the last two minutes (because that’s what it’s configured to do) and slowly work that moving average to zero over the course of the two minutes.

Nope, filter entities only update when the source sensor updates. The filter sensor does not poll.

If you want that type of functionality, you’ll have to get inventive.