Hi all,
Short version: is there an easy way I can do an automation inside ESPhome that will ping an IP address and then do something if there’s no response?
Long version: So I have this IP camera on a backup battery, in an area that suffers frequent outage. When power goes out, it runs off battery, but, if the battery drops below 12V, then the camera crashes, and won’t reboot when the power comes back.
To solve this, I’ve used a little ESP-01 module on a pre-made relay board (the horrible kind that you have to solder and pop off a resister to get the thing to work). I chose this module because a) I had one lying around, and b) it has NC/NO contacts, unlike a Sonoff. That means I can run the 12V the camera needs through the NC contacts, and the relay need only engage to reset the camera, so there’s very little chance of the relay getting stuck.
Now, it works great, but, after a series of SNAFUs around the 1.14.3 upgrade, I am looking at moving certain automation functionality out of HA and into the ESPHome nodes themselves. That way, things will run as they should even if contact between the node and the hub is lost.
So, I had Node-RED pinging the camera every 5 mins to see if it was live, and triggering the relay if it wasn’t. That works, but it presupposes that there’s a good wifi connection. In reality, there might be a million reasons why wifi is currently unavailable.
Therefore, I’d like to move the ping code into the ESPHome node somehow. I read the docs and I don’t think it’s actually possible. I saw something I didn’t understand about ICMP pings, but, it’s over my head.
Can anyone assist with a code example? I’m assuming this will actually have to be a lambda or something. I dunno. I searched this forum but didn’t see something I thought would work.