Hi, still getting to grips with HA with no prior coding experience so please bear with me. I will try to explain the issue that I am seeing as clearly as possible.
I am using the built in ‘Gauge Card’ in Lovelace to display the current electricity cost in GBP for the day so far. The data for the gauge is coming form sensor.electric_cost_today which is an entity provided by an installed integration of ha-hildebrandglow-dcc which uses the data provided form my smart meter.
My gauge card configuration is as follows:
type: gauge
entity: sensor.electric_cost_today
min: 0
severity:
green: 0
yellow: 2
red: 4
needle: true
max: 10
The Gauge Card works fine, until I reboot Home Assistant. While rebooting, where this Gauge Card normally displays, there is an error message saying ‘Entity is non-numeric: sensor.electric_cost_today’
I have checked the state of the entity during a HA restart, and the state shows as ‘unknown’
When the sensor does start returning a numeric value for the state which the Gauge Card can display, it starts working again.
If possible I would like to handle this error message gracefully, so that perhaps the words ‘Waiting for Data’ or similar are displayed until the correct value can be returned.
I have found a handful of other forum posts about this state unknown error, such as this one:
and have tried to implement a fix, however i’m as yet a little out of my depth until I can do some more reading and learn more about sensors and templates!
What I have tried to do is to add the following to my config.yaml file
sensor:
- platform: hildebrandglow_dcc
name: 'electric cost today'
unit_of_measurement: 'GBP'
value_template: >
'{% if is_state(': sensor.electric_cost_today', 'unknown', 'Unknown', 'none', 'None') %}
Waiting for Data...
{% else %}
{{ states('sensor.electric_cost_today') }}
{% endif %}
However the error still displays upon restart.
Can I achieve what I want, or do I need to look at an alternative workaround such as either just not displaying the Gauge Card until the value can be delivered successfully, or showing zero until such time? These options look to be possible using either a conditional display setting or adding in a ‘float’ but again I’m unfamiliar with all of this as yet.
Thanks for any help!