How can I ignore "NaN" values?

Hi,

I have a MQTT sensor to measure humidity and let home-assistant notify me via Telegram when the humidity value gets above 60%.

The MQTT sensor configuration:

- platform: mqtt
  state_topic: "rooms/livingroom/humidity"
  name: 'Living Room Humidity'
  unit_of_measurement: '%'

The automation configuration:

- alias: Living Room Humidity
  trigger:
    platform: numeric_state
      entity_id: sensor.livingroom_humidity
      above: 60
  action:
    service: notify.telegram
    data:
      message: The living room needs some fresh air!

The notification works, however sometimes the MQTT sensor value is shown as “NaN” in home assistant and this also triggers a notification. How can I avoid the “NaN” values or avoid that home assistant sends a notification in that case?

1 Like

i have exactly opposite issue. sometimes my crappy sensor sending NaNs and i want to know when i have to restart it (or check the wiring). But HA just ignores NaNs. At least in mqtt sensors.

Does it still ignore NaN, my sensors now show as None when tasmota sends NaN values. Eg if I disconnected my sensor.

I have the same problem. Sometimes my sensor sensor.modul_co2_2_temperature state = NaN and trigger

  - above: 26
    entity_id: sensor.modul_co2_2_temperature
    platform: numeric_state

run automation.

How can I ignore NaN state and not run trigger when it’s “NaN”?
Please,help!

How long does the value stay NaN for ?
If the automation is not time critical you can effectively filter out the NaN’s with a time condition

  - above: 26
    entity_id: sensor.modul_co2_2_temperature
    platform: numeric_state
#         hh:mm:ss
    for: '00:05:00'
1 Like