Device tracker based on WiFi

Hey, im a relative newbie to HASS and have very simple devices/automations.
I have setup some automations based on the device_tracker entities that come from the companion app. From my understanding, they use GPS to know when you are at a certain location like you home.
It works just fine except for the fact that I live in a building and there are some automations that I dont want running until I am upstairs at my apartment. Is it possible to have the device_tracker entity use my Wifi connection status of my phone rather than GPS? I think this would be more precise in my case.
Thanks

You can use the wifi sensor and have this do a service call device_tracker.see to set a device tracker to home.
Or just trigger on the sensor itself if you don’t need the device tracker.

Interesting concept that I hadn’t thought of… I just tried it by making a binary sensor using the ping platform. If I am close enough for my phone to connect to my home WiFi, the binary_sensor goes “connected”.

Cool.

binary_sensor:
  - platform: ping
    host: 192.168.1.96
    name: "Steve Phone"
    count: 1
    scan_interval: 5

No… not ping.
That wont work when the phone goes to sleep.

Use the companion apps sensor that shows wifi SSID. Use this with if SSID == “somewifi” then…

You can turn the WiFi sensor into a device tracker with a little help from MQTT and an automation, and that’s what I do:

automation:
  - id: 'YOU_wifi_status'
    alias: 'YOU WiFi status'
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.YOUR_PHONE_wifi_connection
        to: ~
    action:
      - choose:
        - conditions:
            - condition: template
              value_template: "{{ 'Cogs-n-Gears' in states('sensor.YOUR_PHONE_wifi_connection') }}"
          sequence:
            - service: mqtt.publish
              data:
                topic: location/YOU_wifi
                payload: 'home'
                retain: true
        default:
          - service: mqtt.publish
            data:
              topic: location/YOU_wifi
              payload: 'not_home'
              retain: true

and

mqtt:
  device_tracker:
    - name: "person YOU wifi"
      state_topic: 'location/YOU_wifi'
      source_type: router
      unique_id: "mqtt_person_YOU_wifi"
2 Likes

I was able to get it working last night after some more research and lots of troubleshooting.
I ended up creating two binary sensors (one for me and one for wife) that use our companion apps ssid sensor. If it == our home ssid then it will output “on”.

Then I put that into a group to know if either of us is home. I’ve been using it with our automations with no issues for now. The SSID check is pretty quick on the companion app. However I did notice that when location setting is turned off on the app, it does not update. Not sure what the relationship there is.

Android requirement.
SSID can be reverse searched

Link to the docs, please.