Getting an entity from Home Assistant is returning "nan"

Here is my sensor configuration:

sensor:
  - platform: homeassistant
    name: "glucose"
    id: glucose
    entity_id: sensor.dexcom_stevermann_glucose_value

In Home Assistant, dev tools, states, the state of “sensor.dexcom_stevermann_glucose_value” is 105.

Does anyone see anything wrong that would make the sensor value NAN?

Its not a type error is it (numeric vs text).

I still get a fright seeing a BS level of 105. That’s 5.8 in real mmol/L numbers.

NAN means Not A Number.
HA has a rigid rule about all sensors value being stored strings, so you might need to convert it in ESPHome.

" Note

This component is only for numeral states. If you want to import arbitrary text states from Home Assistant, use the Home Assistant Text Sensor."

Isnt 105 a number?

Then you would hate my overnight highs. But my endo says I am well-controlled.

That is the hard part to decipher with computer coding.

105 can be a number, but it can also be a string consisting of 1,0 and 5.

That completely went over my head and I missed that little detail. Looking at numbers, the thought that it might be a string instead of an int or perhaps a float. that’s an easy oversight to make and I’m sure it happens to the best of us! Nice catch on that one.

It would be nice if dev tools → states had a type column: (string, float, int)

1 Like

You can get that in dev tools/templates.

Put this in and see what the result is

{{ states('sensor.dexcom_stevermann_glucose_value')}}

I wish it were that easy. Here is what I entered:

Glucose: {{ states('sensor.dexcom_stevermann_glucose_value')}}
Glucose Number: {{ states('sensor.dexcom_stevermann_glucose_value') | int }}
Glucose string: {{ states('sensor.dexcom_stevermann_glucose_value') | string }}

All three returns the same state. I would have hoped that int or string would have returned zero.

Look at Result type.

Thanks. It’s well hidden on the top of my screen

But now I know where to look next time.

I wonder if it’s worth a Feature Request?