Set location based on IP of Device on network

I am the Technology Coordinator for a school and I’m using Home Assistant as a dashboard in my office at work. I would like to get presence detection working based on my phone’s IP address and for it to show which building I am in. I can watch for each IP Address, but it only shows as “Home”. What I would like is for it show Elementary/High School or Junior High.

I run Unifi with a site-to-site VPN between the two locations. I’m comfortable using YAML automation or Node-Red, but I haven’t been able to figure this out yet.

Use Places and OwnTracks.

I’d much prefer to do it via a network scan for two reasons. I’m trying to minimize the number of services running on the network . Secondly, I don’t want an app running in the background on my phone all the time that is trying to connect to service it isn’t able to connect to. (I won’t open MQTT in the firewall)

Did you ever find a solution to this? We have exactly the same setup with UniFi and two locations with separate IP-networks; one on the homestead (where HASS is running) and one in the city apartment. It would be nice to be able to configure a zone with an IP network and devices on that net would be considered in that zone.

  latitude: d.3956157
  longitude: d.0493479
  friendly_name: Homestead
  radius: 200
1 Like

A bit cumbersome, but one approach could be:

  • Create 1 ping binary_sensor per zone for your phone (so 2 here)
  • Create one or multiple automations that would trigger on those binary_sensors and that would call the device_tracker.see service on the actual device_tracker of the phone, specifying the zone.