rmoesbergen / openwrt-ha-device-tracker

OpenWRT device tracker for Home Assistant that actually works
100 stars 17 forks source link

Unrealibility #46

Closed markuznw closed 1 month ago

markuznw commented 2 months ago

Hello and thanks for your work. I am using it on my zyxel ex5601-t0 on openwrt latest snapshot. I just wanted to report this happens sometimes/often

Mon Jul 8 09:35:22 2024 daemon.info presence-detector[28222]: Device 8c:7a:3d:c6:e1:b1 is now at home Mon Jul 8 09:35:22 2024 daemon.info hostapd: phy1-ap0: STA 8c:7a:3d:c6:e1:b1 IEEE 802.11: associated (aid 1) Mon Jul 8 09:35:22 2024 daemon.notice hostapd: phy1-ap0: AP-STA-CONNECTED 8c:7a:3d:c6:e1:b1 auth_alg=ft Mon Jul 8 09:35:22 2024 daemon.notice hostapd: phy0-ap0: Prune association for 8c:7a:3d:c6:e1:b1 Mon Jul 8 09:35:22 2024 daemon.notice hostapd: phy0-ap0: AP-STA-DISCONNECTED 8c:7a:3d:c6:e1:b1 Mon Jul 8 09:35:22 2024 daemon.info presence-detector[28222]: Device 8c:7a:3d:c6:e1:b1 is now away Mon Jul 8 09:35:52 2024 daemon.info hostapd: phy0-ap0: STA 8c:7a:3d:c6:e1:b1 IEEE 802.11: deauthenticated due to inactivity (timer DEAUTH/REMOVE)

The phone is connected and transmitting through wifi so I don't know what to do Even reconnecting wifi several times does not fix the issue :( Thanks in advance for any help

rmoesbergen commented 2 months ago

Hi @markuznw, from the logs I can see the device moves from one Wifi interface to another. How are your WiFi networks configured? Do both interfaces use the same SSID perhaps?

markuznw commented 2 months ago

Yes same id for 2.4 and 5ghz with 802.11r activated. I guess that's the problem, issues with roaming 😞

Even manual reconnecting the phone it usually says online, and immediately away few moments later

rmoesbergen commented 2 months ago

Yes same id for 2.4 and 5ghz with 802.11r activated. I guess that's the problem, issues with roaming 😞

Even manual reconnecting the phone it usually says online, and immediately away few moments later

Ah, right. So apparently your phone is smart and connects to the new network first, then disconnects from the old one, when roaming. This generates a join -> leave sequence which ends up with the phone being offline. Setting fallback_sync_interval to something short (like 10 seconds) in the presence-detector.settings.json will help in this case, although it will briefly go offline and then come back online. I'll have to think about how to deal with this situation, looks like this could be quite common.

rmoesbergen commented 2 months ago

@markuznw Can you give the version on this branch/PR a try?

https://github.com/rmoesbergen/openwrt-ha-device-tracker/pull/48

This takes care of devices being connected to multiple interfaces, and only sends an 'away' when it's not connected anywhere. That should solve your roaming issue. Please let me know if it works. If not, please turn on debug mode and send me the logs, thanks.

markuznw commented 2 months ago

Thank you for the super fast change! I downloaded it and I am testing now. For the moment it seems "home" for my phone survived the usual AP-STA-DISCONNECTED without being marked as away, but at the same time I find another phone that left the home and is not present on wireless luci associations page (so the router correctly deassociated it) still marked as "at home". Will test more accurately and report back :)

rmoesbergen commented 2 months ago

Hi @markuznw , I just pushed a fix to the PR that fixes devices not going into away mode when connected to both interfaces.

markuznw commented 1 month ago

Hello @rmoesbergen I am testing the last commit of the new branch and it's definitely better, seems to actually work fine! I've still some issues with my phone still kept as connected sometimes but it's something in openwrt (it shows connected with 6mbit bandwidth even with disassociate on low ack turned on and it being 2km away from that home...) so not a script fault. Thank you for the fast fix <3

rmoesbergen commented 1 month ago

Thanks for reporting back @markuznw , I'll merge the PR and make a release.