Trigger when an entity stops reporting?

I have 3 android wall tablets in my house. I use the HA app to monitor the battery level in order to turn on/off the charger. One of my tablets routinely (every week or so) will stop reporting its battery state for several hours. When this happens the battery state in HA just stays flat.

Untitled

I tried using the trend sensor to catch this and notify me, but the trend sensor requires two updates to set a trend. If the tablet isn’t updating the sensor won’t work. The tablet battery level also doesn’t go to “unavailable” so I can’t trigger it using a state.

Does anyone know how I can get a trigger when this happens? I want t build an automation to turn on the charger and notify me if the tablet battery level in HA has stayed the same for an hour.

Does the sensor usually fluctuate, at least slightly?

If so you could try a trigger like this:

trigger:
  - platform: state
    entity_id: sensor.mud_room_battery_level
    for:
      hours: 2

This should trigger if the battery level stays the same for 2 hours. Adjust the time to suit your needs.

1 Like

Thanks! I’ll give that a try.

I confirmed that this works. Thanks!

1 Like

I spoke too soon. It does work to let me know when a tablet stops charging, but it also randomly triggers. In fact, I’ve had two false triggers and each time all three automations for the different tablets triggered at the same time.

Have a look at the automation trace and see what caused it to trigger.

Well, I spoke too soon too soon! :grin:

After tracing it I realized I had the mud room tablet battery sensor as the trigger on all three tablets (darn copy & paste). And the mud room tablet did in fact lose connection and stopped reporting for 2 hours.

Thanks again!

1 Like