Help me write a piston to turn on a zigbee light when internet is down

triggers
piston

#1

1) Give a description of the problem
My internet is very intermittent. Still working w/ my ISP to get it fixed (I also like bashing my head against a wall. Both fun things to do). Anyways, it would be very useful to have a zigbee light turn on in the living room whenever the internet is down. This would help my toddler know why Bluey stopped playing. “when the red light in the corner is on, that means Bluey might not play for a few minutes”.
Anyways, I can’t figure out how to write a piston to “check if I have internet”. I’m assuming some kind of “make GET request to the-googler.com”. But what do I do with that? Is there some kind of variable/argument that comes out of that line? How do I construct an if-statement in webcore to check for internet?

2) What is the expected behaviour?
I want to write a piston like this (pseudocode)
Timer: Every 60 seconds
if internet is down (ping google.com != success)
then Zigbee Corner Bulb, turn on, 100%, Red color
elseif internet is reachable (ping google.com == success)
then Zigbee Corner Bulb, turn off
end

3) What is happening/not happening?
Can’t figure out how to set up the piston for the internet status (the if-statement portion)

**4) Post a Green Snapshot of the piston!


5) Attach logs after turning logging level to Full

5/15/2024, 10:25:29 PM +392ms
+4ms ╔Received event [Hub8].time = 1715826329362 with a delay of 30ms, canQueue: true, calledMyself: false
+36ms ║RunTime initialize > 35 LockT > 1ms > r9T > 24ms > pistonT > 22ms (first state access 6 m:10 5 30)
+39ms ║Runtime (7290 bytes) initialized in 24ms (v0.3.114.20230828_HE)
+47ms ║╔Execution stage started
+55ms ║║scheduleTimer Requesting every schedule wake up at Wed, May 15 2024 @ 10:25:59 PM EDT (in 29916ms) for 1 (st:-1)
+62ms ║║Comparison (boolean) null is (boolean) false = true (5ms)
+63ms ║║Condition #5 evaluated true (7ms)
+65ms ║║Condition group #4 evaluated true (condition did not change) (9ms)
+70ms ║║Command optimization: Skipped execution of device command [Corner bulb].on() because it would make no change to the device. (1ms)
+99ms ║║Executed device command [Corner bulb].setColor([hex: #FF0000, hue:0, saturation:100, level:50]) (22ms)
+101ms ║║Exiting piston at end of Every timer block
+105ms ║╚Execution stage complete. (58ms)
+163ms ║Setting up scheduled job for Wed, May 15 2024 @ 10:25:59 PM EDT (in 29859ms)
+165ms ╚Event processed successfully (162ms)


#2

I cant see the first screen shot, so not sure what it is. However, I think your code in the second looks ok. It’s similar to code I have to check my internet connection.
I’m not sure pressing the test button will do what you want. Have you left the code running, then disconnected the internet to see if it works? Also could the problem be the bulb is already on, so it’s not running that code?
It’s probably worth logging a few things. I also check $httpStatusCode = 200
I also wonder if google may get upset at you “pinging” them every 30 secs, may be worth picking from a list of providers randomly.


#3

There’s also the small app called Hubitat Ping that you can install and use the presence attribute to create your piston logic.