WTH: why can't I easily see which devices/sensors are not working?

Sometimes my Zigbee or WiFi is malfunctioning, batteries are low, USB stick got disconnected or an online service stops working (thank you lufdaten!) Why can’t HA profile ‘healthy’ sensors and determine their normal behaviour (gas usage reports every hour, temperature roughly every 5 minutes, etc.) and notify me on irregularities. Too often it takes me days or even weeks to notice some sensor is not working.

Something like this?

type: 'custom:auto-entities'
card:
  type: entities
  title: Last Seen
  show_header_toggle: false
filter:
  include:
    - name: /linkquality/
      options:
        secondary_info: last-changed
sort:
  method: last_updated
  reverse: true

type: 'custom:auto-entities'
card:
  type: entities
  title: Link Quality
  show_header_toggle: false
filter:
  include:
    - name: /linkquality/
      options:
        secondary_info: last-changed
sort:
  method: state
  numeric: true

type: 'custom:auto-entities'
card:
  type: entities
  title: Battery
  show_header_toggle: false
filter:
  include:
    - entity_id: '*battery'
      options:
        secondary_info: last-changed
      not:
        domain: automation
sort:
  method: state
  numeric: true

And an automation that notifies me:

- id: '1579893997207'
  alias: Zigbee Drop Notification
  description: ''
  trigger:
  - at: '18:00:30'
    platform: time
  - at: '6:58:24'
    platform: time
  condition:
  - condition: template
    value_template: "    {%- macro GetDroppedZigbee() -%}\n    {% for state in states.sensor\
      \ -%}\n      {%- if state.attributes.linkquality %}\n        {%- if \"Ikea\"\
      \ not in state.name and \"linkquality\" in state.name and (state.attributes.linkquality\
      \ < 15 or (as_timestamp(now()) - as_timestamp(state.last_updated) > (12 * 60\
      \ * 60) )) -%}\n         X \n        {%- endif -%}\n      {%- endif -%}\n  \
      \  {%- endfor %}\n    {%- endmacro -%}\n\n    {%- if GetDroppedZigbee()[0] ==\
      \ \"X\" -%}\n    true\n    {%- else -%}\n    false\n    {%- endif -%}"
  action:
  - data:
      message: "Some devices haven't been seen lately or have low lqi... {% for state\
        \ in states.sensor -%}\n  {%- if state.attributes.linkquality %}\n    {%-\
        \ if \"Ikea\" not in state.name and \"linkquality\" in state.name and (state.attributes.linkquality\
        \ < 15 or (as_timestamp(now()) - as_timestamp(state.last_updated) > (12 *\
        \ 60 * 60) )) %}\n      {{ relative_time(state.last_updated) }} ago for {{\
        \ state.name | lower }} ({{state.attributes.linkquality}} lqi)\n    {%- endif\
        \ -%}\n  {%- endif -%}\n{%- endfor %}\n"
    service: notify.mobile_app_phone
8 Likes

Very good! Didn’t know about the last-changed option.

You could also consider hiding the “good” entities and only showing the ones that need attention to clean things up a bit. E.g. for my battery sensors I have it filtering on lower than 5% remaining which cleans up the overview a lot.

- entity_id: '*_battery'
  state: < 5
1 Like

thank you for your example… this will certainly help. Doesn’t cover my frustration completely. Some integrations or sensors are allowed to only report daily, while others (e.g. electricity) are supposed to trigger every 10s. Now I have to visually inspect my sensors (and there are many) and assess if they are working correctly. That is not do-able.

In config -> entities, click on the status column to sort by status and it will highlight all entities that are either unavailable as reported by the integration or unavailable because they are not currently provided by any integration:

1 Like

That’s great! Thanks! However, are you sure the condition in the automation works properly?
I copied paste, by removing the ikea test and it also go through the condition even though the macro does not return anythin…

The condition I typed in:

    {%- macro GetDroppedZigbee() -%}
    {% for state in states.sensor -%}
      {%- if state.attributes.linkquality %}
        {%- if  "linkquality" in state.name and (state.attributes.linkquality < 15 or (as_timestamp(now()) - as_timestamp(state.last_updated) > (12 * 60 * 60) )) -%}
         X 
        {%- endif -%}
      {%- endif -%}
    {%- endfor %}
    {%- endmacro -%}

    {%- if GetDroppedZigbee()[0] == "X" -%}
    true
    {%- else -%}
    false
    {%- endif -%}

Have you tried it in the dev tools and see what the outcome is? Try testing it there
For me it works flawlessly.