How to maintain the last value of an entity when become unknown

Hi there, I would need your help.
I have a bunch of templates doing calculation based on AC Power, AC energy, DC energy etc. entities exposed from the Solar inverter.
The problem is that all calculations went broken when the inverter power off, during the night.

I’m asking if there is a way to derivate entities that maintain the last value. I’m trying using the utility meter helpers, selecting the maintain last value flag, but is not working fine with real time sensors as AC power. Any alternative way to do it?

When I say that utility meter is not working fine, I mean that also having high source value, the entity value increase slowly, not following the source status:

Hi Claudio1L,

Not long ago I heard this question, and I believe there was a solution.

Please search for it. I am not able to at this moment.

Do you mean here?

I haven’t read the thread closely, but they seem to be talking about general solutions for large numbers of sensors. Not sure this is a good idea.

For specific sensors, I personally use the custom integration Variables+history:

Thanks @jackjourneyman

looks promising. I’m checking

Thanks again