Skip to content

Fix passive zone lookup in zone-only location privacy mode#4385

Merged
bgoncal merged 2 commits intohome-assistant:mainfrom
arrizer:fix/passive-zone-location-lookup
Feb 24, 2026
Merged

Fix passive zone lookup in zone-only location privacy mode#4385
bgoncal merged 2 commits intohome-assistant:mainfrom
arrizer:fix/passive-zone-location-lookup

Conversation

@arrizer
Copy link
Copy Markdown
Contributor

@arrizer arrizer commented Feb 23, 2026

Bug

When the Location Sent setting is set to Zone Only, automations that trigger on entering a passive zone stop working while the same automations work correctly with Exact location.

Root cause

In zone-only mode, SubmitLocation derives the current zone by GPS lookup via RLMZone.zone(of:in:) rather than using the zone associated with the incoming region event (the event zone may be the one being exited, so a fresh lookup is needed). That lookup filtered using trackablePredicate:

.init(format: "TrackingEnabled == true && isPassive == false")

The isPassive == false condition meant that when the device was inside a passive zone, the lookup returned nil, causing the payload to report not_home to Home Assistant instead of the passive zone so no automation triggered.

In Exact mode this doesn't occur because raw GPS coordinates are sent and Home Assistant resolves the zone server-side, where passive zones are handled correctly.

Note that passive zones are monitored for region enter/exit events by the iOS app (ZoneManager filters only on TrackingEnabled, not isPassive), so the region event does fire, the zone is simply lost during the zone-only lookup step.

Fix

Remove isPassive == false from the filter in RLMZone.zone(of:in:), replacing trackablePredicate with a TrackingEnabled == true-only filter. This method performs a GPS-to-zone lookup and has no reason to exclude passive zones.

trackablePredicate is left unchanged and continues to be used correctly in GeocoderSensor.

In zone-only mode, SubmitLocation derives the current zone by GPS
lookup via RLMZone.zone(of:in:). That method was filtering with
trackablePredicate (TrackingEnabled == true && isPassive == false),
which caused passive zones to never be reported when the user is
inside one - sending "not_home" to HA instead and breaking
automations that trigger on entering a passive zone.

Fix by using only the TrackingEnabled filter in zone(of:in:), which
is purely a GPS-to-zone lookup and has no reason to exclude passive
zones.
Copy link
Copy Markdown

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @arrizer

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@arrizer arrizer marked this pull request as ready for review February 23, 2026 19:58
Copilot AI review requested due to automatic review settings February 23, 2026 19:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes zone-only location privacy mode so passive zones are correctly resolved client-side during GPS-to-zone lookup, preventing not_home payloads when inside a passive zone.

Changes:

  • Updates RLMZone.zone(of:in:) to filter only on TrackingEnabled == true, allowing passive zones to be returned.
  • Leaves trackablePredicate unchanged for existing usages (e.g., GeocoderSensor) where passive zones should remain excluded.

Covers the two cases affected by the fix:
- Passive zone with TrackingEnabled = true is returned when the
  location is inside it
- Zone with TrackingEnabled = false is still excluded
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@bgoncal bgoncal merged commit 4a7fd46 into home-assistant:main Feb 24, 2026
9 of 10 checks passed
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@a21ebf0). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff           @@
##             main   #4385   +/-   ##
======================================
  Coverage        ?       0           
======================================
  Files           ?       0           
  Lines           ?       0           
  Branches        ?       0           
======================================
  Hits            ?       0           
  Misses          ?       0           
  Partials        ?       0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants