How quickly does IoTaWatt try to reconnect to known WiFi networks?

I had a momentary power failure last night. It lasted only a second or so but was enough for all my devices to power cycle, including the IoTaWatt and WiFi router.

All my other devices came back up and reconnected to WiFi as soon as it became available. But IoTaWatt only reconnected to WiFi more than 1 hour later. I know this because Home Assistant told me IoTaWatt status changed from “unavailable” to “turned on” at 1:22 AM (power failure at 12:18 AM) and my WiFi router says the connection time for the IoTaWatt is about 1 hour less than all my other devices.

This is no problem for IoTaWatt itself - it was able to continue logging its data, but it did have a couple of side effects in other systems.

  • No data uploaded to PVOutput during that time, and my system is configured to alert after 15 minutes of inactivity.
  • Home Assistant running automations in the middle of the night based on the changing status of its IoTaWatt sensors.

I understand that if no known WiFi network is available when the IoTaWatt powers on, it goes into AP mode so you can connect to it and reconfigure it. But I’ve seen other reports where a power failure and the relatively fast startup of IoTaWatt vs WiFi router has caused unexpected connectivity issues.

Would it be possible to have IoTaWatt re-scan for known WiFi networks more frequently when in AP mode, and immediately reconnect to a known network when it becomes available?

I’d like it to do this even if the AP itself has connected clients, because I think people’s phones or computer that were used to setup the IoTaWatt might reconnect to it after a power failure, because users will almost always not tell their devices to “forget” that network.

But I suppose the IoTaWatt could also check that any connected clients are idle (no HTTP requests to the IoTaWatt interface in 60-300s?) before reconnecting to the known WiFi network.

The captive portal configuration algorithms are in a black box called WiFi manager. I don’t mess around with it so as to not tempt the laws of unintended consequences. My experience is that changing things with the WiFi is wackamole. Solve one problem and another pops up. The automatic restart after one hour may not be the best solution for everyone, but it does work for most folks. You may be on to something with the phone auto connecting to the AP, but I think it’s more complicated than that.

A small UPS on your router could also go a long way to solve the issue.

1 Like

Is that 1 hour restart baked into the black box, or a configuration option you can change (e.g.

1 hour seems like a long time, much more than a user would actually need if they were legitimately attempting to configure the device (which is just to choose a WiFi network and restart it).

Maybe 3 or 5 minutes would be enough time for the WiFi router to come back up and the IoTaWatt to reconnect?

If it fails again, or if no existing WiFi network credentials are known, it should go to AP mode.

If we can change some config option of the black box, rather than attempting to change the black box behaviour itself, there might not be so much risk of unintended consequences?

1 Like

If your power fails often enough that this is a problem that begs a solution, I think a ups on the router is a better solution.

It doesn’t happen often at all, so I think a UPS is not worth it just for to keep WiFi up for a few seconds to work around this problem. And after a longer power outage, the UPS would also fail to keep WiFi up and the same problem would happen when power comes back.

If it is a hard fix (changing the WiFi Manager code), sure I understand that being an edge case makes it low priority. But if it’s just changing a parameter from 1 hour to 5 minutes, it seems like something worth considering.

Or if such an option is missing in WiFi Manager or not working, then opening an issue with its maintainers might be worth it. I did see a few issues that on their tracker already (assuming I got the right project) that seem to be about the same or a similar thing, but I’m not familiar enough with how IoTaWatt uses WiFi Manager internally to open such an issue myself.

What if iotawat fails to connect after one hour? will it retry in another hour or right away?

It will retry an hour later.