Logic to tell if a device exists

How would I go about creating some logic to see if a device is currently available or not? For example, one of my Harmony hubs fell off the network and as a result, an automation wouldn’t fire that used it as a condition. I would like to setup a notification that alerts me when this device no longer exists (i.e. doesn’t even show up in states).

Thanks.

If the object doesn’t exist in Home Assistant, this template will be “true”.

 {{ states("your_device_name") == 'unknown' }}

I did some quick testing though with a WEMO receptacle. It was UP when home assistant started, so the object exists. Then, I unplugged the receptacle. H.A. obviously cannot contact the device for state updates, but the state never changes from the last known good state. So there is no way to know from the state object that the switch doesn’t exist any more.

2 Likes

You can use the device tracker component and track if the hub is home/not_home. Then setup a automation to notify you if the device switches to not_home.

My automation is here:

You can use the device tracker of your choice that can monitor a local device, nmap or ping come to mind.

Thanks. I like the device tracker idea.