Weird device_tracker requirement

I have a unique case. I need to run a automation immidialaty when I come back home (think opening garage door). Currently, to detect when I am back home I use multiple trackers, (nmap, gps, haas app and asuswrt integrations) which are connected to my person entity. However all of these trackers have a lag. sometimes it takes them 3-4 minutes to detect I am home. Obviously that is not ‘immediate’. One option is to reduce the scan frequency on these trackers, but that will waste of network traffic most of the time (since i don’t switch my location so often).

Alternate option I am considering is using node-red to listen to UDP ARP packets when my phone connects to wifi. That happens almost in matter of seconds which is close enough for my ‘immediate’ requirement.

For that, I setup a UDP listener and read mac address from ARP packet in node-red. That works great and I can almost immediately see it trigger as soon as my phone connects to wifi.

Now in node-red using above UDP trigger, I tried using device_tracker.see service to update one of my existing trackers (nmap tracker) and set it’s state to ‘home’. Service executes fine (with no error) but that doesn’t seem to be working and state doesn’t change. Then I read that device trackers are read only (shouldn’t service call throw an error in that case ? but i digress).

My questions :

  1. Do I need to create a custom device tracker to use device_tracker.see service ? Are there any posts which describe what is ‘current’ way (known devices yaml seems to be deprecated) to create a custom tracker.
  2. If I do create custom tracker, wouldn’t that cause problem since it will always be ‘home’ because there is no service call to flip it to ‘not_home’ (I don’t care about not_home state change since my automation will only run when i get back home). I just want my ‘person’ entity to switch from not_home->home state using this tracker but not other way around. Can custom tracker automatically mark state to stale after predefined time ? Or another ugly option would be to set a timer in node-red to flip the state from ‘home’->‘not_home’ after 10 or 15 minutes when ‘not_home’->‘home’ switch happens. Since other trackers like nmap/router/gps will catchup by then, my person entity will still show correct status.

Any thoughts ?

  1. Known devices is still working, it’s just not used by most integrations anymore. One other option is to use an MQTT Device Tracker.

  2. You will need to set the tracker to not_home in order for there to be a state change to trigger your automation. If you have other trackers that are reliable for not_home use them to automate the change.

Thanks will look into ‘MQTT Device tracker’.

If you have other trackers that are reliable for not_home use them to automate the change.

Is it possible for me to change the state of new ‘MQTT device tracker’ to get updated when my regular nmap tracker turns to ‘not_home’ (but only at the event when nmap tracker turns from home->not home, not continuously)

Yes, you would create an automation with a State trigger that listens specifically for the change of the nmap sensor from home to not_home then as the action you call the mqtt.publish action.

i tried creating a mqtt device tracker in configuration.xml, but getting a weird error…

I already have mqtt sensors.

mqtt:
  sensor:
    - name: "Honda"
      unique_id : "car"
      enabled_by_default: true
      state_topic: "car/honda"
      unit_of_measurement: "miles"
      value_template: "{{ value_json.odometer }}"
      json_attributes_topic: "car/honda"

now when I add a device tracker like

mqtt:
  sensor:
    - name: "Honda"
      unique_id : "car"
      enabled_by_default: true
      state_topic: "car/honda"
      unit_of_measurement: "miles"
      value_template: "{{ value_json.odometer }}"
      json_attributes_topic: "car/honda"
 device_tracker:
    - name: "mqtt_tracker"
      state_topic: "tracke/mqtt_tracker"      

I get error

Missing property ‘devices’

what am i doing wrong ?

Alternatively, can i manually force update the router or nmap trackers ? I tried using homeassistant.update_entity but that didn’t force update those tracker either.

I think it’s just that you’re missing the hyphens (-) that delineate the items in the list and it has confused the yaml interpreter.

mqtt:
  - sensor:
      name: "Honda"
      unique_id : "car"
      enabled_by_default: true
      state_topic: "car/honda"
      unit_of_measurement: "miles"
      value_template: "{{ value_json.odometer }}"
      json_attributes_topic: "car/honda"

  - device_tracker:
      - name: "mqtt_tracker"
        state_topic: "tracke/mqtt_tracker"

that’s not working either.

I keep it simple. I have an ESP8266-01 in each of my cars. By the time I am in the driveway, they have connected to my WiFi.

How to OTA flash sleeping esphome sensor - ESPHome - Home Assistant Community (home-assistant.io)

Is it that you missed the “r” in “tracke/mqtt_tracker”? Shouldn’t that read “tracker/mqtt_tracker”?

spelling mistake was an error during pasting.
however my issue is intellisense is giving error that it is violation of schema even before saving/deployment.

Double check that you did the sensor part correctly, both entities are created in my instance:

image