Skip to content

V6 rewrite#232

Merged
GrandMoff100 merged 30 commits into
devfrom
v6_rewrite
Apr 26, 2026
Merged

V6 rewrite#232
GrandMoff100 merged 30 commits into
devfrom
v6_rewrite

Conversation

@adamlogan73
Copy link
Copy Markdown
Collaborator

@adamlogan73 adamlogan73 commented Apr 3, 2026

Closes #229

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 99.89230% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.85%. Comparing base (fbefe2e) to head (be2ec71).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
homeassistant_api/asyncclient.py 99.29% 1 Missing ⚠️
homeassistant_api/client.py 99.28% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #232      +/-   ##
==========================================
+ Coverage   99.66%   99.85%   +0.19%     
==========================================
  Files          29       29              
  Lines        2359     2787     +428     
==========================================
+ Hits         2351     2783     +432     
+ Misses          8        4       -4     

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

Swap type checker from mypy to zuban across CI, pre-commit, and
pyproject.toml. Relax pinned versions on docs, styling, and testing
dependency groups to use range constraints. Bump requires-python
to >=3.10 and websockets to >=16.
Remove the unified Client/WebsocketClient classes that combined sync and
async via use_async flag. Promote the Raw* implementations to be the
public API: Client, AsyncClient, WebsocketClient, AsyncWebsocketClient.
Drop the async_ prefix from async client methods since they now live on
separate classes. Move URL scheme validation into base classes.
Introduce Base*/Async* model variants for Domain, Entity, Group, Service,
and Event. Replace _client constructor pattern with explicit client field.
Bump minimum Python to 3.11, expand ruff rules to ALL, modernize type
annotations, and enforce single-line imports.
Replace the decorator-based processor registry with dict-based MIME
dispatch and separate sync/async entry points. Response content is now
read lazily only when needed for error messages, eliminating the
internal _buffer access hack. Remove custom processor registration
API and decode_bytes parameter.
- Rename get_domain() param from `domain` to `domain_id` on WS clients
- Change WS get_domain() return type to Domain | None using .get()
- Fix fire_event() return type on sync Client from str | None to str
- Add keyword-only marker for significant_changes_only in sync get_entity_histories()
- Remove redundant entity_id param from WS trigger_service methods
- Fix TemplateEvent.result type from str to Any (HA returns native types)
- Add str() conversion in WS get_rendered_template to match return annotation
- Document WS trigger_service return type differences (protocol limitation)
New models for entity registry responses (EntityRegistryEntry,
EntityRegistryEntryExtended, EntityRegistryUpdateResult) and
list/get/update/remove methods on both sync and async WS clients.
Also adds configurable max_size param to WS client init (default 16MB)
to handle large responses like full entity registry lists.

Update CI Python version from 3.9 to 3.11.
- Rewrite usage.rst async section: replace use_async=True/async_ prefix
  pattern with separate AsyncClient and AsyncWebsocketClient classes
- Fix advanced.rst: update caching params (cache_session -> session),
  remove obsolete "disabling caching" section, add use_cache docs
- Fix README.md: update async example to use AsyncClient, remove
  "async not supported" note for WebSocket
- Standardize docstrings across all four client classes: consistent
  voice, correct class references (Entity->AsyncEntity etc.), fix
  "homeassistant" -> "Home Assistant" naming
- Fix minor issues: typos, Python version (3.9->3.11), zuban in
  CONTRIBUTING.rst tooling list
- Fix broken f-string/%-style log format in sync client
- Align empty-params guard between sync and async clients
- Replace deprecated verify_ssl with ssl param in TCPConnector
- Stop prepare_headers from mutating caller's dict; allow header overrides
- Use ResponseError instead of mismatched RequestError in WebSocket layer
- Fix auth failure path that could raise unhandled ValidationError
- Make sync _subscribe_events use recv_result to match async
- Make include_id keyword-only in async send() to match sync
- Gracefully handle __exit__ when connection is already closed
- Clean up _event_responses in finally block during unsubscribe
- Suppress auth token from debug logging
- Validate History states are non-empty and share same entity_id
- Replace asyncio.Task and Container with deserializable types in models
- Add model_rebuild for ServiceFieldSelector circular reference
- Export all config entry and entity registry models from top-level package
- Fix async websocket fixture decorator in conftest
- Fix sync test_listen_config_entries to use explicit break like async version
- Strengthen test assertions and add cleanup safety in disable/enable tests
- Use tmp_path for SQLite cache in async session test
- Raise ReceivingError in __exit__/__aexit__ when connection is not open
- Remove duplicate check_success from handle_recv (parse_response already handles errors)
- Catch non-ValidationError exceptions in authentication_phase
- Add ResponseError to Service.trigger() fallback so it works for websocket clients
- Fix tests to expect ResponseError for websocket error responses
Replace all HTTP and WebSocket dependencies with niquests:
- requests + requests-cache -> niquests (sync REST client)
- aiohttp + aiohttp-client-cache -> niquests AsyncSession (async REST client)
- websockets -> niquests[ws] WebSocket extension (sync + async WS clients)

Drop built-in request caching support (requests-cache, aiohttp-client-cache).
Users can configure caching on their own session instances if needed.

WebSocket clients now use niquests' response extension API
(Session.get(ws://) -> response.extension.send_payload/next_payload).
Add fragment buffering in _recv to work around upstream urllib3-future
bug where next_payload() returns incomplete messages for large payloads.

Accept optional session parameter in WebSocket client constructors for
consistency with REST clients. Use non-nullable session types with del
for _ws in __exit__/__aexit__.
Comment thread .pre-commit-config.yaml
Comment thread CHANGELOG.md
…[tool.zuban] with default mode, and fix test type narrowing
GrandMoff100
GrandMoff100 previously approved these changes Apr 12, 2026
…ches, and self-contained entity registry remove tests
@GrandMoff100 GrandMoff100 merged commit 60d07a2 into dev Apr 26, 2026
7 checks passed
@GrandMoff100 GrandMoff100 deleted the v6_rewrite branch April 27, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add poetry.lock to gitignore

3 participants