nitaybz / homebridge-network-presence

Homebridge plugin that provides occupancy sensor for devices presence in your network
MIT License
43 stars 7 forks source link

Allow device discovery via hostname + speed up discovery #12

Closed alexh-name closed 3 years ago

alexh-name commented 3 years ago

Hi! I managed to add discovery via hostname + optionally speeding up discovery by defining the address range completely within the the already used local-devices dependency. Hope this PR finds you well.

alexh-name commented 3 years ago

I found that iOS devices started changing their MAC address as a privacy feature, so I needed to discover them via their advertised hostname.

Also possibly a fix for issues https://github.com/nitaybz/homebridge-network-presence/issues/4, https://github.com/nitaybz/homebridge-network-presence/issues/10 and https://github.com/nitaybz/homebridge-network-presence/issues/11, because on networks with large arp tables the find() function might time out before all reverse lookups are done. I think on those networks you need to specify an address range or somehow drop the reverse lookup entirely. Last solution would be the most performant if discovery by hostname is to be discarded, because then the reverse lookups are not used anyway.

However, I think this PR might be a good compromise between both. I'm not sure if local-devices has an option to disable reverse lookups.

nitaybz commented 3 years ago

I'm planning to add a feature "onlyPing" which will allow to set up devices by IP only, and save the entire lookup process.... that would at least compare the plugin to other outdated plugins.

anyway, your PR is greatly appreciated and seems solid. I'll merge it now