I’ve been working on custom component that utilized ‘tshark’ to capture packets for 10 seconds and save to a file. The file is then loaded and parsed to register a new device in home assistant.
My code was thrown together quickly and is definitely not in a state that I would share yet, but I may continue working on it for a public release during free time.
I started with a project called howmanypeoplearearound. This project may also be a good starting point for you since it seams to be closer to what you want to do (find all nearby devices) whereas I am more interested in tracking my own devices (and devices nearby my house).
One problem I found was that I was able to pick up over 30 SSIDs and over 300 clients in a small neighborhood (not even an apartment). Obviously you don’t want 300 new devices showing up in HA, so i had to find ways to filter it down to only track my devices and unknown devices that are within range of my house:
- Filter out any devices that are connecting to other peoples SSID. (I don’t want to see any of my neighbors devices that are connected to their own router.
- Ensure that MY devices (anything in known_devices.yaml) are tracked.
- Ensure that any devices that are not mine, and that are not connected to a neighbors router will get logged in the following way:
- Use RSSI to determine if the device is within range of your house.
- if not within range, ignore the device for now.
- If it is within range:
- wait for this device to be found within range on 5 different tshark scans.
- After being found 5 time (within range), report it to Home Assistant as a new device and start tracking the device in HA.
- Use RSSI to determine if the device is within range of your house.
Hope this helps you out a bit!