Skip to content

Add GatewayClient for the gateway WebSocket - #102

Draft
kelvan wants to merge 2 commits into
mainfrom
gardena/fs/local-client
Draft

kelvan wants to merge 2 commits into
mainfrom
gardena/fs/local-client

Conversation

@kelvan

@kelvan kelvan commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Adds GatewayClient, which owns the WebSocket to the gateway: connecting with Basic auth, reconnecting, and correlating requests with their replies, so callers don't have to implement that themselves. It works as an async context manager and has a discover_devices() helper.

Callbacks tell the caller about pushed events, (re)connects, lost connections and a rejected password. Messages that are not replies to a pending request can optionally be collected on an events queue. After connecting, the client exposes the gateway's certificate and its SHA-256 fingerprint, and it can pin that fingerprint on later connections. A rejected password raises AuthenticationError on the first connect and calls on_auth_failed on a later reconnect, instead of retrying forever.

The examples use the client in a second commit and no longer need the websockets package.

@kelvan kelvan added the enhancement New feature or request label Oct 26, 2026
@kelvan kelvan self-assigned this Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  gardena_smart_local_api
  client.py 172, 281-283, 308, 359-360, 372, 374-375, 378-379, 383-385, 402, 421
Project Total  

This report was generated by python-coverage-comment-action

@kelvan
kelvan force-pushed the gardena/fs/local-client branch 3 times, most recently from 9a5640e to 2e9f2dd Compare October 26, 2026 15:32
@easybe

easybe commented Oct 26, 2026

Copy link
Copy Markdown
Member

Can this be used by the examples? Does it make sense to do so?

Comment thread gardena_smart_local_api/client.py Outdated
@kelvan
kelvan force-pushed the gardena/fs/local-client branch from 2e9f2dd to e4a3da5 Compare October 26, 2026 15:37
@kelvan

kelvan commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

Can this be used by the examples? Does it make sense to do so?

yes, that is the plan :)

@kelvan
kelvan force-pushed the gardena/fs/local-client branch from e4a3da5 to 6e5726e Compare October 26, 2026 15:41
@kelvan kelvan changed the title Add GardenaLocalClient for the gateway WebSocket Add GatewayClient for the gateway WebSocket Oct 26, 2026
@kelvan
kelvan force-pushed the gardena/fs/local-client branch 4 times, most recently from dbca0e3 to 856329c Compare October 26, 2026 17:10
kelvan and others added 2 commits October 26, 2026 18:16
Integrations had to implement connecting, authenticating, reconnecting
and request/reply correlation themselves, and duplicated it between a
coordinator and a config flow. The client provides it once, pins the
gateway certificate by fingerprint, and reports a rejected password
instead of retrying it forever.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The examples had their own copy of the connection and reply handling,
which the client now provides.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kelvan
kelvan force-pushed the gardena/fs/local-client branch from 856329c to 139be03 Compare October 26, 2026 17:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants