**Step 1:** Disable Background Tracking on Your Phone
To ensure Home Assistant never tracks you automatically, you need to turn off the background location sensors in the Android app.
- Open the Home Assistant Companion App on your Android phone.
- Go to Settings > Companion App > Manage Sensors.
- Look for the following sensors and disable them:
* Background Location
* Location Zone
Enable this:
* Single Accurate Location
Note: //Do not revoke the Android OS location permission for the app itself. The app still needs system permission to grab the GPS coordinates when Home Assistant manually requests them.//
**Step 2:** Create the "Locate Phone" Script
Next, we will create a script in Home Assistant that forces the Android app to report its current location immediately using a high-priority notification command.
- In Home Assistant, go to Settings > Automations & Scenes > Scripts.
- Click Add Script -> Create New Script.
- Switch to the YAML editor (via the three dots in the top right) and paste the following code (//replace notify.mobile_nokiax10//) with your actual phone's notify entity):
sequence:
- action: notify.mobile_nokiax10
data:
message: command_request_location
mode: single
icon: mdi:crosshairs-gps
alias: Request Phone Location
** if above doesnt work, use this:
action: notify.mobile_app_nokiax10
data:
message: command_request_location
**Step 3:** Add the Button to Your Dashboard
Now, add a button card to your Lovelace dashboard so you can trigger the location request on demand.
- Go to your dashboard, click the three dots in the top right, and select Edit Dashboard.
- Click Add Card and choose the Button card (or a Tile card).
- Configure the card with the following settings:
* Name: Locate My Phone
* Icon: mdi:cellphone-marker
* Tap Action: Run Script
* Script: Select the script you created in Step 2 (script.request_phone_location).
type: button
name: Locate My Phone
icon: mdi:cellphone-marker
tap_action:
action: perform-action
perform_action: script.request_phone_location