Trigger on unreadable or unavailable values

I’ve got a ESP connected to HA, with a temperature sensor (DHT22), placed in a tropical greenhouse. I need to keep the greenhouse above 10°C, so I added a climate control with a heater. Last night, the thermometer failed for some reason, and the readings in HA showed “not available” (in Dutch, so not sure if this is the exact translation). The ESP was still running (switches were reachable from HA). I want to get a notification or restart of the ESP when this happens again, but I have no idea how to set up the automation trigger for unreadable or unavailable values. Any idea?

you have to know what the actual state is by going to the states panel and looking at the entity_id.

but here is the generic trigger:

  - platform: state
    entity_id: sensor.your_temp_sensor
    to: 'unavailable'

Thanks a lot for the reply. I implemented it yesterday, and during the night, it happened again :frowning: The trigger is unfortunately not activated.

It’s still in the current state (didn’t restart the ESP yet). Any idea how I can know the correct “to”-value to put in the trigger? In dutch, the value says “Onbekend”, but I guess that’s just a label…

I will also try to connect the sensor to a different pin (just to be sure), but a trigger on this event would decrease stress-levels a lot! :slight_smile:

Did you go to the states panel and look at the entity_id for the sensor to see what the actual satates are as I suggested above?

Also it’s impossible to see why it’s not working if you don’t post any code.

Don’t post a screenshot of the code. post the yaml properly formatted by using ``` on the line before and after the code.

Thanks! I have removed the single quotes from your code, and I think it works now. Will have to wait until it fails without me testing it, but I feel confident it will work.

I have read your first reply too fast indeed, and didn’t even know there was a page to see the state of all entities (very new in the world of HA). Thank you for that suggestion!

- id: '1615129382758'
  alias: GHMobile01_TemperatureUnavailable
  description: ''
  - platform: state
    entity_id: sensor.ghmobile01_temperature
    to: unavailable
  - device_id: ad88f0936ff6657db4b11c708d013ce2
    domain: mobile_app
    type: notify
    message: Temperatuur sensor werkt niet meer
    title: Waarschuwing!
  mode: single

I don’t think it should have made any difference if the quotes were there.

Either way you are comparing a string value.

But hopefully it works. :slightly_smiling_face:

And an FYI

if you don’t reply directly to me by hitting the “reply” button in my post or you include my name with @finity then I don’t see your replies to me. I usually check my notifications first and eventually get around to reading my unread posts later.