home-assistant-arpscan_tracker
home-assistant-arpscan_tracker copied to clipboard
How and does it work?
I installed it, added it to the configuration and restarted HA. But where do I see the results of the scan? And in terminal if I type arp-scan I get this:
The instructions do not explain how install arp-scan in the HA container. I gave up.
Back in the days the tool was installed in the default ha image. But HA developers removed everything they think didn't belong there. So I added an install command which runs when my integration is started, but it seems it does not work anymore or fails on some install types, or both. I will have a look when I have some spare time.
Thanks.
I found the install code in https://github.com/cyberjunky/home-assistant-arpscan_tracker/blob/master/custom_components/arpscan_tracker/device_tracker.py#L60
And can report it fails because the package manager it assumes to be present isn't.
# whoami
root
# apk add arp-scan
-sh: apk: not found
#
Maybe instead of subprocess.getoutput("arp-scan "+options) we could do with pure python https://pypi.org/project/arpwitch/ ?
@tomchiverton not sure, scapy and arpwitch need root permissions. What is the OS you run on, does it have another pkg manager installed?
It's running under KVM, as per https://www.home-assistant.io/installation/linux
So being root isn't an issue, I think? Output above was directly from 'virtsh console' after entering "root" at the HA login prompt
Does apt-get ... command work instead of apk? Or also not available?
No, none of these are available in HAOS.
haos has "arp" commond, can add-on use this? like "arp |grep eth0".
here is log: :/config# arp |grep ether 192.168.100.185 ether 68:ab:bc:c6:d5:8f C enp5s0 ricecooker.lan ether cc:b5:d1:12:25:61 C enp5s0 curtainlivingroom.lan ether 7c:c2:94:5d:be:34 C enp5s0 curtainbedroom.lan ether 7c:c2:94:5e:2e:44 C enp5s0 xiaoduaudiospeaker.lan ether 88:2d:53:3f:f8:cf C enp5s0 gassensor.lan ether dc:ed:83:20:d8:21 C enp5s0 172.18.0.3 ether 02:42:ac:12:00:03 C br-fe6cca2934a7 xiaomi-humidifier-p3_mi ether 64:9e:31:38:90:06 C enp5s0 172.18.0.2 ether 02:42:ac:12:00:02 C br-fe6cca2934a7 youyanji.lan ether 68:ab:bc:b6:9b:28 C enp5s0 yugang.lan ether 68:ab:bc:b5:f2:d5 C enp5s0 boardlinkremote.lan ether 34:ea:34:c7:3c:28 C enp5s0 172.17.0.2 ether 02:42:ac:11:00:02 C docker0 mideafriger.lan ether 9c:c1:2d:be:dc:86 C enp5s0 172.17.0.3 ether 02:42:ac:11:00:03 C docker0 mijiahub.lan ether 54:ef:44:47:6d:5b C enp5s0 192.168.100.240 ether b8:50:d8:56:91:d5 C enp5s0 mediaclothesdryer.lan ether 10:2c:8d:fc:e6:99 C enp5s0 washer.lan ether 88:f2:bd:7b:38:d2 C enp5s0 dreamcleanbot.lan ether 70:c9:32:08:42:8b C enp5s0 iStoreOS.lan ether 60:be:b4:04:04:ed C enp5s0 192.168.100.77 ether c0:39:37:18:31:e2 C enp5s0 fryer.lan ether 68:ab:bc:93:ac:ef C enp5s0 ax6000.lan ether 3c:cd:57:fa:d6:00 C enp5s0 computerlight.lan ether cc:b5:d1:2e:bf:d6 C enp5s0
I can not locate that command here on the latest haos
pi@pi5:~ $ sudo virsh console haos
Connected to domain 'haos'
Escape character is ^] (Ctrl + ])
homeassistant login: root
Welcome to Home Assistant OS.
Use `ha` to access the Home Assistant CLI.
# arp
-sh: arp: not found
#
Well, I just tested the docker version of homeassistant, using the docker exec -it homeassistant /bin/bash command to enter homeassistant. The two may be different.
The two are very different. As I understand it, HA under Docker is "HA Core" and doesn't support addons, for instance; https://www.home-assistant.io/installation/#advanced-installation-methods
I can confirm it no longer works. Running supervised ...
We are not talking about addons, this is an integration. There already was also an arp integration back then but it is slow, that was the reason I created the arp-scan version. I will have another look into a python only version, but it's not a matter of a search and replace.
there is an arping command in homeassistant/home-assistant
c843b3178ffd:/config# arping
BusyBox v1.37.0 (2024-11-19 21:09:16 UTC) multi-call binary.
Usage: arping [-fqbDUA] [-c CNT] [-w TIMEOUT] [-I IFACE] [-s SRC_IP] DST_IP
Send ARP requests/replies
-f Quit on first ARP reply
-q Quiet
-b Keep broadcasting, don't go unicast
-D Exit with 1 if DST_IP replies
-U Unsolicited ARP mode, update your neighbors
-A ARP answer mode, update your neighbors
-c N Stop after sending N ARP requests
-w TIMEOUT Seconds to wait for ARP reply
-I IFACE Interface to use (default eth0)
-s SRC_IP Sender IP address
DST_IP Target IP address
From the "ha" shell, that works too .
IDK if you can do that from an extension like this one.
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8131728c77c7 homeassistant/aarch64-addon-mosquitto:6.5.0 "/init" 5 days ago Up 5 days 0.0.0.0:1883-1884->1883-1884/tcp, :::1883-1884->1883-1884/tcp, 0.0.0.0:8883-8884->8883-8884/tcp, :::8883-8884->8883-8884/tcp addon_core_mosquitto
2e646aea3aa4 ghcr.io/home-assistant/aarch64-hassio-multicast:2024.03.0 "/init" 5 days ago Up 5 days hassio_multicast
941b94b6ae6c ghcr.io/home-assistant/aarch64-hassio-audio:2023.12.0 "/init" 5 days ago Up 5 days hassio_audio
3f3f439a0c3c ghcr.io/home-assistant/aarch64-hassio-dns:2024.12.0 "/init" 5 days ago Up 5 days hassio_dns
aca7ea82ec0a ghcr.io/home-assistant/aarch64-hassio-cli:2024.09.0 "/init" 5 days ago Up 5 days hassio_cli
c628f32d3c8b ghcr.io/home-assistant/aarch64-hassio-supervisor:latest "/init" 5 days ago Up 5 days hassio_supervisor
88090882d878 ghcr.io/home-assistant/qemuarm-64-homeassistant:2025.1.4 "/init" 8 days ago Up 5 days homeassistant
673715bf5095 ghcr.io/home-assistant/aarch64-hassio-observer:2023.06.0 "/usr/bin/observer" 3 months ago Up 5 days 0.0.0.0:4357->80/tcp, [::]:4357->80/tcp hassio_observer
# docker exec -it 88090882d878 /bin/bash
homeassistant:/config# arping
BusyBox v1.37.0 (2024-11-19 21:09:16 UTC) multi-call binary.
Usage: arping [-fqbDUA] [-c CNT] [-w TIMEOUT] [-I IFACE] [-s SRC_IP] DST_IP
Send ARP requests/replies
-f Quit on first ARP reply
-q Quiet
-b Keep broadcasting, don't go unicast
-D Exit with 1 if DST_IP replies
-U Unsolicited ARP mode, update your neighbors
-A ARP answer mode, update your neighbors
-c N Stop after sending N ARP requests
-w TIMEOUT Seconds to wait for ARP reply
-I IFACE Interface to use (default eth0)
-s SRC_IP Sender IP address
DST_IP Target IP address
Why do you say it does not work? I just found this integration today because I want to track devices using ARP scan, just installed it, followed the instructions and I can see in "Developer Tools" > "States all the network devices as device_trackers. Isn't this not working for you? or are you expecting or want to do something different?
Why do you say it does not work? I just found this integration today because I want to track devices using ARP scan, just installed it, followed the instructions and I can see in "Developer Tools" > "States all the network devices as device_trackers. Isn't this not working for you? or are you expecting or want to do something different?
https://github.com/cyberjunky/home-assistant-arpscan_tracker/issues/18#issuecomment-2459410442
Just installed this integration. After about an hour sniffing around and reading all sorts of manuals, I finally got it working.
@cyberjunky I strongly recommend updating the Readme.md with usage manual. Something like this:
- install HACS
- install this custom integration
- configure
- check config and restart (all good up to this point)
- login to your network router and set static IP in DHCP settings for the device you wish to track (phone for example) - not required, but recommended
- after restart go to the root folder of the HA config
- search for the file
known_devices.yaml, it will contain found devices on the network - update the records as needed (see: https://www.home-assistant.io/integrations/device_tracker/); mainly set
name: <friendly name that will appear in HA>andtrack: true - restart HA
- go to Developer tools -> States; in the filter type
device_tracker; check if devices respond as required (toggle phone's wifi on and off, if tracking the phone, wait for at least the preset time in the config file) - to set up automations, do not use Zone feature (looks okay, but does not work)
- set up automations using State feature:
triggers:
- trigger: state
entity_id:
- device_tracker.<mac address of the tracked device>
from: home
to: not_home
for:
hours: 1
minutes: 0
seconds: 0
conditions: []
actions:
- action: notify.telegram_myphone
metadata: {}
data:
message: Leaving! Bye :)
mode: single
My setup: Synology NAS -> Docker -> HA in the docker -> ARP works fine