Hello, I am trying to create an automation to detect offline devices, either due to lack of electricity, network connection or malfunction.
I have created this automation according to the documentation. The Shelly 3 device is offline but it does not notify me when it is unavailable every 30 seconds. If I try to run the automation, I receive the notification via WhatsApp, but the automation does not detect that the device is offline.
I have then modified this automation according to a similar post on this same forum. But the result is the same as above, if I run automation the message arrives but it does not detect that the device is offline
Does anyone know where I can fix the problem so that it doesn’t detect the device as offline? I think the problem is that the automation does not detect that the device is not online and that is why I do not receive the WhatsApp, since if I run the automation I receive a WhatsApp with the message
How are you testing the trigger and determining that it does not work?
A state trigger will only fire when the state changes. If your device is already unavailable at the time the automation is (re)loaded, it will never fire until the device becomes not unavailable and then goes unavailable again.
I mean, it will work, under normal conditions. It just will not fire during testing, unless the state changes from/to unavailable. You can test for that using the Developer Tools panel where you can manually override the state to something else, then back to unavailable and see if the trigger fires after X amount of time.
You can also add another trigger that fires immediately when the automation is (re)loaded and then add the state check as a condition for that trigger. But then it will also run for example when you restart the HASS server, or whenever you edit and save a different automation, as that will cause all automations to be reloaded. May or may nor make a difference, or may be annoying.