mueslo / openwrt_hass_devicetracker

Simple OpenWRT package which forwards device connection changes to a HomeAssistant instance
GNU General Public License v3.0
92 stars 31 forks source link

Enhanced is_connected to avoid false positives #28

Closed fhtagnn closed 4 years ago

fhtagnn commented 5 years ago

Checking MAC addresses via iw has the disadvantage that clients are only removed after a timeout. To avoid a positive MAC check even though a device has been disconnected from all wlan interfaces the IPs (v4 & v6) associated with a MAC are found via ip neigh and a ping is issued to all IPs. After the ping disconnected MAC should be removed from the iw list and the iw check is repeated.

maciekczwa commented 5 years ago

This work much better for me.

quthla commented 5 years ago

I think the ping is not needed. It just delays the check but has no other effect.

With https://github.com/mueslo/openwrt_hass_devicetracker/pull/30 it's also working. Can you maybe try it?

fhtagnn commented 5 years ago

My first approach was to add sleep 5 as you did. However, this did not work in my case.

May be assicoated to the two wlan interfaces in my openwrt installation. Not sure. With the ping you make sure that the device is disassociated without adding a "fiddling factor" that each users has to adjust to his or her setup.

quthla commented 5 years ago

I am not sure how a ping would lead to the device being disassociated as at that time hostapd noticed already the device is disconnected and will disassociate it by itself.