pybluetti 0.2.7__tar.gz → 0.2.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pybluetti-0.2.7 → pybluetti-0.2.9}/CHANGELOG.md +8 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/PKG-INFO +1 -1
- {pybluetti-0.2.7 → pybluetti-0.2.9}/pyproject.toml +1 -1
- {pybluetti-0.2.7 → pybluetti-0.2.9}/src/pybluetti/__init__.py +4 -3
- {pybluetti-0.2.7 → pybluetti-0.2.9}/src/pybluetti/client.py +5 -0
- pybluetti-0.2.9/tests/test_package.py +11 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/tests/test_product_client.py +13 -0
- pybluetti-0.2.7/tests/test_package.py +0 -7
- {pybluetti-0.2.7 → pybluetti-0.2.9}/.github/workflows/publish.yml +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/.github/workflows/tests.yml +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/.gitignore +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/LICENSE +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/README.md +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/scripts/lint +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/scripts/setup +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/scripts/test +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/scripts/typecheck +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/src/pybluetti/const.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/src/pybluetti/exceptions.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/src/pybluetti/models.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/src/pybluetti/product_client.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/src/pybluetti/py.typed +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/src/pybluetti/unify_response.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/src/pybluetti/websocket.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/tests/__init__.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/tests/test_const.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/tests/test_exceptions.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/tests/test_unify_response.py +0 -0
- {pybluetti-0.2.7 → pybluetti-0.2.9}/tests/test_websocket.py +0 -0
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# 0.2.9
|
|
2
|
+
|
|
3
|
+
- Debug logging now includes the `msgCode` and `message` of every JSON answer. A command the cloud refuses still answers HTTP 200, so the code was the one part of the answer the log did not show.
|
|
4
|
+
|
|
5
|
+
# 0.2.8
|
|
6
|
+
|
|
7
|
+
- `pybluetti.__version__` is read from the installed package's metadata, so it matches the released version. It had said `0.1.1` since that release.
|
|
8
|
+
|
|
1
9
|
# 0.2.7
|
|
2
10
|
|
|
3
11
|
- Every request now has a timeout of 10 seconds (`REQUEST_TIMEOUT` in `client.py`), set in `Bluetti._request()` and so on all four calls of `ProductClient`. There was none, so the session's own applied, and aiohttp's default for that is five minutes: when the gateway accepted a status request and never answered it, each `get_device_status()` held its caller for 300 s. In `bluetti-home-assistant`, which retries a timeout once and keeps the last values through two failed polls, that made one poll take ten minutes and left the entities on values up to half an hour old before they went unavailable (bluetti-community/bluetti-home-assistant#78). A request that runs out of time raises `TimeoutError`, as it did before after the five minutes, so a caller that already handles it needs no change. A caller that set a longer limit on its own session no longer gets it for these requests.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pybluetti
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
4
4
|
Summary: Async Python client for the BLUETTI cloud API - device discovery, state, and control.
|
|
5
5
|
Project-URL: Homepage, https://github.com/bluetti-community/pybluetti
|
|
6
6
|
Project-URL: Used by, https://github.com/bluetti-community/bluetti-home-assistant
|
|
@@ -6,10 +6,11 @@ https://github.com/bluetti-official/bluetti-home-assistant's
|
|
|
6
6
|
custom_components/bluetti/api/, the same way
|
|
7
7
|
https://github.com/pyenphase/pyenphase backs the enphase_envoy Home Assistant
|
|
8
8
|
integration. Fully async, including the websocket push-update transport
|
|
9
|
-
(`aiohttp`'s native websocket client, no dedicated threads).
|
|
10
|
-
bluetti-home-assistant to depend on this package is a separate follow-up.
|
|
9
|
+
(`aiohttp`'s native websocket client, no dedicated threads).
|
|
11
10
|
"""
|
|
12
11
|
|
|
12
|
+
from importlib.metadata import version
|
|
13
|
+
|
|
13
14
|
from .client import Bluetti
|
|
14
15
|
from .const import Method
|
|
15
16
|
from .exceptions import ApplicationRuntimeException, HttpStatusException
|
|
@@ -18,7 +19,7 @@ from .product_client import ProductClient
|
|
|
18
19
|
from .unify_response import UnifyResponse
|
|
19
20
|
from .websocket import StompClient
|
|
20
21
|
|
|
21
|
-
__version__ = "
|
|
22
|
+
__version__ = version("pybluetti")
|
|
22
23
|
|
|
23
24
|
__all__ = [
|
|
24
25
|
"ApplicationRuntimeException",
|
|
@@ -124,6 +124,11 @@ class Bluetti:
|
|
|
124
124
|
if response.content_type.lower().startswith("application/json"):
|
|
125
125
|
data = await response.json() # read response body to JSON
|
|
126
126
|
unify_response = TypeAdapter(UnifyResponse[responseType]).validate_python(data)
|
|
127
|
+
# A command the cloud refuses still answers HTTP 200; its
|
|
128
|
+
# msgCode is the only trace of the refusal.
|
|
129
|
+
self.logger.debug(
|
|
130
|
+
"<====== Server msgCode %s: %s", data.get("msgCode"), data.get("message")
|
|
131
|
+
)
|
|
127
132
|
if data.get("msgCode") == 805 and self._on_auth_expired is not None:
|
|
128
133
|
self._on_auth_expired()
|
|
129
134
|
self.logger.info("token have expired")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""The package's own metadata."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import version
|
|
4
|
+
|
|
5
|
+
import pybluetti
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_version_is_the_installed_packages() -> None:
|
|
9
|
+
# Hard-coded, it stayed at 0.1.1 through every release after that one.
|
|
10
|
+
assert pybluetti.__version__ == version("pybluetti")
|
|
11
|
+
assert pybluetti.__version__ != "0.1.1"
|
|
@@ -220,3 +220,16 @@ async def test_request_the_cloud_never_answers_times_out(monkeypatch):
|
|
|
220
220
|
release.set()
|
|
221
221
|
|
|
222
222
|
assert elapsed < 2
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
async def test_every_json_answer_logs_its_msgcode(caplog):
|
|
226
|
+
# A refused command still answers HTTP 200: without its msgCode the
|
|
227
|
+
# debug log cannot tell a refusal from an accepted command.
|
|
228
|
+
response = _FakeResponse(json_data={"msgId": "1", "msgCode": 1302, "message": "device offline", "data": None})
|
|
229
|
+
client, _on_auth_expired = _client(_FakeSession(response))
|
|
230
|
+
|
|
231
|
+
with caplog.at_level("DEBUG", logger="pybluetti"):
|
|
232
|
+
await client.control_device({"sn": "SN1", "fnCode": "SetCtrlWorkMode", "fnValue": "workmode_0"})
|
|
233
|
+
|
|
234
|
+
assert "<====== Server msgCode 1302: device offline" in caplog.text
|
|
235
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|