Async Python client for the BLUETTI cloud API - device discovery, state, and control.
This repository is the extraction target for the API client code that used to
live in
bluetti-home-assistant's
custom_components/bluetti/api/, following the same pattern
pyenphase uses for the enphase_envoy
Home Assistant integration: a standalone, independently testable and
versionable library, decoupled from Home Assistant's own release cycle.
The extraction is happening in three steps:
- Done. Move the client code here mechanically, decoupled from
hass(server URLs and anon_auth_expiredcallback are passed in as plain constructor arguments instead - seesrc/pybluetti/). - Done. Replace the blocking
websocket-clienttransport (previously run on a dedicated thread to keep it out of Home Assistant's event loop) withaiohttp's native async websocket client -src/pybluetti/websocket.pyhas no threads left. STOMP protocol framing (stomper) is unchanged. - Not started. Publish to PyPI, and switch
bluetti-home-assistant'smanifest.json/imports to depend on this package instead of its own in-tree copy.
- Independent testing and versioning, not tied to Home Assistant's release cadence.
- A step toward Home Assistant core inclusion - core integrations are expected to depend on an external library for the actual device/API communication, not embed raw HTTP/websocket calls directly in the integration.
- Fixed a known gap along the way: the embedded client used to run the blocking
websocket-clientlibrary on a dedicated thread to keep it out of Home Assistant's event loop.pybluettiis fully async instead, matchingbluetti-home-assistant's ownquality_scale.yamlasync-dependencygoal once step 3 wires it up.
scripts/setup # install runtime + test dependencies
scripts/test # run the test suite (100% line coverage enforced)
scripts/lint # run ruff, auto-fixing what it safely can
scripts/typecheck # run mypy --strictMIT - see LICENSE.