Skip to content

Add "in_zones" array when reporting zone-only location#4665

Open
bgoncal wants to merge 9 commits into
mainfrom
in-zones
Open

Add "in_zones" array when reporting zone-only location#4665
bgoncal wants to merge 9 commits into
mainfrom
in-zones

Conversation

@bgoncal
Copy link
Copy Markdown
Member

@bgoncal bgoncal commented May 26, 2026

Summary

To fulfill the new requirements in core we need to send in_zones when we send a location update using zone only. See home-assistant/architecture#1387 for more details. Implemented in core home-assistant/core#171814

Android PR: home-assistant/android#6879

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Comment thread Sources/Shared/API/HAAPI.swift Outdated
@bgoncal bgoncal marked this pull request as ready for review May 27, 2026 13:32
Copilot AI review requested due to automatic review settings May 27, 2026 13:32
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

Adds support for Home Assistant Core’s new in_zones field in update_location webhook payloads when the app is configured to send zone-only location updates, gated by Core version support.

Changes:

  • Add in_zones to WebhookUpdateLocation and populate it for zone-only location updates when supported by Core.
  • Introduce RLMZone.zones(of:in:includingPassive:) to return all matching zones (sorted by radius) and use it when building zone-only updates.
  • Extend unit tests for the new in_zones payload and the new multi-zone lookup behavior.

Reviewed changes

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

Show a summary per file
File Description
Tests/Shared/Webhook/WebhookUpdateLocation.test.swift Adds coverage for serializing in_zones when using the zone-name initializer.
Tests/Shared/RealmZone.test.swift Adds coverage for returning all matching zones and excluding passive zones when requested.
Sources/Shared/Environment/AppConstants.swift Adds a Core version gate constant for in_zones support.
Sources/Shared/API/Models/WebhookUpdateLocation.swift Adds inZones to the model and maps it to in_zones in JSON.
Sources/Shared/API/Models/RealmZone.swift Adds zones(...) API to return all matching zones (sorted) and reimplements zone(...) via it.
Sources/Shared/API/HAAPI.swift Sends in_zones in zone-only payloads when supported and derives location_name from the first non-passive zone where applicable.

Comment thread Sources/Shared/Environment/AppConstants.swift Outdated
Comment thread Sources/Shared/API/Models/RealmZone.swift Outdated
bgoncal and others added 2 commits May 27, 2026 15:37
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

4 participants