Skip to content

feat: add typed SupportedAlias parsing and per-type resolution - #2232

Open
iMicknl wants to merge 2 commits into
mainfrom
feat/supported-aliases
Open

feat: add typed SupportedAlias parsing and per-type resolution#2232
iMicknl wants to merge 2 commits into
mainfrom
feat/supported-aliases

Conversation

@iMicknl

@iMicknl iMicknl commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Closes #2224.

core:SupportedAliases is currently exposed as a raw, untyped list, so every consumer has to walk the attribute themselves — and, as #2224 describes, most will treat it as "one entry per type" and get duplicate behavior. A Somfy ogp:VenetianBlind reports up to six favorite1 slots for what is functionally a single "My position" preset.

What this adds

@define(kw_only=True)
class SupportedAlias:
    id: str
    type: str
    features: list[str] = field(factory=list)

Two Device methods:

Deliberately left out

  • The required_features capability tiers (step 3 of the app's algorithm in core:SupportedAliases can list multiple entries with the same type (e.g. favorite1); add a helper to resolve the one the app would use #2224). Consumers that show one control per type — which is what the app does — already land on the most capable id via the most-featured pick, so the tiers add an API surface nobody currently needs. Easy to add later without breaking this signature.
  • An OverkizAliasType enum. type stays str so unknown types survive parsing instead of being dropped. Home Assistant relies on this to log a warning and fall back to a generated name when it meets a type it has no translation for; dropping unknown entries would hide new alias types instead of surfacing them.

Naming note: #2224 floated get_most_featured_alias_by_type; I went with get_most_featured_aliases since the dict[str, ...] return already says "by type". Happy to rename.

id is normalized with str() because goToAlias is declared as taking a single STRING parameter on every server in docs/data, and attrs does not enforce the annotation. Every payload observed in docs/data and in the Home Assistant fixtures already reports ids as strings.

Tests

Six tests in tests/test_models.py::TestSupportedAliases covering the absent attribute, parsing, id normalization, most-featured resolution, array-order tie-breaking, and that one alias is kept per type. tests/test_models.py passes (184 tests).

Also documented under "Resolve supported aliases" in docs/device-control.md.

Downstream

home-assistant/core#175567 consumes this: it replaces hand-rolled dict-walking with get_most_featured_aliases(), which collapses the six duplicate "My position" buttons on the venetian blind in HA's own fixtures down to one.

core:SupportedAliases can list several ids for the same type, each
advertising a different subset of features. Consumers had to walk the raw
attribute themselves, which in practice meant treating every entry as a
distinct control instead of the single one the official app resolves to.

Closes #2224
Every observed core:SupportedAliases payload reports ids as strings. The
normalization stays because goToAlias takes a string parameter and attrs
does not enforce the declared type.
@iMicknl
iMicknl requested a review from tetienne as a code owner August 23, 2026 21:01
Copilot AI balanced review requested due to automatic review settings August 23, 2026 21:01
@github-actions github-actions Bot added the feature New feature or capability label Aug 23, 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.

🟡 Changes recommended

Documentation incorrectly claims parity with the official app despite omitted capability-tier filtering.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds typed parsing and per-type deduplication for device-supported aliases.

Changes:

  • Introduces SupportedAlias and Device alias helpers.
  • Adds parsing and resolution tests.
  • Documents alias resolution.
File summaries
File Description
pyoverkiz/models.py Implements typed alias parsing and selection.
tests/test_models.py Tests parsing, normalization, and deduplication.
docs/device-control.md Documents the new helpers.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/device-control.md
Comment on lines +149 to +150
The official app shows a single control per type and targets the most featured
id, which `get_most_featured_aliases()` reproduces:
Comment thread pyoverkiz/models.py
Comment on lines +529 to +534
"""Return the alias to use per type, mirroring how the Somfy app resolves them.

A device can advertise several ids for the same type, each covering a
different subset of features. The app shows a single control per type and
targets the most featured id, preferring the earliest one on a tie.
"""
Comment thread tests/test_models.py
"""Tests for parsing and resolving the core:SupportedAliases attribute."""

@staticmethod
def _device_with_aliases(value: list[dict] | None) -> Device:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core:SupportedAliases can list multiple entries with the same type (e.g. favorite1); add a helper to resolve the one the app would use

2 participants