Vard0
June 5, 2020, 8:11am
1
Hi all.
I’m hoping someone can help me with some of my devices that cause my guage cards to show “entity is non-numeric” when they go offline.
I have seen this forum post but unfortunately I cannot find a way to get the suggested solutions to work for me:-
https://community.home-assistant.io/t/lovelace-ui-official-gauge-card-invalid-numeric-figure/189316
An example of one of the sensors I am monitoring is below:-
- platform: template
sensors:
temperature_th:
friendly_name: Solar Geyser Temperature
unit_of_measurement: '°C'
device_class: temperature
value_template: "{{ state_attr('switch.sonoff_1000bd0443', 'temperature') }}
The state it shows when it is offline is as below.
Ideally I would like it to show a value of 0 if it is offline.
Does anyone know how I can resolve this?
Thanks
tom_l
June 5, 2020, 8:59am
2
- platform: template
sensors:
temperature_th:
friendly_name: Solar Geyser Temperature
unit_of_measurement: '°C'
device_class: temperature
value_template: >
{% if is_state_attr('switch.sonoff_1000bd0443', 'temperature', 'unknown') %}
0
{% else %}
{{ state_attr('switch.sonoff_1000bd0443', 'temperature') }}
{% endif %}
Vard0
June 5, 2020, 11:14am
3
Thank you Tom.
I had a suspicion you would be the first to respond
I tried this but unfortunately it did not work:
I am still getting the error:-
This is the Gauge card config:
There are two entities that are associated with this sonoff device:-
tom_l
June 5, 2020, 11:17am
4
I was only testing for unknown
state. Yours is unavailable
. Try this:
- platform: template
sensors:
temperature_th:
friendly_name: Solar Geyser Temperature
unit_of_measurement: '°C'
device_class: temperature
value_template: >
{% if state_attr('switch.sonoff_1000bd0443', 'temperature') in ['unknown', 'unavailable', 'none'] %}
0
{% else %}
{{ state_attr('switch.sonoff_1000bd0443', 'temperature') }}
{% endif %}
Vard0
June 5, 2020, 11:37am
5
Thanks Tom.
No change unfortunately. Still shows the same error on the card.
Are the states case sensitive?
tom_l
June 5, 2020, 11:55am
6
What is the state of the two sensor/attributes?
Vard0
June 5, 2020, 11:58am
7
Current states are below:-
Are the states case sensitive in the yaml file?
tom_l
June 5, 2020, 12:00pm
8
Has the sonoff temperature changed yet?
The template wont update until it does.
You could try running the update_entity service in the developer tools.
Vard0
June 5, 2020, 12:28pm
9
Hi Tom
No. The devices are offline (power cut).
I set the state manually to 55 and the card changed:-
I then ran the update_entity service
And it went back to this:-
tom_l
June 5, 2020, 12:38pm
10
Change ‘none’ in the template to ‘None’
Vard0
June 5, 2020, 12:52pm
11
Still no luck Tom.
It goes back to the same status on the card after I call the update_entity service.
tom_l
June 5, 2020, 1:59pm
12
Well, if you are sure you have exactly this:
- platform: template
sensors:
temperature_th:
friendly_name: Solar Geyser Temperature
unit_of_measurement: '°C'
device_class: temperature
value_template: >
{% if state_attr('switch.sonoff_1000bd0443', 'temperature') in ['unknown', 'unavailable', 'None'] %}
0
{% else %}
{{ state_attr('switch.sonoff_1000bd0443', 'temperature') }}
{% endif %}
Then I’m out of ideas.
Vard0
June 8, 2020, 11:28am
13
Hi Tom
Thanks very much for your assistance with this. My config settings were exactly as you posted above. (I copied and pasted them into the configuration.yaml file).
These are sonoff devices and I think there may something unusual about their state values???
I ended up tackling this through a python script similar to the one that was posted here:-
https://community.home-assistant.io/t/change-switch-state-without-performing-action/142706/14
Steven_V
(Steven)
October 26, 2020, 10:24am
14
The gauge for my SMA sunny boy gave a ‘non-numeric’ error when the solar panels were not producing any power.
This is my configuration.yaml:
sensor:
- platform: sma
host: 192.168.0.28
ssl: true
verify_ssl: false
password: <mypassword>
scan_interval: 60
sensors:
- pv_power
- daily_yield
- total_yield
- platform: template
sensors:
pv_power_numeric:
value_template: "{{ states('sensor.pv_power') | float }}"
unit_of_measurement: "W"
i am using sensor.pv_power_numeric as the value for my gauge. It now shows ‘0’ instead of showing the ‘non-numeric error message’ when it’s dark.
1 Like
petro
(Petro)
October 26, 2020, 11:46am
15
Welcome,
Why are you creating a pv_power_numeric sensor? You don’t need to. Just add the unit_of_measurement to pv_power.
Steven_V
(Steven)
October 26, 2020, 5:10pm
16
even with the unit_of_measurement set, i still get the error "entity is non-numeric: sensor.pv_power’ and the gauge is not shown (when there is no solar panel output).
On normal output, i see the gauge with the correct value.
With the pv_power_numeric, the ‘nill’ value is converted to numeric 0.
no error!
petro
(Petro)
October 27, 2020, 2:58pm
17
Ok, so then was your original response a question or just you saying “This is how I fixed it”?
Steven_V
(Steven)
October 27, 2020, 10:22pm
18
This is my solution to the original topic question…
No need to compare to [‘unknown’, ‘unavailable’, ‘none’] …
petro
(Petro)
October 28, 2020, 1:00am
19
Might want to say that in your post next time. I’m not sure if this is a translation issue or what, but that wasn’t clear.
VdR
December 14, 2020, 7:46pm
20
You are a genius.
I had the same issue with all readings from the SMA inverter except total yield. This solved it. Great. Thank you.