Nmap marks me as always home, regardless of whether I am?

Hi all. I’ve migrated my home assistant from a Synology NAS to a Raspberry Pi, however, something is wrong with nmap presence detection. I set it up to scan for devices, toggled off the ones I didn’t want in the known_devices.yaml

The entry for my phone is the only one tagged to track, and it’s MAC address is correct. This set up worked perfectly on my synology, though for some reason on this install on the Pi my phone is always “at home”, even when I turn off wifi and restart… Running nmap ipaddress on command line does detect correctly whether that device is on the network at the time… Just home assistant always things I’m home?

device_tracker:

  • platform: nmap_tracker
    scan_options: " --privileged -sP " // tried adding this in to see if it would help, hasn’t
    hosts: 192.168.0.0/24
    home_interval: 10
    track_new_devices: no

Example configuration.yaml entry

known_devices.yaml
android-4_______:
hide_if_away: false
mac: C0:AA:FB:AA:3B:AA
name: android-4_______
picture:
track: true
vendor: OnePlus Tech (Shenzhen) Ltd

Anyone got any ideas?

1 Like

Maybe try adding interval_seconds: 10 or whatever number you want to play with. That will be the number of seconds between scans.

Described here with other device tracker options:

if you can group your allocated IP address and only scan for them , rather than the full range (ie 255) that will help too

or pick you devices you want to scan and allocate them a fixed ip address and only scan for those IP address.
I have only 5 devices that i want to determine if the are ‘home’ , so i only scan for 5 fixed ip address (hosts)

Hi, thanks for reply.

As you can see from my config above, I have home interval set to 10, and am scanning only a small portion of the network. These same settings worked perfectly on the different platform (synology). Something seems to be going wrong as when turning off my phone’s WiFi and rebooting everything, home assistant boots up and says my phone is at home, even though it is not on my network…

I do have a static IP set up for my phone - how do you define a user by IP in nmap? It seems to work by Mac address?

Thanks again

@whatever You can do it this way:

  - platform: nmap_tracker
    hosts: 
    - 192.168.1.92
    - 192.168.1.27
    - 192.168.1.69
    consider_home: 300
    track_new_devices: yes
    home_interval: 10

I would suggest using the ping presence detection, not least because it uses far less cpu.

Hey.

So I’ve set it up to only scan the particular IP address:

device_tracker:

  • platform: nmap_tracker
    hosts:
    • 192.168.0.6
      home_interval: 10
      track_new_devices: no

Although the problem is the same as before. Even though that IP address is not connected to the network and running:
nmap 192.168.0.6

Starting Nmap 6.47 ( http://nmap.org ) at 2017-02-28 15:32 GMT
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 3.19 seconds

Shows that it shouldn’t be marked as “HOME” based off an nmap ping. However, according to home assistant, it is always “HOME”, regardless of whether it is or isn’t, breaking my automations. I had this working perfectly on a synology, the only thing that’s changed is that now it’s running from Raspbian and the All In One installer…

Would hugely appreciate some guidance, thanks for reading.

Good morning everyone,

any news on this topic?
Have the same issue with nmap or/and icmp ping.
Already disabled nmap and only scan for devices via ping, but the issue described in this thread is still present.

Home-Assistant is running in a docker container with --net=host

Snipped of my ping config:

- platform: ping
  count: 5
  hosts:
    workhomelan: 192.168.0.80

Snipped of my known_devices:

workhomelan:
  hide_if_away: true
  mac: FC:15:CC:06:CC:F9
  name: Work LAN
  picture:
  track: true
  vendor: Hewlett Packard

I can manually ping or nmap this device and it is not responding. Not a wonder, because it is turned off and unplugged laptop in my bag :slight_smile: .
But home-assistant is reporting this device as “home”.
This is only one of several devices with this issue.

Also the description for “count” in Ping is a little rare.
What does it mean “packet used for each device”? Is Ping sending 5 packets to every device and if its not getting 100% positiv reply, it assumes the host as “not_home”?
Or is it sending 5 packets:

  • 3 positive, 2 negative = home
  • 2 positive, 3 negative = not_home
    How often is Ping sending packets and could this be configured?

I am still struggeling with this two platforms since 2 weeks now and excuse me, but it is a little disapointing that such fundamental and “easy” thing like presence detection with a ping is that less documented.

Trying to switch from openhab which is running on the same host, perfectly. Also with ping as presence detection.

Like @whatever , I would be very thankful for any advice :slight_smile:

Hi, I should have updated this post but forgot.

I’m not sure exactly what I did, but after deleting the known devices yaml and recreating it a few times it just started working for me. It would seem in my case it had something to do with that file.

Hope that helps.

Hi,

thanks for your reply. Gave it a shot, but only solved it temporarily.
I deleted known_devices and the db, so it was fresh an new created.
As soon as I plugged in my work laptop, it was discovered. But after disconnecting, it stays “home” :unamused:

I am using mysql as db backend.
Will try the steps again, using db standard hass config and let you know if that changed anything.

As I observed the same, deleting the know_devices.yaml worked for me, too.
Since two weeks the nmap_tracker works without any issue.

Hey,

I tried around so much! In the end it looks like I solved it for my setup.
First, delete known_devices.yaml was not enough in my case. I have also configured the recorder with a mysql db, which also has to been dropped and let hass recreate it.

Also, the standard nmap an ping parameters seem to not work for me. Now I have a mixture of both in my config:

- platform: nmap_tracker
  interval_seconds: 60
  consider_home: 180
  scan_options: " -sP --host-timeout 10s"
  hosts: 192.168.0.1/24

- platform: ping
  interval_seconds: 60
  consider_home: 180
  hosts:
    router: 192.168.0.1
    ...

This is all for docker environment.
Have no unused Pi2 or 3 to test it in that scenario.
But if it stays like this and work like a charm, openhab and java is history for me :-).
Only thing missing in hass is FHT and/or Busware CUL433/868Mhz support.

Thanks for your help

I have the same problem with snmp. Some devices always remain ‘Home’ after a day or two. If i delete know_devices.yaml it works for a couple of days again. If I remove tracking from my config, reboot, add tracking and reboot a second time, it works for a couple of days without removing known devices.

I’m on 0.56.2

Hi can someone help, I am running Hassio ver 0.57.2 on PiZero with below nmap options but causing it to hang after few minutes, at present tracking only 2 iPhones and 3 Android phones
configuration.yaml entry
device_tracker:
- platform: nmap_tracker
hosts: 192.168.0.1/24
track_new_devices: no
home_interval: 15
exclude:
- 192.168.0.201
- 192.168.0.202
- ***.***.***.***
I also need help to place custom icons of family members, can someone help where to place these png files in Hassio environment. I tried placing it under config directory and placing icon: /config/name.png in customization.yaml but doesn’t work.

i know it’s a little late, but for pictures you need to place them in the www/ directory of your HA installation and reference them via local/image.ext inside of known_devices.yaml. Use the ‘picture’ property.

Thanks for your response, there are some other references where people spoke about the file size, not sure if that is the problem. I tried the way you suggested, did not work and the same was posted under another case below:

May I ask how you control the same device with these two different platforms? Cause with nmap_tracker we’re keeping track of the device with the MAC Address and with the ping we’re keeping track of the device with the Static IP.

So say I’d like to track the state of the device… Won’t there be 2 different representations for only one device?

Sorry if this sounds silly, I’m new to the Hass.io.

Thanks a lot!

After playing around a little bit more I realized it is just a matter of editing the known_devices file and unify the 2 devices that appear as separate. :slight_smile: