Triggering automation when temp sensor is down?

Hi,

I have a bunch of DS18B20 Dallas temp sensors on an ESP32 ESPhome device.

I want to make sure these sensors are actually alive (their update interval in ESPhome is 1 minute)

is there a way to setup an automation if (for example) there hasn’t been a temp update from a certain sensor in 5 the last minutes ?

… imagine if the sensor stops sending temp updates and the heating keeps going all night full throttle because the thermostat’s incoming temperature is “frozen” (no pun intended) …

so it’s more of a safety measure …

how do I do this ?

Are you experiencing drop-outs or is this a preemptive strike? I ask because there are many ways things can fail

Yes, you can do that by using the “last changed” value of the sensor’s state object. But, what if the temperature has just been 18.0˚ for 6 minutes…?

I would use a template trigger like the following:

trigger:
  - platform: template
    value_template: "{{ now() - states.sensor.livingroom_temperature.last_changed > timedelta(minutes=10) }}"

There’s also this status binary sensor that tests if your ESP device is connected:

Are you experiencing drop-outs or is this a preemptive strike? I ask because there are many ways things can fail

definitely as a preemptive strike …

Yes, you can do that by using the “last changed” value of the sensor’s state object. But, what if the temperature has just been 18.0˚ for 6 minutes…?

exactly right … it’s risky indeed …
in my ESPhome logs I see that the ESP sends the values to HA every minute … so can’t I use a “last received data” value of the sensor, instead of “last changed” value ?

There’s also this status binary sensor that tests if your ESP device is connected:

I know but that doesn’t test the sensors, does it ?
they can also fail (Onewire is sensitive to failure, especially when the lines are long)

so this “status” sensor would only be the solution to half of the problem …

Nope.

There is no such attribute.

Only last_changed and last_updated. Both require the state to change. See: State Objects - Home Assistant

maybe by using timers (and resetting them each time a value is sent) ?

Ahha!!

The base sensor config has this:

Screenshot 2021-11-27 at 00-46-46 Sensor Component

aha !
that could be a way to do it …
I will further investigate this “on_value” command …

thanks for the help !

I just edited my post with a better way.