cyberjunky / home-assistant-arpscan_tracker

This component tracks devices using the arp-scan liinux command, it's very fast, and reasonably accurate.
MIT License
28 stars 4 forks source link

Apr-Scan not working in newest release (1.0.4) #5

Closed DeadEnded closed 3 years ago

DeadEnded commented 3 years ago

ARP Scan device tracker is not working for me in the latest release. I have done some basic troubleshooting and it appears that in 1.0.4 it is excluding all devices. 1.0.3 is still functioning so I have rolled back.

Here is a debug of 1.0.3 (working example with IP and MAC removed):

2020-12-28 09:24:49 DEBUG (SyncWorker_13) [custom_components.arpscan_tracker.device_tracker] Scanning...
2020-12-28 09:24:51 DEBUG (SyncWorker_13) [custom_components.arpscan_tracker.device_tracker] Scandata Interface: enp8s0, type: EN10MB, MAC: <hostMAC>, IPv4: <hostIP>
WARNING: host part of <hostIP> is non-zero
Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan)
<ip1> <mac1> NETGEAR
<ip2> <mac2> Hon Hai Precision Ind. Co.,Ltd.
<ip3> <mac3> (Unknown)
<ip4> <mac4> (Unknown)
<ip5> <mac5> LG Electronics (Mobile Communications)
<ip6> <mac6> LG Electronics (Mobile Communications)
36 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.7: 256 hosts scanned in 1.980 seconds (129.29 hosts/sec). 6 responded
2020-12-28 09:24:51 DEBUG (SyncWorker_13) [custom_components.arpscan_tracker.device_tracker] Arpscan successful
2020-12-28 09:24:51 DEBUG (SyncWorker_13) [custom_components.arpscan_tracker.device_tracker] Scanner initialized
2020-12-28 09:24:51 DEBUG (SyncWorker_14) [custom_components.arpscan_tracker.device_tracker] arpscan last results [Device(mac='enp8s0,', name='enp8s0,', ip='Interface:', last_update=datetime.datetime(2020, 12, 28, 9, 24, 51, 124516, tzinfo=<DstTzInfo 'America/Kentucky/Louisville' EST-1 day, 19:00:00 STD>)), Device(mac='host', name='host', ip='WARNING:', last_update=datetime.datetime(2020, 12, 28, 9, 24, 51, 124516, tzinfo=<DstTzInfo 'America/Kentucky/Louisville' EST-1 day, 19:00:00 STD>)), Device(mac=<hostMAC>, name='XXXX', ip='<hostIP>', last_update=datetime.datetime(2020, 12, 28, 9, 24, 51, 124516, tzinfo=<DstTzInfo 'America/Kentucky/Louisville' EST-1 day, 19:00:00 STD>)), Device(mac='XXXX', name='XXXX', ip='XXXX', last_update=datetime.datetime(2020, 12, 28, 9, 24, 51, 124516, tzinfo=<DstTzInfo 'America/Kentucky/Louisville' EST-1 day, 19:00:00 STD>)), Device(mac='XXXX', name='XXXX', ip='XXXX', last_update=datetime.datetime(2020, 12, 28, 9, 24, 51, 124516, tzinfo=<DstTzInfo 'America/Kentucky/Louisville' EST-1 day, 19:00:00 STD>)), Device(mac='XXXX', name='XXXX', ip='XXXX', last_update=datetime.datetime(2020, 12, 28, 9, 24, 51, 124516, tzinfo=<DstTzInfo 'America/Kentucky/Louisville' EST-1 day, 19:00:00 STD>)), Device(mac='XXXX', name='XXXX', ip='XXXX', last_update=datetime.datetime(2020, 12, 28, 9, 24, 51, 124516, tzinfo=<DstTzInfo 'America/Kentucky/Louisville' EST-1 day, 19:00:00 STD>)), Device(mac='XXXX', name='XXXX', ip='XXXX', last_update=datetime.datetime(2020, 12, 28, 9, 24, 51, 124516, tzinfo=<DstTzInfo 'America/Kentucky/Louisville' EST-1 day, 19:00:00 STD>))]

After updating to 1.0.4:

2020-12-28 09:17:20 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Scanning...
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Scandata Interface: enp8s0, type: EN10MB, MAC: <hostMAC>, IPv4: <hostIP>
WARNING: host part of <hostIP> is non-zero
Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan)
<ip1> <mac1> NETGEAR
<ip2> <mac2> Hon Hai Precision Ind. Co.,Ltd.
<ip3> <mac3> (Unknown)
<ip4> <mac4> (Unknown)
<ip5> <mac5> LG Electronics (Mobile Communications)
<ip6> <mac6> LG Electronics (Mobile Communications)
22 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.7: 256 hosts scanned in 1.959 seconds (130.68 hosts/sec). 6 responded
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Excluded Interface:
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Excluded WARNING:
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Excluded <ip1>
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Excluded <ip2>
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Excluded <ip3>
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Excluded <ip4>
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Excluded <ip5>
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Excluded <ip6>
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Arpscan successful
2020-12-28 09:17:22 DEBUG (SyncWorker_9) [custom_components.arpscan_tracker.device_tracker] Scanner initialized
2020-12-28 09:17:22 DEBUG (SyncWorker_4) [custom_components.arpscan_tracker.device_tracker] arpscan last results []

Here is my configuration.yaml entry:

# Enable Device Tracking
device_tracker:
  - platform: arpscan_tracker
    interval_seconds: 60
    consider_home: 60
    track_new_devices: true
    scan_options: " --interface=enp8s0 10.11.12.201/24 -g"
    exclude:
      - <list of IP's to be excluded - works in 1.0.3>

The IP's in the debug of 1.0.4 are the IP's of the devices that were correctly being tracked in 1.0.3. The exclude IP's from configuration.yaml are not appearing at all, which is fine - they aren't suppose to be tracked anyway.

I believe the problem is with the new include parameter. If you do NOT have it, the code is excluding everything (that is my guess).

Here is the code I think that is causing it:

if not ipv4 in include_hosts:
    _LOGGER.debug("Excluded %s", ipv4)
    continue

Since I do not have an include_hosts, it is actually excluding everything. There needs to be a check before this to see if the include hosts is empty, and if so, skip this. I will dig into this (I'm novice) and see if I can find the cause.

Cheers! DeadEnd

cyberjunky commented 3 years ago

@DeadEnded Is this fixed with 1.0.5?

DeadEnded commented 3 years ago

yes, sorry - forgot to close. Thanks!