openwrt-luci-rpc icon indicating copy to clipboard operation
openwrt-luci-rpc copied to clipboard

Devices being incorrectly marked as home

Open matt-snider opened this issue 4 years ago • 7 comments

  • 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?

matt-snider avatar Mar 27 '20 15:03 matt-snider

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)

mastnym avatar Apr 19 '20 20:04 mastnym

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.

Emilv2 avatar May 21 '20 20:05 Emilv2

I have this same issue but with an android device, on luci-mod-rpc 1.1.6 and HA 0.114.4.

tiagofreire-pt avatar Sep 17 '20 10:09 tiagofreire-pt

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?

pdecat avatar Mar 21 '21 09:03 pdecat

No not fixed. Only wifi.getiwinfo works reliable for iOS in my experience.

Emilv2 avatar Mar 21 '21 11:03 Emilv2

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.

ben-64 avatar Sep 15 '21 05:09 ben-64

Hi 👋 I'd hope we can close this issue with the new release from today. The merged PR includes the fix mentioned here. Trying to get this (and other fixes for the luci component) into homeassistant here.

floriangeigl avatar Sep 11 '22 15:09 floriangeigl