Solar battery percentage sensor sometimes gets "non-numeric", how to show latest numeric value recorded?

Hi there. I’ve just created a convenient dashboard to monitor my solar panels. I’m using the FoxESS (hacs) third party integration, which sometimes doesn’t work properly. Sometimes, the sensors don’t update for a couple of minutes, so I get a “unavailable” value for them.

It just lasts for one minute or two most of the times, for a dozen times in a day. So, since this problem only happens for a limited amount of time, is there a convenient way to show the latest recorded numeric value, at least until the sensor won’t get back working again?

Thanks in advance!

Search the forum for a template that will just not report if it’s unavailable. This is a commonly asked question.
Tips on Searching for Answers & Duplicate Topics in the Forum.

Thank you so much. Unfortunately as a non-native English speaker I find many difficulties with my queries sometimes.

Create a template sensor helper (Settings, Helpers) with a state template of:

{% if states('sensor.YOUR_SENSOR_ID')|float('x') is number %}
  {{ states('sensor.YOUR_SENSOR_ID')|float }}
{% else %}
  {{ this.state }}
{% endif %}
1 Like

Thanks a lot, finally it worked, and - better yet - I learnt a new thing!!