-
Notifications
You must be signed in to change notification settings - Fork 26
V6 rewrite #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
V6 rewrite #232
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
7ec2130
move to uv
adamlogan73 c317706
Replace mypy with zuban and relax development dependency versions
adamlogan73 f9d4111
Streamline Docker build and merge dev dependency groups
adamlogan73 fb7da56
Flatten client hierarchy and remove Raw prefix
adamlogan73 436f747
Split models into Base/Sync/Async hierarchies and modernize codebase
adamlogan73 e7dec40
Replace Processing class with standalone sync/async functions
adamlogan73 74f79a6
Add unit tests for client params, error classes, and models
adamlogan73 357102d
Unify client API surface across REST and WebSocket clients
adamlogan73 24a8a25
Add entity registry methods and models for WebSocket clients
adamlogan73 821c20e
Update documentation and docstrings for v2 API surface
adamlogan73 efef0a9
Fix bugs and issues found during full code review
adamlogan73 f30fa11
Fix websocket error handling and test failures
adamlogan73 f24678a
Add v2.0 changelog
adamlogan73 3517ad6
Bump version to v6.0.0
adamlogan73 c8187ce
Migrate from requests/aiohttp/websockets to niquests
adamlogan73 fdb5996
Bump readthedocs Python version from 3.10 to 3.11
GrandMoff100 e901829
Add command to check Python and pip paths
GrandMoff100 a67c1a3
Fix not installing to readthedocs venv
GrandMoff100 d7ed02f
Fix some typing issues
GrandMoff100 7e3a01b
Ignore intentionally unreachable line
GrandMoff100 2de2990
Use CaseInsensitiveDict for headers in mock responses
GrandMoff100 52d76ab
Pin urllib3-future<2.19.902 to avoid WebSocket regression
adamlogan73 6c6e74c
Unpin urllib3.future after websockets patched
GrandMoff100 0bd97cf
Replace mypy with zuban: add pre-commit hook, convert [tool.mypy] to …
adamlogan73 03351fd
Exclude type guard error messages from coverage
GrandMoff100 16ed85d
Exclude testing session start error handling and remove unnecessary e…
GrandMoff100 81adb38
Fix coverage gaps: restore pragma: no cover, annotate untestable bran…
adamlogan73 2a7a677
Improve usability of config/entity_registry/update parameters (#235)
mj23000 e5c7152
Fix aliases typing (#234)
mj23000 be2ec71
Modernize StrEnum usage (#233)
mj23000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # HomeAssistant-API v6.0 Changelog | ||
|
|
||
| ## Breaking Changes | ||
| A lot has changed in this version. A lot went into modernising and standardizing the interfaces of the clients. | ||
| As such, many of the previous paradigms have changed. If you run into any bugs or issues, please let us know. | ||
| ### Minimum Python version raised to 3.11 | ||
| Python 3.9 and 3.10 are no longer supported. | ||
|
|
||
| ### Client classes restructured | ||
| The old `Client` class (which combined sync and async via a `use_async` flag) has been removed. There are now four distinct client classes: | ||
|
|
||
| | Old | New | | ||
| |---|---| | ||
| | `Client(use_async=False)` | `Client` | | ||
| | `Client(use_async=True)` | `AsyncClient` | | ||
| | `WebsocketClient` (sync) | `WebsocketClient` | | ||
| | — | `AsyncWebsocketClient` (new) | | ||
|
|
||
| Async client methods no longer have the `async_` prefix — e.g. `async_get_states()` is now just `get_states()` on `AsyncClient`. | ||
|
|
||
| ### Models split into Base/Sync/Async variants | ||
| `Domain`, `Entity`, `Group`, `Service`, and `Event` now have three variants each: | ||
| - **`Base*`** — plain data, no client reference | ||
| - **`*`** (e.g. `Domain`) — sync, bound to `Client` | ||
| - **`Async*`** (e.g. `AsyncDomain`) — async, bound to `AsyncClient` | ||
|
|
||
| ### Processing module rewritten | ||
| The decorator-based `@Processing.processor(mimetype)` registry has been replaced with simple dict-based MIME dispatch and separate `sync`/`async` entry points. Custom processor registration and the `decode_bytes` parameter have been removed. | ||
|
|
||
| ### Build system moved from Poetry to uv + hatchling | ||
| `poetry.lock` is removed. The project now uses `uv` for dependency management and `hatchling` as the build backend. | ||
|
|
||
| ### Type checker changed from mypy to zuban | ||
|
|
||
|
GrandMoff100 marked this conversation as resolved.
|
||
| ## New Features | ||
|
|
||
| ### WebSocket API support (sync & async) | ||
| Full WebSocket client implementation for both sync (`WebsocketClient`) and async (`AsyncWebsocketClient`) with support for: | ||
| - **Config entries** — get, disable, enable, ignore flow, subentries, subscribe | ||
| - **Entity registry** — list, get, update, remove entries | ||
| - **Events** — subscribe, fire, and listen | ||
| - **Services** — trigger with full domain/service routing | ||
| - **Templates** — render and subscribe to template updates | ||
|
|
||
| ### Entity registry models | ||
| New models: `EntityRegistryEntry`, `EntityRegistryEntryExtended`, `EntityRegistryUpdateResult`. | ||
|
|
||
| ### Configurable WebSocket max message size | ||
| WS clients accept a `max_size` parameter (default 16 MB) to handle large responses like full entity registry lists. | ||
|
|
||
| ## Improvements | ||
|
|
||
| - Unified method signatures across all four client classes for consistency | ||
| - Expanded ruff lint rules to `ALL` (from just E, F, W) | ||
| - Test coverage improved to ~99% | ||
| - Modernized type annotations throughout | ||
| - Response content is now read lazily, eliminating internal `_buffer` access hacks | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,13 @@ | ||
| ARG BUILD_FROM | ||
| FROM ghcr.io/astral-sh/uv:python3.13-bookworm AS dependencies | ||
| WORKDIR /app | ||
| COPY pyproject.toml README.md ./ | ||
| RUN uv sync --group dev | ||
|
|
||
| FROM ${BUILD_FROM} AS base | ||
| FROM python:3.13-bookworm | ||
| ENV PYTHONPATH=. | ||
| WORKDIR /app | ||
| COPY ./ /app/ | ||
|
|
||
| FROM base AS dependencies | ||
| RUN pip install --upgrade pip wheel | ||
| RUN pip install poetry | ||
| RUN python3 -m venv .venv && \ | ||
| . .venv/bin/activate && \ | ||
| poetry install --with testing && \ | ||
| deactivate | ||
|
|
||
| FROM base AS final | ||
| COPY --from=dependencies /app/.venv /app/.venv | ||
| ENV PATH="/app/.venv/bin:$PATH" | ||
| COPY ./ /app/ | ||
|
|
||
| ENTRYPOINT [ "sh", "entrypoint.sh" ] | ||
|
|
||
| ENTRYPOINT [ "sh", "entrypoint.sh" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.