Skip to content

Add floor context to entity pickers and entity display#4875

Open
bgoncal wants to merge 4 commits into
mainfrom
entity-naming-floors
Open

Add floor context to entity pickers and entity display#4875
bgoncal wants to merge 4 commits into
mainfrom
entity-naming-floors

Conversation

@bgoncal

@bgoncal bgoncal commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Screenshots

Link to pull request in Documentation repository

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

Any other notes

@bgoncal bgoncal self-assigned this Jun 29, 2026
Copilot AI review requested due to automatic review settings June 29, 2026 13:00
@bgoncal bgoncal added watch The Apple Watch app and complications CarPlay widgets control-center labels Jun 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “floor” awareness to entity context/subtitle rendering so entity pickers and AppIntent-based pickers can disambiguate identically named areas by including the floor (e.g., Home • Ground Floor • Living Room • Thermostat) when needed.

Changes:

  • Fetches floor registry data and stores floor context alongside areas (floor id + denormalized floor name).
  • Extends shared subtitle/context formatting to optionally include floor, and adds collision detection to only show floors when area names collide.
  • Plumbs floorName through MagicItem/AppIntent/Widget entity representations and adds unit tests for the subtitle/disambiguation rules.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Tests/App/Area/EntityContextSubtitle.test.swift Adds tests for subtitle floor placement/omission and floor disambiguation behavior.
Sources/Shared/Models/HAFloorRegistryResponse.swift Introduces a typed model for the floor registry response.
Sources/Shared/Models/HAAreasRegistryResponse.swift Adds floorId to the area registry response decoding.
Sources/Shared/MagicItem/MagicItemProvider.swift Caches per-server floor-name mappings and includes floor in MagicItem entity context.
Sources/Shared/HATypedRequest+App.swift Adds a typed request for config/floor_registry/list.
Sources/Shared/Environment/AppDatabaseUpdater.swift Resolves and persists floorName into AppArea records when saving areas.
Sources/Shared/Environment/AppAreaTable.swift Adds floorId / floorName columns to the AppArea table schema.
Sources/Shared/Environment/AppArea.swift Persists floorId and denormalized floorName on the AppArea model.
Sources/Shared/Database/DatabaseTables.swift Adds floorId / floorName column identifiers for the AppArea table.
Sources/Shared/AreasService.swift Fetches floors for a server and exposes lookup APIs for floor resolution.
Sources/Extensions/Widgets/Scene/Control/IntentSceneEntity.swift Adds floorName to widget scene entities and wires it into query mapping.
Sources/Extensions/Widgets/HAAppEntityAppIntentEntity.swift Adds floorName to AppIntent entities and includes it in query/collection building.
Sources/Extensions/Widgets/Controls/Switch/IntentSwitchEntity.swift Adds floorName to switch control entities and populates it from floor mappings.
Sources/Extensions/Widgets/Controls/Light/IntentLightEntity.swift Adds floorName to light control entities and populates it from floor mappings.
Sources/Extensions/Widgets/Controls/Fan/IntentFanEntity.swift Adds floorName to fan control entities and populates it from floor mappings.
Sources/Extensions/Widgets/Controls/Cover/IntentCoverEntity.swift Adds floorName to cover control entities and populates it from floor mappings.
Sources/Extensions/Widgets/Controls/Button/IntentButtonEntity.swift Adds floorName to button control entities and populates it from floor mappings.
Sources/Extensions/Widgets/Controls/Automation/IntentAutomationEntity.swift Adds floorName to automation control entities and populates it from floor mappings.
Sources/Extensions/EntityProvider+Details.swift Extends subtitle formatting with floor, adds collision detection helpers, and adds a floor-name mapping helper.
Sources/Extensions/AppIntents/Sensor/IntentSensorsAppEntity.swift Adds floorName to sensor AppIntent entities and populates it from floor mappings.
Sources/Extensions/AppIntents/Script/ScriptAppIntent.swift Adds floorName to script AppIntent entities and populates it from floor mappings.
HomeAssistant.xcodeproj/project.pbxproj Registers the new files in the project and test target build phases.

Comment thread Tests/App/Area/EntityContextSubtitle.test.swift
Comment thread Sources/Shared/AreasService.swift
Comment thread Sources/Shared/Environment/AppDatabaseUpdater.swift Outdated
Comment thread Sources/Extensions/EntityProvider+Details.swift
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.61538% with 42 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@f6566d4). Learn more about missing BASE report.

Files with missing lines Patch % Lines
Sources/Shared/AreasService.swift 20.00% 20 Missing ⚠️
...ources/Shared/Environment/AppDatabaseUpdater.swift 0.00% 10 Missing ⚠️
Sources/Extensions/EntityProvider+Details.swift 89.74% 4 Missing ⚠️
Sources/Shared/HATypedRequest+App.swift 0.00% 4 Missing ⚠️
Sources/Shared/Environment/AppArea.swift 50.00% 2 Missing ⚠️
Sources/Shared/MagicItem/MagicItemProvider.swift 33.33% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4875   +/-   ##
=======================================
  Coverage        ?   47.25%           
=======================================
  Files           ?      277           
  Lines           ?    17430           
  Branches        ?        0           
=======================================
  Hits            ?     8236           
  Misses          ?     9194           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants