Lovelace Guage Card - entity is non-numeric

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.

image

Ideally I would like it to show a value of 0 if it is offline.

Does anyone know how I can resolve this?

Thanks

- 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 %}

Thank you Tom.

I had a suspicion you would be the first to respond :grinning:

I tried this but unfortunately it did not work:

I am still getting the error:-

image

This is the Gauge card config:

image

There are two entities that are associated with this sonoff device:-

image

image

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 %}

Thanks Tom.

No change unfortunately. Still shows the same error on the card.

Are the states case sensitive?

What is the state of the two sensor/attributes?

Current states are below:-

image

image

Are the states case sensitive in the yaml file?

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.

Hi Tom

No. The devices are offline (power cut).

I set the state manually to 55 and the card changed:-

image

image

I then ran the update_entity service

image

And it went back to this:-

image

Change ‘none’ in the template to ‘None’

Still no luck Tom.

It goes back to the same status on the card after I call the update_entity service.

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. :man_shrugging:

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

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

Welcome,

Why are you creating a pv_power_numeric sensor? You don’t need to. Just add the unit_of_measurement to pv_power.

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!

Ok, so then was your original response a question or just you saying “This is how I fixed it”?

This is my solution to the original topic question…
No need to compare to [‘unknown’, ‘unavailable’, ‘none’] …

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.

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.