Ihost automation, that checks if there is internet access

Hi

I would like to make an automation for my ihost where i check if there is internet access, and if there is not, I would like to cut the routers power and turn it back on 10 sec. later.

Idea of logic:
Create a “simulated” smart device called internet checker (like a switch)
Have it Ping Google server every 30 sec.
If ping is success full set the switch to “on” of the ping is unsuccessfull set it to “off”

Would this be possible to create?

Or can I do it without making something custom?

you can try to set up a Flow using Node-Red

A flow in Node Red i think is the best solution.