Plugin for unresponsive sensors?

I was wondering whether there is an add-on/plugin to monitor sensors and to get a notification when one of the monitored sensors isn’t sending information for a certain period.
Ofcourse I could write my own automation, however I am not the only one facing these problems, so that’s why I would like to know this!
Thanks in advance!

1 Like

Two options:

This sensor lists any devices in a group that are reported as unknown:

sensor:
  - platform: template
    sensors:
      offline_devices:
        friendly_name: "Offline Devices"
        value_template: >
          {{ expand(states.group.watchdog_devices.attributes.entity_id|list) | selectattr('state', 'in', ['unavailable', 'unknown', 'none']) | map(attribute='entity_id') | list | length }}
        entity_id: sensor.time
        attribute_templates:
          entities: >
            {{ expand(states.group.watchdog_devices.attributes.entity_id|list) | selectattr('state', 'in', ['unavailable', 'unknown', 'none']) | map(attribute='entity_id') | list | join('\n') }}

Just create and populate the group “watchdog_devices” with whatever you want to track.

The other option I use is a script / automation that reports if a device hasn’t changed its value in a configurable amount of time:

script:
  watchdog:
    alias: 'Entity Watchdog'
    # description: "Entity Watchdog"
    # fields:
    #   entity_id:
    #     description: 'The entity to check'
    #     example: 'binary_sensor.sensor'
    #   time:
    #     description: 'The max number of seconds before an alert'
    #     example: '300'
    sequence:
      - service: persistent_notification.dismiss
        data_template:
          notification_id: 'Watchdog:{{entity_id}}'
      - condition: template
        value_template: '{{ ( now()|as_timestamp() - states[entity_id].last_updated|default(0,true)|as_timestamp()|default(0,true) ) > time }}'
      - service: persistent_notification.create
        data_template: 
          title: 'Watchdog: {{ entity_id }}'
          message: >
            {%- if states[entity_id].last_updated %}
            Entity {{ entity_id }} has not been updated in {{ ( now()|as_timestamp() - states[entity_id].last_updated|default(0,true)|as_timestamp()|default(0,true) )|int }}
            seconds which is longer than the max allowed of {{ time }}.
            {%- else %}
            Entity {{ entity_id }} does not seem to exist.
            {%- endif %}
          notification_id: 'Watchdog:{{entity_id}}'

To use the script, I have an automation that runs every 5 minutes and checks each device I want to watch:

automation:
  - alias: Watchdog
    trigger:
      platform: time_pattern
      minutes: "/5"
    action:
      - service: script.watchdog
        data:
          entity_id: sensor.living_room_51_10
          time: 600
      - service: script.watchdog
        data:
          entity_id: sensor.kitchen_52_10
          time: 1200

(Extend the action section to include as many devices as you want to check.

Hope this helps.

Thanks!! That’s what I was looking for.
Would there also be the possibility to add a notification to the script when the sensor changed its value after being unresponsive?

The second option which uses the script & automation creates a persistent notification if a device is unresponsive. If the device later responds, it automatically removes the persistent notification.