Using Ping in RM to toggle an outlet

My Satellite modem locks up occasionally and needs a power cycle to restore internet connection. So I got a Zigbee outlet. I see RM 5.1 has a Ping function but struggling to see how to implement it inside a conditional action.

Trigger: every 30min
Action:
if (ping 8.8.8.8 == false) // if ping failed
{turn outlet off; delay 15sec; turn outlet on;} // cycle outlet off/on

That's basically what I want to do. Anyone figure out how to do a similar thing in RM?

I have a an Outage Pinger app tied to a virtual switch, I could use that switch state in the RM action but would prefer to do it all in RM.

1 Like

This is a bit tricky to figure out, but the 2.2.9.137 release notes have the clue you'll need:

Rule 5.1: Added Ping action. This pings an IP address 3 times, and returns a string with the results. The string is in %text%. It also places the packetLoss value in %value% (100 means no response).

So, the easiest thing to do is probably something like:

Rule 5.1 with Ping, Set pingValue to %value% as integer, IF (pingValue = 100) THEN do stuff END-IF

(Be sure to create a local or hub variable; mine is called pingValue. This is necessary since you can't use the built-in %value% variable in this way without assigning it to a "real" variable first, which I'm doing like this:

)

You'll also need some trigger, which I didn't include above. A periodic trigger with whatever interval (a couple times an hour or whatever?) sounds like it might do the trick for you.

4 Likes

It works! I put in a bogus IP to test. The first IF condition is to turn it On if for some reason its Off which it shouldn't be.

7 Likes

wow. that was brilliant @bertabcd1234 !!!