AlexxIT / SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
https://github.com/AlexxIT/Blog
MIT License
2.58k stars 405 forks source link

RFbridge doesnt update alarm sensor when disconnected from Internet (local) #1379

Open zd3sf opened 2 months ago

zd3sf commented 2 months ago

RFbridge 2, firmware 3.5.2. integration (in Local or Auto). with Internet access for the bridge denied from the router, the buttons keep working but the window sensor doesn't update. I found that the bridge bridge connects to this IP (13.56.143.44) even with pihole block, and it stays online in the ewelink app. Interestingly, if I allow internet access then pull the WAN cord out after the bridge initialized, the sensors keep working.

I am thinking that the bridge uses the connection to 13.56.143.44 to pull the clock time because the sensor triggers need "last triggered" which needs the clock on the bridge to be correct. What if we spoof this IP address and redirect it to a local NTP server? It wouldn't be this easy because this IP is not only n NTP but is also the connection to ewelink. But if anyone can figure how supply the time clock to sonoff devices without ewelink, that would be awesome... potentially solve all issues with sensors not working in local mode.

image

AlexxIT commented 2 months ago

https://github.com/AlexxIT/SonoffLAN?tab=readme-ov-file#issues

zd3sf commented 2 months ago

There's nothing in the logs that would be helpful. This a problem between the bridge and the server. This is more a development suggestion sorry

AlexxIT commented 2 months ago

Without device and any debug info I can't do anything

zd3sf commented 2 months ago

home-assistant_sonoff_2024-04-13T15-12-22.530Z.log config_entry-sonoff-af35e4956ec234642bc36eb0ae423546.json Sorry here you go

AlexxIT commented 2 months ago

I can see local updates in your logs. You don't have them when there's no internet?

2024-04-13 10:12:17.263 DEBUG (MainThread) [custom_components.sonoff.core.ewelink] 100205192c <= Local3 | 192.168.2.175:8081 | {'sledOnline': 'on', 'arming': True, 'rfTrig9': '2024-04-13T14:58:59.000Z', 'ssid': 'TP-LINK_E8A8', 'bssid': '8c:3b:ad:0f:8b:99'} | 682
2024-04-13 10:12:18.083 DEBUG (MainThread) [custom_components.sonoff.core.ewelink] 100205192c <= Local3 | 192.168.2.175:8081 | {'sledOnline': 'on', 'arming': True, 'rfTrig9': '2024-04-13T14:58:59.000Z', 'ssid': 'TP-LINK_E8A8', 'bssid': '8c:3b:ad:0f:8b:99'} | 682
zd3sf commented 2 months ago

With no internet, pushing a button works in both homeassistant and ewelink app. But sensor status doesn't update also in both ewelink and homeassistant.
home-assistant_sonoff_2024-04-13T15-54-10.296Z-no internet.log

I can see the orange light on the bridge flash when I trigger the window alarm (open or close) but it doesnt update the 'last triggered' or current status in ewwelink or homeassistant

AlexxIT commented 2 months ago

Yes. Same TS will be skipped. I don't know if it safe to remove this check. Then another check would have to be made for local+cloud messages.

https://github.com/AlexxIT/SonoffLAN/blob/08070c312b52d877ffdfb31c73b91d696def4926/custom_components/sonoff/remote.py#L128-L130

AlexxIT commented 2 months ago

I don't know how to fix this on the component side. Disabling the date check doesn't seem to be safe. You can also see that the message counter on the device side doesn't increase.

zd3sf commented 2 months ago

Pulling the WAN cable out the router while everything else is connected, the RF bridge continue to work normally for 2-3 minutes. Then it misbehaves