Notify when a device goes offline

Hello community, is there any trigger I can use with my (already configured) pushover notification system?

I would like to receive a notification when my Yeelight bulbs or Shelly devices goes offline, but I don’t know which trigger I can use.

Thank you

You should be able to use the state trigger, as such:

- platform: state
  entity_id: light.example #Insert your Entity here
  to: unavailable

I hope that helps :slight_smile:

Thank you, but I have tons of yeelight and shelly devices and I have to do an automation for each of them. Is here any other way to check unavailability of all the devices in one automation? Like ping every 5 minutes and then notify if a specific device doesn’t reply (the ping it’s just an example :slight_smile: )

Not to sure, did a quick google and found this yaml which may help.
Unavailable Sensor Detection and Notification (

Here is a link to the thread I found it from: Sensor - Unavailable/Offline Detection - Share your Projects! - Home Assistant Community (

I personally do not detect when devices go offline, as it happens far to often, but that is do to poor WIFI which will soon be replaced with a better Access Point.

I have now Netgear Orbi RBR50 with 2 satellites and in fact I have more stable WiFi connections compared with old Asus AP. Till now I got no device offline, but just in case I would like to be prepared. Anyway, thank you for your search, I’ll try to implement an unavailable sensor

Hey there. That unavailable sensor gist is mine. I put out an updated version recently and it didn’t work well. Just wanted to make sure you try the right one - the group version. It is the one linked above. I forgot to update the gist until I saw this thread.

Anyway, you should be able to just drop the package in and go! Let me know if you have any issues.

You can use the suggestion from the second post and just add all your entities you want to track to the list, no need for ine automation per device.

E.g. from my system

# Notify on Device Offline
  - id: notify_on_device_offline
    alias: "Benachrichtigung bei Gerät offline"
    mode: parallel
      - platform: state
          - sensor.battery_level_remote_light_livingroom
          - sensor.battery_level_remote_light_dressroom
          - sensor.battery_level_remote_light_bedroom
          - sensor.battery_level_remote_light_office
          - sensor.battery_level_remote_sabrina
          - sensor.battery_level_remote_dimitri
          - binary_sensor.motion_livingroom
          - binary_sensor.motion_dressroom
          - binary_sensor.motion_bedroom
          - binary_sensor.motion_office
          - sensor.temperature_bathroomsmall
          - sensor.temperature_livingroom
          - sensor.temperature_storageroom
          - sensor.lux_outside
          - sensor.lux_office
          - binary_sensor.door_bathroomlarge
          - binary_sensor.door_bathroomsmall
          - binary_sensor.door_office
          - binary_sensor.door_bedroom
          - binary_sensor.door_dressroom
          - binary_sensor.door_storageroom
          - binary_sensor.door_kitchen
          - binary_sensor.door_livingroom
          - binary_sensor.door_main
          - binary_sensor.window_bathroomlarge
          - binary_sensor.window_office
          - binary_sensor.window_dressroom
          - binary_sensor.window_bedroom
          - binary_sensor.window_kitchen
          - binary_sensor.window_livingroom
          - binary_sensor.water_leak_bathroomsmall
          - binary_sensor.water_leak_bathroomlarge
          - binary_sensor.water_leak_kitchen
          - binary_sensor.water_leak_storageroom
        to: "unavailable"
          minutes: 5
      - service: notify.mobile_app_phone_dimitri
          title: "Device offline!"
          message: >
            📵 {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} is offline more than 5 minutes!
            channel: Notfall
            priority: high
            ttl: 0
            color: red

That’s great and simple, thank you. I added to the list all my Yeelight and Shelly devices, it works perfect!

1 Like

Where would this code go? Configuration.yml?

It’s an automation :wink:

So obviously the code goes into automations.yaml

Thank you. I’m still super green on editing the yml files vs using the GUI.

I created a more generic method. Not perfect, but better than adding each device to an automation:

  1. Create a python script “config/python_scripts/” with the following content:
# add here device ids you wan't to ignore

for state in states:
  if not state.entity_id in ignore_entities:
    if state.state == "unavailable":

if len(offline_devices) > 0:
  message = "\n".join(offline_devices)

  # in my example, i send a notification via telegram bot"notify", "max", {
    "title": "Devices offline",
    "message": message.replace("_", "\_")
  1. Create an automation that executes the script:
  alias: Notify Device offline
  description: ''
  - platform: time
    at: '18:00'
  condition: []
  - service: python_script.device_offline_notification
  mode: single

That’s not really an alternative in my opinion, because it only runs once a day, so it would be possible that your device could in the worst case be offline for almost 24 hours before you get notified. And running it every 5 minutes with a time pattern trigger would be inefficient.

For a more generic approach you can take a look at the gist posted in one of the first posts.

Depending on your needs. For me, its good enough. Some unavailable entites, like my yeelights, which currently stops working randomly (i dont know why…), are a few minutes later available again. I personally don’t want to get notified every minute … But the gist above is definitly worth looking at.

Me neither, that’s why my automation only runs if the device has been unavailable for at least 5 minutes.

Awesome. This would make a great example for a HA blueprint!