openwrt-luci-rpc
openwrt-luci-rpc copied to clipboard
Devices being incorrectly marked as home
- openwrt-luci-rpc version: v1.1.2
- OpenWRT version: 18.06.4 r7808-ef686b7292
- Python version: 3.7
- Operating System: NixOS
Description
First of all, thank you for this project! :-)
So my problem is: I'm using the home-assistant component which relies on this library to detect the presence of people to mark them as home or away. I notice that certain devices are being marked as home even though they aren't.
The relevant code in home-assistant is here:
result = self.router.get_all_connected_devices(only_reachable=True)
I have seen the note in the code about OpenWRT version >18.06:
Notes around newer OpenWrt releases (18.06+)
Do not use `reachable` or `stale` values
as they flap constantly even
when the device is inside the network.
The very existence of the mac in the results
is enough to determine the "device is home"
But looking at the RPC calls I notice that, (1) reachable appears to be set properly in the results, and (2) only_reachable
has no effect because "Flags" is never present in the device entry returned from the ARP RPC call:
if "Flags" in device_entry ...:
# ...
So due to all of this, it appears devices are only marked as away when their DHCP lease expires, which I don't think is the desired behaviour.
Am I doing something wrong here or do you have any advice on how to troubleshoot this further?
I'm having the exact same problem, but it appers to have something to do only with iOS devices. My android phone is 'away', but my wifes' iPhone is 'home' even though we were both away. Here is a same issue. I'm on version 1.12 (Homeassistant 0.107), Python 3.7. I'll investigate further, when this happens again (last couple of days it was working without any problems)
I use this custom component to fix this issue. No more iOS devices incorrectly showing up as not home. You'll need luci-app-statistics
(or rather one of its dependencies, I'm not sure which one) luci-mod-rpc
and also luci-mod-network
installed on your openwrt router to make it work.
I have this same issue but with an android device, on luci-mod-rpc 1.1.6 and HA 0.114.4.
Hi, it seems this issue was fixed on the HA side by https://github.com/home-assistant/core/pull/40160, released in 0.115.0.
I do not face the issue with my Android devices nowadays. Can anyone with an iOS device also confirm this issue is resolved for them?
No not fixed. Only wifi.getiwinfo
works reliable for iOS in my experience.
Update: with commit 9d40417, it works. However this fix is not included in homeassistant
I have also some troubles with android devices. If I force Wi-Fi disconnection, then device is correctly seen as being away. However, if the device becomes out of range, then it is never flagged as away. It remains in the arp cache entry of the openwrt router.