Reastart router with ssh

Trying to reastart my router thru ssh. Which works fine with a command. (ssh user@ip /sbin/reboot). But the switch is either on or off, so double tap is needed if already on. I would like to “load” the switch to on if it is on (ping or something), then turn it off with the switch. And when it has rebooted, it “load” the switch at on again. So the switch is more like a pul-up button. Any ideas?

The command_line switch looks like it has an option to get the state: command_state. It sounds like it should do what you want, if you send a curl request to the host, you can grep for the host refusing the connection maybe.

1 Like

The command_line switch is the answer, I did this with my router.

The command_state: is looking for a return code of 0 for ON, so you can ether ensure the Command / script returns 0 when it is on or you can use the value_template: to detect something specific.

1 Like

Okey, a classic
curl -Is [ip]
would do the trick? With som modding with the return :slight_smile: Should get a 404, or 401 if its online.
Thanks @hborawski and @BlinkyLights