Lovelace UI official Gauge Card: Invalid numeric figure

Hi,
I am using the GAUGE CARD to show i.e. Pollen activity by German Weather Service (DWD).
If a forecast is not available , the value won’t be within interval [1…6], but ‘-1’.
In that case the same error comes up in the frontend like:

'Entity is non-numeric: ....'

Would it be possible to create an optional argument for the Gauge definition like:

error_message: 'Not available'

That the Gauge itself still appears, but the text appears instead of the coloured gauge scale?

Best regards,
Joerg

PS: Same problem here:

You could use a template sensor to either keep the last known good value or to report something like 9999 if there is no forecast available.

Ok, thanks for the answer.
I am almost new - if this is a simple solution for more experienced users, it is fine for me if this topic will be shifted to general forum questions…

For me it is still not possible…may you post some code, that I can alter or copy into my configuration file?
I am using the GUI mainly…

Regards,
Joerg

PS: I am actually have an infight already with some template sensor :slight_smile:

I can help you with the template sensor.

What is your pollen sensor entity_id and what state does it actually have when the forecast is unavailable (check the developer tools / states menu).

Also which would you prefer, 9999 or holding the last known value?

Oh, that would be great.
But it seems there is the next problem at the horizon.
I am using a custom component with Unique ID it seems if I have a look in the entities.
My entity in this case is
dwd_pollen_11_tomorrow_birke

The value in the API is ‘-1’ if no value is available.
Holding the last value seems reasonable.

Is there a solution, even without Unique ID?

regards,
Joerg

That’s still a numeric value.

You are right.
I will check the source file and API again.
My interpretation was, that the range in the gauge of 0-6 is showing a ‘-1’ as non valid.

Thanks for now,
Joerg

OK,
the State is ‘unknown’ , because the json file shows the ‘-1’ (which means ‘not available’ acc. German API)
I would appreciate if you can give me an example to keep the last value, in case the new state is unknown.

The json file will be here , just for information:
https://opendata.dwd.de/climate_environment/health/alerts/s31fg.json

The sensor is
sensor.dwd_pollen_11_today_avg

Best regards,
Jörg

- platform: template
  sensors:
    filtered_pollen:
      name: 'whatever you want' # change this
      unit_of_measurement: 'ppm?' # and this
      value_template: >
        {% if is_state('sensor.dwd_pollen_11_today_avg', 'unknown') %}
          {{ states('sensor.filtered_pollen') }}
        {% else %}
          {{ states('sensor.dwd_pollen_11_today_avg') }}
        {% endif %}
1 Like

Hi Jörg,

but this would give you wrong information as the value is really unknown. For this reason I am not going to change this, but feel free to use the template sensor to fit it to your use case.

BTW: I am planning to improve the implementation to support maybe renaming inside of Home Assistant itself and use the functionality the platform delivers a bit better, including tests, so that eventually I can create a PR to make it part of the core product instead having to install it manually.

Best
Schumi

You can adapt the template to tell you when the data is unknown by displaying an obviously incorrect value like 9999, with the advantage that the graph does not display the error message:

- platform: template
  sensors:
    filtered_pollen:
      name: 'whatever you want' # change this
      unit_of_measurement: 'ppm?' # and this
      value_template: >
        {% if is_state('sensor.dwd_pollen_11_today_avg', 'unknown') %}
          9999
        {% else %}
          {{ states('sensor.dwd_pollen_11_today_avg') }}
        {% endif %}

Thanks to Marc for the component.
With 9999 I am better off - you are right.

I altered the code slightly, because for ‘name’ I received an error.
Thanks a lot Tom!

filtered_pollen_birke_today:
        friendly_name: "Pollen_birke_filtered_today"
        unit_of_measurement: 'ppm' # and this
        value_template: >
          {% if is_state('sensor.dwd_pollen_11_today_birke', 'unknown') %}
            9999
          {% else %}
            {{ states('sensor.dwd_pollen_11_today_birke') }}
          {% endif %}

Have a nice sunday! :slight_smile:

1 Like

Sorry, you’re right. That should have been friendly_name, not name.

FYI You don’t need underscores in the friendly name. You can use spaces.

1 Like

Is there any reason why this won’t work anymore?

I get now the problem again, that the value remains ‘unknown’.

      filtered_pollen_birke_today:
        friendly_name: "Pollen_birke_filtered_today"
        unit_of_measurement: 'ppm' # and this
        value_template: >
          {% if is_state('sensor.dwd_pollen_11_today_birke', 'unknown') %}
            9999
          {% else %}
            {{ states('sensor.dwd_pollen_11_today_birke') }}
          {% endif %}

Regards,
Jörg