How to detect that WiFi has off?

I run Homeassistant on a Pi4 running HAOS. It connects to the router by cable. Some other devices connect to the WiFi.

I had a situation the other day where the WiFi went off on the router (Teltonika RUT-951). A full power-cycle was required to get it back, so the various tools on the router were no use (e.g. it reboots if pings to defined addresses fail).

I’m looking for a way to detect that the WiFi has gone off so that I can have an automation cycle the router’s power using a GPIO relay.

I can’t use ping, because the router is reachable over Ethernet. If I enable the WLAN connection on the Pi, is there a way to detect that a particular WLAN has gone? Or is there another way?

So set one of those addresses to a wireless device.

Unfortunately, as I said in the OP, rebooting is not enough. I need to cycle the power.

Plug it in to a smart plug.

1 Like

So… wi-fi is down, but the router is still connected to the internet, and since HA has a wired connection to the router that is also still connected to the internet, but without access to wireless devices.

You might be able to use error messages in the log to trigger the automation - there will be a ton of those.

Isn’t it as simple as pinging a wifi connected device (that is always home) and if the ping fails, in all likelihood wifi is down, so reboot the access point.

There’s a chicken and egg problem. All the smart plugs are either WiFi or Zigbee etc. and I don’t want to introduce Zigbe just for this. If the WiFi is down, I can’t control the smart switch !

I’m currently think of a GPIO-controlled relay.

The first part is OK. I’ve added some ping entities and I can detect that several have gone offline.

Unfortunately, rebooting the router is not enough, it needs to be power-cycled to recover.

Try this:

1 Like

ping two or three things on the WLAN, if all three fail, power cycle the router (using zigbee outlet).

ok so no zigbee. If you wired lan works when your router fails, aliexpress has esp32s with ethernet ports.

1 Like

Aah, I didn’t realize that. That would be the nicest as it removes the need for the Pi to be close to the router.

You have the following independent technologies for indirect wireless communication.

  • WiFi (require AP)
  • Zigbee (Require coordinator)
  • Z-Wawe (require coordinator or what it is called in Z-wave)
  • RF (require transceiver)

Get a better access point.

Yes, but no :slight_smile:
In every other respect, the Teltonika RUT series are ideal for this environment as they are designed for embedded systems with multiple WAN technologies, including 4G - which I am using. I can find no instances in their support forums that this has occurred elsewhere, so I’m loath to chuck it out over something that may never re-occur. However, I do want to have something in place inc are it does. This “system” will be installed remotely and over 90mins from my location - I don’t want to have to visit unnecessarily.

1 Like

Sounds like you need something completely outside HA to throw the switch - something that can be triggered with a phone call maybe (sensitive territory here :shushing_face:).

https://quasarelectronics.co.uk/Category/kits-modules-telephone-activated-relay-board-switches

I actually forgot Bluetooth in the list, but you could maybe automate it a bit with a ESP that detects the WiFi failure and then cuts the power to the router, waits 30 seconds and connects it again.
This could run without an external interaction.

1 Like

Nice idea and worth examining.

I think this is probably the best solution. On my wish-list for this remote system is some sort of hardware watchdog that will be completely independent of the ‘active’ devices. This could be the best approach. Thanks.