Skip to content

Add Home summary models and entity-filter engine#5018

Open
bgoncal wants to merge 1 commit into
mainfrom
summaries-models
Open

Add Home summary models and entity-filter engine#5018
bgoncal wants to merge 1 commit into
mainfrom
summaries-models

Conversation

@bgoncal

@bgoncal bgoncal commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

Adds the model and request layer for the default-dashboard summaries (light, climate, security, media players, maintenance, energy, people) so they can be reused natively. These are derived client-side from entity states and registries, matching the frontend's home strategy.

  • EntityFilter plus EntityFilterEvaluator — a Swift port of the frontend entity-filter engine (generateEntityFilter / findEntities).
  • HomeSummary enum — each summary's entity filters, icon, colour, and applicability.
  • HomeSummaryState — computes each summary's value (lights on, temperature range, lock/alarm status, media playing, low/unavailable batteries, people home).
  • New energy/get_prefs request + EnergyPreferences model, and temperature_entity_id / humidity_entity_id added to the area registry model.

No UI yet — this is groundwork for a native summaries view. Energy's live value is left for a follow-up (needs the energy statistics collection).

Screenshots

Link to pull request in Documentation repository

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

Any other notes

Copilot AI review requested due to automatic review settings July 9, 2026 14:44

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

Adds shared “Home summary” domain models plus an entity-filter evaluator to compute dashboard-style summary states (lights/climate/security/media/maintenance/energy/people) from entity registry + state data, and introduces an Energy preferences request/model to support energy applicability checks.

Changes:

  • Added HomeSummary + HomeSummaryState for defining summary metadata (filters/icons/colors) and computing per-summary derived state.
  • Added EntityFilter + EntityFilterEvaluator to evaluate frontend-like entity-filter rules against registries/states.
  • Extended area registry decoding with temperature_entity_id / humidity_entity_id, and added energy/get_prefs request + EnergyPreferences model.

Reviewed changes

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

Show a summary per file
File Description
Sources/Shared/Models/HomeSummaryState.swift Defines HomeSummaryState and computes summary state values from an EntityFilterEvaluator and area registry data.
Sources/Shared/Models/HomeSummary.swift Defines HomeSummary, summary filters, icons/colors/titles, and applicability logic.
Sources/Shared/Models/HAAreasRegistryResponse.swift Adds decoding/storage for temperatureEntityId and humidityEntityId on areas.
Sources/Shared/Models/EntityFilterEvaluator.swift Implements entity-filter matching and low-battery detection using states + registries.
Sources/Shared/Models/EnergyPreferences.swift Adds EnergyPreferences + EnergySource to model energy preferences and detect grid availability.
Sources/Shared/HATypedRequest+App.swift Adds a typed WebSocket request for energy/get_prefs.
HomeAssistant.xcodeproj/project.pbxproj Registers new Swift source files in the Xcode project/targets.

Comment thread Sources/Shared/Models/HomeSummary.swift Outdated
Comment on lines +80 to +84
public var title: String {
switch self {
case .light: return "Lights"
case .climate: return "Climate"
case .security: return "Security"
Comment on lines +27 to +31
func state(using evaluator: EntityFilterEvaluator, areas: [HAAreasRegistryResponse]) -> HomeSummaryState {
switch self {
case .light:
let matched = evaluator.findEntities(matching: filters)
return .lights(onCount: matched.filter { evaluator.states[$0]?.state == "on" }.count)
@bgoncal bgoncal force-pushed the summaries-models branch from 1cbc004 to db32ad3 Compare July 9, 2026 14:50
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

⚠️ Unused L10n strings detected

Found 3 unused localization strings in the codebase.

Click to see details
Parsing Strings.swift...
Found 1881 L10n strings

Reading all Swift source code...
Read 6374723 characters of Swift code

Checking for unused strings...
Checked 100/1881 strings...
Checked 200/1881 strings...
Checked 300/1881 strings...
Checked 400/1881 strings...
Checked 500/1881 strings...
Checked 600/1881 strings...
Checked 700/1881 strings...
Checked 800/1881 strings...
Checked 900/1881 strings...
Checked 1000/1881 strings...
Checked 1100/1881 strings...
Checked 1200/1881 strings...
Checked 1300/1881 strings...
Checked 1400/1881 strings...
Checked 1500/1881 strings...
Checked 1600/1881 strings...
Checked 1700/1881 strings...
Checked 1800/1881 strings...

================================================================================
UNUSED STRINGS REPORT
================================================================================

Found 3 unused strings:


CAMERAPLAYER:
  - L10n.CameraPlayer.Talkback.microphoneDenied
    Key: camera_player.talkback.microphone_denied
    Line: 820

CONNECTION:
  - L10n.Connection.Permission.InternalUrl.body1
    Key: connection.permission.internal_url.body1
    Line: 1370
  - L10n.Connection.Permission.InternalUrl.body2
    Key: connection.permission.internal_url.body2
    Line: 1372

================================================================================
Total unused: 3
================================================================================

================================================================================
Copy-paste these keys into the "Lokalise: Delete Keys" workflow (keys input):
================================================================================
camera_player.talkback.microphone_denied,connection.permission.internal_url.body1,connection.permission.internal_url.body2

To remove them, run the
Lokalise: Delete Keys
workflow — it deletes the keys from Lokalise and opens a PR removing them from
Localizable.strings and regenerating Strings.swift. Copy-paste these keys into the keys input:

camera_player.talkback.microphone_denied,connection.permission.internal_url.body1,connection.permission.internal_url.body2

Port the default-dashboard summary definitions (light, climate, security,
media players, maintenance, energy, persons) from the frontend as reusable
Swift models: EntityFilter plus a findEntities engine, the HomeSummary enum
with per-domain filters/icons/colors, per-summary state calculation, and an
energy/get_prefs request. Summaries are derived client-side from entity
states and registries, matching the frontend.
@bgoncal bgoncal force-pushed the summaries-models branch from db32ad3 to 10228aa Compare July 9, 2026 14:54
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.

2 participants