Device_tracker - DHCP push rather than poll

Hi All,

    I'm evaluating several options to provide states to device_tracker, NMAP and the services that poll DHCP tables are OK, but I'd prefer to have the data 'instantly' after the device comes on the network.

    I'm using ISC DHCP to handle DHCP and some DNS updates. ISC DHCP has the ability to run a script on commit, lease release, and lease expiry. [Example of DHCP script execution](http://jpmens.net/2011/07/06/execute-a-script-when-isc-dhcp-hands-out-a-new-lease/) 

     Having the script set the state to home through an API call functions. I'm wondering if anyone has played with this manner of updating the state or if there's a smoother route I should be taking. For instance, all of the attributes will be dumped as soon as the script sets the state to home if they're not included w/ the update.

Thank you,
Mike

how “instant” are you looking for, and instant from what event? I’m not trying to be difficult sorry if it sounds that way, but when you get home, your iphone has to be awake, it has to negotiate with wifi and agree on a IP address with your DHCP server. So if you are looking at your network for device_tracking, it’s not going to be instant. I will not give you what you want if you are wanting something to turn on the lights when you are a mile away turning the corner. It just doesn’t have the range. I’m using Nmap on my network to track when someone gets home, and it’s pretty quick. Granted, I’m only searching for 4 devices by their IP addresses. So I’m not scanning an entire subnet. How many devices are you interested in and what type of event do you want to trigger as a result of their coming/leaving home?

How do you do this?

I see only to exclude, not to include few IPs

you can check for specific addresses or ranges. The excludes are when you are doing a large range and want to exclude your servers or something like that. I reserve these IP addresses for each phone by using a mac address reservation in my DHCP server (in my case in y router). That way any time that MAC address tries to connect to the network, it will always get the same address from DHCP.
Once they are home, I cut way back on the checks for them to once every 10 minutes when they are home to avoid running down their phone batteries. The consider_home helps prevent false away states when nmap times out occasionally. I was getting timeouts at 180 (3 minutes), but it’s been stable at 200 seconds.

  - platform: nmap_tracker
    home_interval: 10
    consider_home: 200
    hosts: 
      - 192.168.2.120
      - 192.168.2.121
      - 192.168.2.122
      - 192.168.2.124

Hi turboc,

 Your name reminds me of Borland. Fond memories. I think I wore out my F9 button back in the day.

 I understand there is a delay w/ negotiating a connection and being issued an address. NMAP can have its interval shortened.  For me, I'd rather have the positive, at that moment, update than continually poll. Not sure what you meant by "I will not give you what you want..." The solution already works. I'm asking if anyone has worked w/ DHCP pushes rather than polling so that I could check out how they did things. I'm new this week to Home Assistant. I'm sure there are things I didn't think about or come across yet. Your tip about cutting back the interval when the device home is pretty sweet. That's the type of stuff I'm looking for. I appreciate you sharing it.

 In addition to locks/lights/throttling back Transmission, this is fun for having bonfires. An XAP800 distributes sound to a few rooms inside, the patio, shed, and horseshoe pit. When friends arrive, their , chosen by me, "theme song" is played or an announcement is made. It's humorous to throw out a "Barbie Girl", "I'm too sexy", or an inside joke occasionally to stir the pot. This works because I have alternate SSIDs setup that most of my friends and family are already setup to connect to. Before they get out of their truck, they unplug the phone, and it wakes up and grabs an address.

Thank you,
Mike

Actually the name was given to me by a friend, it’s actually Turbo Chip (386), so that’s how far back it goes. I like the idea of the walk up song. That’s cool.
So you want to use a push from the dhcp server to show arrival, how are you handling departure?

https://www.reddit.com/r/homeassistant/comments/641rwm/presence_detection_with_dhcp_and_mqtt/ details how to do this with ISC DHCP and DDNS updates using a call out to a script to push MQTT notifications.

Cheers, Steve