Understang nmap

I am working on a project to detect when one of our cars is in the driveway to turn on the garage light. Regardless who is driving, so phone tracker wouldn’t work. I am looking for a simple solution (which also rules out phone trackers) and planning to put and ESP8266-01 in each car, and use nmap (or ping?) to detect when the ESP connects to the home network.

So, I put this into my .yaml file:

device_tracker:
  - platform: nmap_tracker
    hosts:
     - 192.168.1.25/24  #Steve's Phone
     - 192.168.1.34/24  #Test ESP8266
    home_interval: 10
    exclude:
     - 192.168.1.128        #Home Assistant

I told nmap to only look for my phone and my test ESP device, but when I restart Home Assistant, I am getting badges for every IP device on my home network:

So, my question is, Is this normal for nmap to discover every IP on my network?
Would ping be better?

That is an entire subnet, not a single address.

try just using 192.168.1.25

This may be of use in your project

Thanks for the link. I definitely need to do more research.
The reason for an ESP device powered by the car is so that I will know which car is approaching, and later when the logic develops, which door to open or close.

Thanks for the reply.
It still discovers every IP device on my network…
Since this is a low-priority project, I am putting it on the shelf until I get a chance to review the links that silvrr posted.

Delete all of the devices from known_devices.yaml, and restart Home Assistant. It isn’t still finding every IP, it’s just showing you the devices that have been discovered previously.

If you use nmap with an ip/24 it is scanning the entire network. device_tracker will put these devices in ‘known_devices.yaml’ and will display them no matter if they are on your network any longer or not.

Try setting up groups too. If you have groups, it won’t just spit EVERY device out on the main page. You have control over what devices are shown.

1 Like

Thanks. I never had a known_devices.yaml file before this, but that cleaned up the display.
I do use groups, but during experiments or early in development, I turn off my default_view so that I can see everything on one page.

Do you know what protocol nmap uses to know if a device is ‘home’? I unplug my ESP device so it can’t even respond to a ping, yet even after the home_interval has long passed, it’s still showing as ‘home’.

The docs suggest using home_interval to maintain battery life in the device (probably normally a phone). This makes sense if the device has to respond to something like a ping. How often is the device scanned or queried if there is no home_interval specified?

home_interval doesn’t handle the scanning. you need to add interval_seconds to your device tracker.

Thanks for all your help. I’ve cleaned up my badges and learned something about known_devices.yaml, but same question: How often is the device scanned if there is no interval_seconds parameter?

In my known_devices.yaml I have made sure that track is true and I have removed home_interval and interval_seconds, but with the ESP device unplugged, the State is still showing it at Home. Any guess why, or is this the wrong component for my purpose?

I’m not sure about that.

I would either use PING, or not use device tracker for this, and instead use MQTT from the ESP, but they don’t like being disconnected from the MQTT server, so it would take a lot of debugging to get it to a stable point.

I have’t used nmap (yet), but from reading the docs and the code, I believe it’s the consider_home parameter that is controlling when a device (that hasn’t been “seen”) will change to not_home. See details on the Device Tracker component doc page.

Couple things about NMap:

  1. Will a device show in the list if it’s currently offline when defined in nmap_tracker
  - platform: nmap_tracker
    hosts:
      - 192.168.0.200
      - 192.168.0.201

I show the 201 value but not the 200 and the 200 mac address isn’t showing yet. Assume because offline.

  1. Is there a way to rename the detection badges from mac address values to real names?