How to check if my devices are working?

I currently have around 40 Xiaomi peripherals… door / window sensors, human presence sensors, webcam and the xiaomi gateway. In addition to activate home automation systems, I use them as anti-intrusion detection devices through AlarmSystem.
Some of the devices are connected via WiFi and others via Zigbee.
I would like to use an automation that detects when any of these sensors or cameras is not active (because for example it has failed or has drained the battery) or if Xiaomi Gateway does not work or disconnected … and sends me a notification.
How can I do it? Has anyone already used a practical and functional system?

I use the following automation to send a notification if any of my Yeelights go ‘unavailable’ which happens if someone turns the light switch off.

alias: Notify if light unavailable
initial_state: 'on'
trigger:
  - platform: state
    entity_id: light.bedroom_lamp, light.couch_light, light.dining_table_light, light.living_room_light, light.walkin_robe_light
    to: 'unavailable'
    for:
      seconds: 22
action:
  - service: notify.Pushbullet
    data_template:
      message: >
        '{{ trigger.from_state.attributes.friendly_name }} has gone unavailable'

I had to include the for: timer to prevent false triggers.

I also have one to create a TTS to a Google Home, which I know could have been combined, but this allows me to easily turn the TTS off.

 alias: TTS if light unavailable
initial_state: 'on'
trigger:
  - platform: state
    entity_id: light.bedroom_lamp, light.couch_light, light.dining_table_light, light.living_room_light, light.walkin_robe_light
    to: 'unavailable'
    for:
      seconds: 20
action:
  - service: tts.google_say
    entity_id: media_player.kitchen
    data_template:
      message: >
        '{{ trigger.from_state.attributes.friendly_name }} has gone unavailable, please switch back on as it is an automated light'
1 Like

for yeelights and TTS is more simple becouse they have the state “unavailable”.
for zigbee sensor like door/window or human presence sensor it is more difficult.
In https://www.home-assistant.io/components/binary_sensor.xiaomi_aqara/ I see thath they state could be only…ON or OFF

Could I use the generic class… connectivity?
connectivity: “ON” means connected and “OFF” means disconnected

I have xiaomi zigbee sensors which go to “unavailable” state once in a while. So I think you should be able to trigger on that.

I’d like to do the same for my Xiaomi Aqara motion sensor, it fell off the outdoor wall it was on, disappeared somewhere on the street, and I only found out several days after.

I have the exact same issue. So if anyone have a solution !!!
Thanks a lot.