Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
adamlogan73
left a comment
There was a problem hiding this comment.
Thanks for this. I checked the model changes against Home Assistant core at 2026.11.3 and they line up: the entity registry output (next_name_part, no more has_entity_name, nullable aliases), the config/entity_registry/update schema (and good catch on disabled_by using the wrong enum), and the new error_reason_translation_domain on config entries. I also ran these models against a live 2026.4.3 instance and everything still parses, so older servers keep working.
A few changes before merging (details inline):
- Drop the vendored nimax commit (a64981c).
- Rebase onto
mainand re-record the cassettes. There are conflicts inpyproject.toml,tests/test_websocket.pyand likely some cassettes.mainalso has a new cassette test,test_async_concurrent_listeners_and_pingintests/test_events.py, recorded against an older HA. Please re-record the full set against 2026.11.3 after rebasing, so every cassette comes from the same version. - Move the model-parsing tests to
tests/test_models.py. - Make
next_name_parta strict enum.
| include = ["homeassistant_api", "homeassistant_api/py.typed"] | ||
|
|
||
| [tool.uv.sources] | ||
| nimax = { path = "vendor/nimax-1.1.1-py3-none-any.whl" } |
There was a problem hiding this comment.
nimax 1.2.0 includes the replay fix (nimax#8), and main now requires nimax>=1.2. Please drop this commit (a64981c). That also removes the wheel from vendor/ and the COPY vendor/ line in the Dockerfile.
| FROM ghcr.io/astral-sh/uv:python3.13-bookworm AS dependencies | ||
| WORKDIR /app | ||
| COPY pyproject.toml README.md ./ | ||
| COPY vendor/ ./vendor/ |
There was a problem hiding this comment.
This line goes away with the vendored-nimax commit.
| @@ -722,3 +734,75 @@ async def test_async_get_components(async_cached_client: AsyncClient) -> None: | |||
| """Tests the `GET /api/components` endpoint.""" | |||
| components = await async_cached_client.get_components() | |||
| assert "person" in components | |||
|
|
|||
|
|
|||
| def test_parse_flow_progress_without_discovery_key() -> None: | |||
There was a problem hiding this comment.
This test and the three after it (test_parse_flow_progress_from_older_server, test_parse_config_entry_without_nullable_fields, test_parse_flow_progress_with_non_string_placeholders) are pure model-parsing tests. Please move them to tests/test_models.py; this file holds the endpoint and cassette tests.
| modified_at: DatetimeIsoField | ||
| name: str | None = None | ||
| # Values added by newer Home Assistant versions are kept as plain strings. | ||
| next_name_part: Annotated[ |
There was a problem hiding this comment.
Please make this a strict NextNamePart | None. The other enums in the models are strict, and for now we would rather update the models when Home Assistant adds values than accept unknown strings in one place. If we do want unknown values to pass through, it should apply to every enum, in a separate change.
a64981c to
fd94fcf
Compare
Home Assistant 2026.11 stopped sending `has_entity_name` in entity registry WebSocket payloads (home-assistant/core#186898), so validating `config/entity_registry/list`, `get` and `update` results failed. Make the field optional so older servers keep working. Also align the model with the current payload: - `aliases` may mix `None` (the computed entity name) with strings - add `next_name_part` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- disabled_by was wrongly typed as EntityHiddenBy - aliases may contain None for the computed entity name - categories values may be None to remove a category from a scope - options may be None Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ConfigFlowContext.discovery_key is only present for discovery flows, so flows such as reauth failed to parse from config_entries/flow/progress - Note that FlowContext.show_advanced_options (removed in home-assistant/core#172249) and ConfigFlowContext.confirm_only (removed in home-assistant/core#188784) are only sent by older servers - Add ConfigFlowContext.dismiss_protected, FlowResult.sort and ConfigEntry.error_reason_translation_domain Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
disabled_by, reason, error_reason_translation_key and error_reason_translation_placeholders were required, so config entries from servers that omit them failed to parse, unlike the neighbouring error_reason_translation_domain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Home Assistant placeholder values are not guaranteed to be strings, so error responses and flows with e.g. numeric placeholders failed to parse. Add a shared TranslationPlaceholders type (dict[str, Any]) and use it for all placeholder fields so new ones don't reintroduce dict[str, str]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Update tests for behaviour changes since 2026.4.3. The cassettes are not re-recorded here, so these tests fail until they are: - Two new system config entries (marketplace, analytics) bring the total to 6 - Disabling or enabling a config entry now sends an extra update event when disabled_by changes, before the entry is unloaded or set up Give the logbook tests an entry to parse: with no history for sun.red_sun, get_logbook_entries yielded nothing and the parsing loop went untested. Set sun.red_sun twice before querying, since the logbook skips an entity's initial state and the second state is what produces an entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fd94fcf to
452ff30
Compare
|
Thank you for the response! All your comments should be addressed now. |
An array of changes have been made to the models used in the WebSocket API for Home Assistant, making the current
6.1.0version ofHomeAssistant-APIno longer compatible with Home Assistant2026.11.This PR synchronizes the models with the ones defined in Home Assistant Core, updates the test cassettes and adds the necessary unit tests. See each commit for details.
Do note that this PR uses a patched version of nimax, that contains a necessary bug fix. This change is isolated to the latest commit, so that it can be dropped when the nimax change has been merged and released.