Reliable Presence Detection in Home Assistant Using WiFi Ping on Android (2026)

Reliable Presence Detection in Home Assistant Using WiFi Ping on Android (2026)

By WisBro
#Home Assistant#Presence Detection#Raspberry Pi#Smart Home#Android

One of the most powerful features of a self-hosted smart home is automation based on who is home and who isn't. Lights that turn off when everyone leaves. The alarm that arms itself when you walk out the door. The heating that kicks in before you arrive. All of this depends on one thing working reliably: presence detection.

The problem is that GPS-based geofencing โ€” the default approach โ€” is slow. In real-world testing, it can take 2 to 5 minutes after arriving home before Home Assistant registers you as "home." That's enough time to be standing at your front door, key in hand, wondering why nothing happened.

This guide covers the approach that actually works: using your phone's WiFi connection as the presence trigger. The moment your phone connects to your home WiFi, HA knows you're home. Instant. No delay.

If you haven't set up Home Assistant yet, start with Part 1 of this series: How to Set Up Home Assistant on Raspberry Pi with Cloudflare Tunnel.

Why GPS Presence Detection Fails in Practice

The Home Assistant mobile app uses a combination of GPS, WiFi scanning, and cell tower data to determine your location. In theory this works well. In practice, Android aggressively kills background processes to save battery โ€” which means the HA app can't always report your location in real time.

The result: you arrive home, park the car, walk to the door, and HA still shows you as "not_home" because the GPS update hasn't fired yet. You end up opening the app manually just to wake it up, which defeats the entire purpose.

WiFi ping solves this differently. Instead of relying on the phone to report its own location, your Raspberry Pi actively pings your phone's IP address on the local network every 30 seconds. If it responds โ€” you're home. If it stops responding โ€” you've left. No app dependency, no background process, no Android battery optimisation interference.

What You'll Need

  • Home Assistant running on Raspberry Pi (see Part 1)
  • Android phone with the Home Assistant companion app installed
  • Access to your router admin panel to reserve a static IP
  • Your phone's MAC address (we'll find this during setup)

Step 1 โ€” Install the HA Companion App and Create Your Person

Install the Home Assistant app from the Play Store on your Android phone. Open it and log in using your HA URL โ€” either your local IP (http://192.168.1.x:8123) or your remote domain if you've set up a Cloudflare tunnel.

Once logged in, go to HA and create a person profile:

  • Go to Settings โ†’ People โ†’ Add Person
  • Enter your name and enable login
  • Under Select the devices that belong to this person, add your phone
  • Save

This creates a person.yourname entity in HA that we'll use as the unified presence indicator โ€” combining multiple tracking methods into one clean state.

Step 2 โ€” Reserve a Static IP for Your Phone

For the WiFi ping tracker to work reliably, your phone must always get the same IP address on your home network. Without this, the IP could change and HA would lose track of your phone entirely.

Find your phone's current IP and MAC address:

  • Go to Android Settings โ†’ About Phone โ†’ Status โ†’ IP address โ€” note the IP
  • To find the MAC address, go to Android Settings โ†’ Connected devices โ†’ Connection preferences โ†’ Bluetooth โ†’ Device name โ€” then check your router's connected devices list for the matching entry

Log into your router admin panel and create a DHCP reservation (sometimes called "static lease" or "address reservation") that permanently assigns your chosen IP to your phone's MAC address. Save the setting.

From this point on, your phone will always get the same IP โ€” for example 192.168.1.50.

Step 3 โ€” Add the Ping Integration in HA

Home Assistant has a built-in Ping (ICMP) integration that monitors whether a device on your network is reachable. In HA 2026.x this creates a binary_sensor that shows on (connected) or off (disconnected).

Go to Settings โ†’ Integrations โ†’ Add Integration โ†’ search "Ping" and add it. When prompted, enter your phone's reserved IP address.

After a moment you'll see a new entity like binary_sensor.192_168_1_50 appear. Check Settings โ†’ Developer Tools โ†’ States and search for it โ€” it should show on while your phone is connected to WiFi.

Step 4 โ€” Create a Presence Helper

The binary sensor works, but it can't be linked directly to a person profile (which requires a device_tracker entity). We solve this with a template helper that converts the binary sensor into a proper presence sensor.

Go to Settings โ†’ Helpers โ†’ Create Helper โ†’ Template โ†’ Template a binary sensor and fill in:

  • Name: Your Name Phone Wifi
  • State template: {{ is_state('binary_sensor.192_168_1_50', 'on') }}
  • Device class: presence

Click Submit. You now have a binary_sensor.yourname_phone_wifi entity that shows Home or Away based on your WiFi connection โ€” updating every 30 seconds.

Step 5 โ€” Create the Presence Automations

Since the presence helper is a binary_sensor and not a device_tracker, we can't link it directly to the person profile. Instead, we use two automations that call the device_tracker.see service to update the person's location whenever the WiFi status changes.

Automation 1 โ€” Arrived Home

Go to Settings โ†’ Automations โ†’ Create Automation:

  • Trigger: State โ†’ binary_sensor.yourname_phone_wifi โ†’ turns on
  • Action: Call service โ†’ device_tracker.see
  • Service data: dev_id: yourname, location_name: home

Automation 2 โ€” Left Home

Create a second automation:

  • Trigger: State โ†’ binary_sensor.yourname_phone_wifi โ†’ turns off
  • For: 2 minutes (to avoid false triggers from brief WiFi drops)
  • Action: Call service โ†’ device_tracker.see
  • Service data: dev_id: yourname, location_name: not_home

The 2-minute delay on the "left home" automation is important. Without it, a brief WiFi blip โ€” your phone switching from WiFi to mobile data for a moment โ€” would falsely trigger the "away" state.

Step 6 โ€” Configure Location Sensors on Your Phone

Open the HA companion app on your Android phone and go to App Settings โ†’ Companion App โ†’ Manage Sensors. Make sure the following are enabled:

  • Background location โ€” the main GPS sensor
  • Location zone โ€” fires when you enter or leave a defined zone
  • Single accurate location โ€” improves accuracy
  • Wi-Fi connection โ€” under Network sensors, enables instant home detection via WiFi

Leave High accuracy mode off โ€” it drains battery significantly and isn't needed with the WiFi ping approach.

Step 7 โ€” Fix Android Battery Optimisation

Android's battery management can prevent the HA app from running in the background. To ensure location updates fire reliably:

  • Go to Android Settings โ†’ Apps โ†’ Home Assistant โ†’ Battery โ†’ Unrestricted
  • Go to Android Settings โ†’ Apps โ†’ Home Assistant โ†’ Permissions โ†’ Location โ†’ Allow all the time
  • Go to Android Settings โ†’ Battery โ†’ Battery optimization โ†’ Home Assistant โ†’ Don't optimize

On Pixel phones, also check Android Settings โ†’ Apps โ†’ Home Assistant โ†’ three dots menu โ†’ Allow background activity and make sure it's on.

Step 8 โ€” Set Your Home Zone

In HA go to Settings โ†’ Areas & Zones โ†’ Home zone and set the radius to 100 meters. This is the sweet spot โ€” accurate enough to distinguish home from nearby locations, large enough that GPS drift doesn't cause false "left home" events.

Make sure the pin is placed on your actual home location. You can drag it on the map.

Step 9 โ€” Add Your Wife (or Any Other Person)

Repeat Steps 1โ€“5 for each person in your household. Each person needs:

  • Their own HA account and person profile
  • The HA companion app installed and logged in on their phone
  • A static IP reserved on the router for their phone
  • Their own ping binary sensor and presence helper
  • Their own "arrived" and "left" automations

Once set up, HA will have separate person.name entities for each household member โ€” the foundation for any multi-person automation.

Testing Your Setup

Go to Settings โ†’ Developer Tools โ†’ States and search for person.yourname. You should see it showing home.

To test leaving: turn WiFi off on your phone. Wait 2 minutes (the delay we set) and check again โ€” it should switch to not_home. Turn WiFi back on and it should switch back to home within 30 seconds.

To test the automations fired correctly, go to the automation and click Traces โ€” you'll see a log of every time it triggered and whether the action succeeded.

How the Two Methods Work Together

With this setup you actually have two complementary presence methods running side by side:

MethodBest ForSpeedReliability
WiFi PingArriving homeInstant (30s)Very high
GPS (HA App)Leaving home1โ€“3 minHigh

WiFi is excellent for detecting arrival because your phone connects to home WiFi the moment you're in range โ€” often before you even get out of the car. GPS is better for departure because the WiFi disconnects gradually and you want the 2-minute delay buffer anyway.

Together they eliminate the main weakness of each individual method.

Troubleshooting

Ping sensor shows "off" even though phone is home

Check that your phone's IP hasn't changed โ€” the DHCP reservation may not have taken effect yet. Reconnect your phone to WiFi after setting the reservation, then verify the IP matches what you entered in HA. Also make sure your phone's WiFi is actually on and connected (not on mobile data).

Automation triggered but person.name didn't update

Check the automation trace for errors. The most common issue is a mismatch between the dev_id in the automation and the actual entity ID. Go to Developer Tools โ†’ States and search for device_tracker.yourname โ€” use whatever comes after device_tracker. as your dev_id.

GPS takes too long after leaving home

Make sure Location zone is enabled in the HA app sensors. This fires immediately when you exit the defined home zone, which is faster than waiting for a general GPS position update. Also confirm your home zone radius is set correctly in HA.

False "away" triggers during the day

Increase the "For" duration on the "Left Home" automation from 2 minutes to 5 minutes. This gives more buffer for brief WiFi drops without affecting real departure detection, since you'll be well outside WiFi range within 5 minutes of actually leaving.

Frequently Asked Questions

Q: Does this work if I have multiple WiFi access points (mesh network)?

Yes. As long as all your access points share the same network (same SSID and subnet), your phone will always appear on the same local network regardless of which access point it connects to. The ping from your Pi will reach it either way.

Q: What if my phone goes to sleep and doesn't respond to pings?

Modern Android phones respond to ICMP pings even when the screen is off and the phone is asleep, as long as it's connected to WiFi. This is handled at the network driver level, not the app level, so battery optimisation doesn't affect it.

Q: Can I use this with iPhones too?

Yes, the WiFi ping approach works with any device that has a reserved IP โ€” iPhones, iPads, laptops, anything. The HA companion app for iOS also supports the same sensor configuration described in this guide.

Q: Do I still need the HA mobile app if I'm using WiFi ping?

Yes โ€” the mobile app handles departure detection via GPS and also provides push notifications, which are essential for the alarm automations we'll build in the next article. The WiFi ping handles arrival; the app handles departure. They work best together.

Q: How do I handle guests or temporary devices?

Only add devices that belong to permanent household members. Guest phones won't have a reserved IP and won't be tracked unless you add them manually โ€” which is exactly the behaviour you want.

What's Next

With reliable presence detection working for everyone in your household, you have the foundation for a proper smart home security system. The next step is building an alarm system in Home Assistant using Alarmo โ€” wiring your existing SmartThings sensors into HA automations that arm when everyone leaves and disarm the moment someone arrives home.

This article is part of the Plain Digit Smart Home series. Follow along as we build a complete, self-hosted smart home system on a Raspberry Pi.