Presence Detection with the HA Companion App — Welcome Home Automations
- Andrea Leandri
- Jun 29
- 6 min read
Updated: Jul 2
Skill level: Beginner → Intermediate | Time to complete: 30–45 minutes
What you'll build: Reliable presence detection using the HA Companion App on iPhone, plus two automations: a Jarvis welcome greeting when you arrive home, and smooth jazz playing through your Alexa speakers — stopping automatically when you leave.
Why the Companion App Beats WiFi Detection
If you've tried presence detection via WiFi ping, you've likely hit the classic iOS problem: the iPhone disconnects from WiFi when the screen goes to sleep, so HA thinks you've left at 2am. Or you walk in the front door and nothing happens for 45 seconds because the ping hasn't fired yet.
The Companion App solves both problems. It uses GPS, WiFi scanning, and cell tower data combined, reporting your location directly to HA — proactively, not when HA polls for it. It knows you're approaching home before you arrive, and doesn't lose you because your screen is off.
The best setup combines both methods into a single person entity. HA merges the Companion App tracker and a WiFi ping tracker into one reliable state. If GPS briefly loses signal indoors, WiFi acts as fallback. If WiFi drops while you sleep, GPS confirms you're still home.
What You'll Need
Home Assistant — any recent version (2024.x or later)
HA Companion App — installed on your iPhone from the App Store
Alexa Media Player integration — already installed if you followed the Jarvis guide on this site
Ping integration — built into HA, no install needed
Your iPhone's local IP — for the WiFi ping fallback tracker
Part 1: Set Up the Companion App Device Tracker
1.1 Install and connect the app
Install Home Assistant from the App Store and sign in to your HA instance. The app needs to reach HA — either on your local network or via your DuckDNS URL.
1.2 Enable location permissions — the most critical step
This is where most people go wrong, and why presence detection seems unreliable on iOS.
iPhone Settings → Home Assistant → Location → set to: Always
Also enable Precise Location — the toggle directly below. Without this, iOS gives HA a rough 500m radius instead of your actual GPS position.
Why "Always" and not "While Using"? With "While Using", iOS only reports your location when the app is on screen. With "Always", the app reports in the background. Without this, your phone looks like it left home every time you put it in your pocket.
1.3 Enable background refresh
iPhone Settings → Home Assistant → Background App Refresh → On. This allows the app to send location updates even when it is not the active app.
1.4 Configure location settings in the app
HA Companion App → sidebar menu → App Configuration → Location. Enable: Location Updates, Significant Location Change, and Background Location Updates.
1.5 Verify the device tracker exists
In HA, go to Settings → People — your iPhone should be listed as a device tracker. Or check Developer Tools → States and search for device_tracker. You'll see your device with state home or not_home.
Part 2: Set Up the Ping Fallback Tracker
The Ping integration gives you a second tracker based on your iPhone's presence on the home WiFi. On its own it's unreliable — iOS disconnects sleeping phones from WiFi — but combined with the Companion App in a person entity, it provides a useful backup signal.
2.1 Find your iPhone's local IP
iPhone → Settings → WiFi → tap your network name → IP Address. Note it down (e.g. 192.168.1.45).
Tip: Set a DHCP reservation on your Zyxel router so your iPhone always gets the same IP. Network → DHCP → Static DHCP → add your iPhone's MAC address and assign a fixed IP.
2.2 Add the Ping integration
Settings → Devices & Services → Add Integration → search "Ping (ICMP)". Enter your iPhone's local IP. Or add directly to configuration.yaml:
binary_sensor:
- platform: ping
host: 192.168.X.XX # your iPhone's local IP
name: "XXXXXX iPhone WiFi"
count: 2
scan_interval: 30Restart HA after adding this.
Part 3: Create a Person Entity
The person entity ties everything together, merging multiple trackers into one reliable presence state.
Settings → People → Add Person
Name: XXXXXX
Device Trackers: add both device_tracker.XXXXXX_s_iphone (Companion App) and device_tracker.XXXXXX_iphone_wifi (Ping)
You now have person.XXXXXX with state home or not_home. Always use the person entity in automations — never individual trackers. The merging logic is: if any tracker says home, the person is home. The person only becomes not_home when all trackers agree you're away.
Part 4: Configure Your Home Zone
Settings → Areas, Zones & Labels → Zones → home. Check the radius — default is 100 metres. For a city house, 100m is usually right. You can increase to 150–200m if you want automations to trigger slightly before you reach the front door.
Part 5: Welcome Home Automation — Alexa Greeting
This automation fires when you arrive home and triggers a greeting through one of your Alexa speakers.
alias: "Home - Welcome home greeting"
description: >
Plays a Jarvis welcome greeting through the living room Echo
when XXXXXX arrives home.
trigger:
- platform: state
entity_id: person.XXXXXX
from: "not_home"
to: "home"
for:
seconds: 30 # must be home 30 sec to filter GPS blips
condition:
- condition: time
after: "07:00:00"
before: "23:00:00"
action:
- delay:
seconds: 15
- service: notify.alexa_media_echo_dot_woonkamer # replace with your device
data:
message: >
Welcome home, XXXXXX.
It is {{ now().strftime('%-H:%M') }}.
data:
type: tts
mode: singleReplace notify.alexa_media_echo_dot_woonkamer with your actual Alexa entity — find it in Developer Tools → Services → search notify.alexa_media. Customise the message template to include any live sensor data you want: outside temperature, Marstek battery level, time of day, or just a simple welcome.
Part 6: Smooth Jazz on Arrival, Silence on Departure
This automation plays smooth jazz through your Alexa speakers when you arrive home, and stops all playback when you leave.
Find your Alexa media player entity
Developer Tools → States → search media_player. Your Echo devices will be listed there. To play on multiple speakers simultaneously, create a speaker group in the Alexa app first — it will appear as a single media_player entity in HA.
Smooth jazz TuneIn stations
Some reliable options to use as media_content_id in the automation: tunein://s24840 (Smooth Jazz Florida), tunein://s1946 (181.FM Smooth Jazz), tunein://s28917 (Jazz24), tunein://s28918 (WBGO Jazz 88.3 FM).
The automation
alias: "Home - Smooth jazz on arrival and departure"
description: >
Plays smooth jazz when Andrea arrives home,
stops all Alexa playback when she leaves.
trigger:
- platform: state
entity_id: person.XXXXXX
from: "not_home"
to: "home"
for:
seconds: 30
id: arrived
- platform: state
entity_id: person.XXXXXX
from: "home"
to: "not_home"
for:
minutes: 2
id: left
condition:
- condition: time
after: "08:00:00"
before: "22:30:00"
action:
- choose:
# Arriving home
- conditions:
- condition: trigger
id: arrived
sequence:
- delay:
seconds: 20
- service: media_player.play_media
target:
entity_id: media_player.echo_dot_woonkamer # replace with your device
data:
media_content_type: "music"
media_content_id: "tunein://s24840" # Smooth Jazz Florida
- service: media_player.volume_set
target:
entity_id: media_player.echo_dot_woonkamer
data:
volume_level: 0.25 # gentle background volume
# Leaving home
- conditions:
- condition: trigger
id: left
sequence:
- service: media_player.media_stop
target:
entity_id: media_player.echo_dot_woonkamer
mode: singleThe for: seconds: 30 on arrival filters out GPS blips from driving past your zone. The for: minutes: 2 on departure prevents the music stopping if you just step outside briefly. Adjust both to taste.
Using Spotify instead of TuneIn: if you have Spotify connected to Alexa and the Spotify integration in HA, replace the media_content_id with a Spotify URI like spotify:playlist:37i9dQZF1DX0SM0LYsmbMT. Find URIs by right-clicking any playlist in Spotify → Share → Copy Spotify URI.
Tuning for Reliability on iOS
iPhone battery optimisation aggressively kills background processes. If person.XXXXXX stops updating reliably, check: Battery → Low Power Mode is off, Settings → Home Assistant → Background App Refresh is On, Settings → Privacy & Security → Location Services → Home Assistant is set to Always with Precise Location.
iOS sometimes silently resets these permissions after updates. If presence detection suddenly stops working after an iOS update, check these three settings first.
Troubleshooting
person.XXXXXX never changes state: Location must be set to Always with Precise Location in iPhone Settings
Presence very slow to update (5+ minutes): Enable Significant Location Change in the Companion App settings
False "left home" at night: iPhone WiFi disconnects during sleep — normal. The Companion App GPS should override it. Check Background App Refresh is on.
Welcome greeting fires multiple times: Add for: seconds: 30 to the trigger and set automation mode: single
Music doesn't start: Check the media_player entity ID in Developer Tools → States. Verify the TuneIn station ID is correct by testing it manually.
Companion App stops updating after a few days: Go to iPhone Settings → Home Assistant and force-re-enable Background App Refresh. iOS sometimes resets this.
Guide written by a Home Assistant enthusiast in Utrecht. Built with Home Assistant and way too much time fine-tuning arrival timing.



Comments