konnected-io / konnected-security

Konnected connects wired sensors and switches to SmartThings, Home Assistant, Hubitat and OpenHAB
https://konnected.io
Apache License 2.0
416 stars 322 forks source link

Konnected will continuously reboot if the network if offline, which makes it pointless to ever buy a Battery Backup. #149

Closed trooperthorn closed 3 years ago

trooperthorn commented 3 years ago

Issue: Firmware Source is written to fail when the rest of the network if offline.

What happens: Konnected Reboots every 5 minutes if either of the following occur:

With the Current Configuration, this leads disable the entire Konnected Ecosystem under the following conditions:

File: konnected-security/src/lfs/wifi.lua

Lines 15-18: -- failsafe: reboot after 5 minutes in case of extended wifi outage failsafeTimer = tmr.create() failsafeTimer:register(300000, tmr.ALARM_SINGLE, function() node.restart() end)

Line 64: sntp.sync({gw, 'time.google.com', 'pool.ntp.org'},

I block all NTP requests leaving the network to stop replay attacks. Once I created DNS records to point to my NTP Server, the connection stayed online.

heythisisnate commented 3 years ago

Thanks for the report, @trooperthorn. Yes, you are correct that the firmware is designed to reboot loop when the network is offline. The idea is that ultimately the network will come back up and the device will automatically reconnect and resume operation when that happens.

You'll notice that the first server in the NTP server list is gw (your router/gateway IP) so if you configure your router to respond to NTP, then the NTP request will never leave your network.

It's not pointless to buy a battery backup. If your network/router is also backed-up with a battery, then everything should continue working through a power outage. Our backup battery also works quite well with most consumer grade 12V routers/modems.

The failsafe reboot loop is by design, to allow for the network to recover and the device to reconnect. Did you have any other suggestions for how to mitigate a network failure?