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

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: