python-homely 0.1.10__tar.gz → 0.1.11__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.
- {python_homely-0.1.10/src/python_homely.egg-info → python_homely-0.1.11}/PKG-INFO +1 -1
- {python_homely-0.1.10 → python_homely-0.1.11}/pyproject.toml +1 -1
- {python_homely-0.1.10 → python_homely-0.1.11}/src/homely/client.py +12 -19
- {python_homely-0.1.10 → python_homely-0.1.11/src/python_homely.egg-info}/PKG-INFO +1 -1
- {python_homely-0.1.10 → python_homely-0.1.11}/tests/test_sdk.py +34 -1
- {python_homely-0.1.10 → python_homely-0.1.11}/LICENSE +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/README.md +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/setup.cfg +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/src/homely/__init__.py +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/src/homely/exceptions.py +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/src/homely/models.py +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/src/homely/py.typed +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/src/homely/websocket.py +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/src/python_homely.egg-info/SOURCES.txt +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/src/python_homely.egg-info/dependency_links.txt +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/src/python_homely.egg-info/requires.txt +0 -0
- {python_homely-0.1.10 → python_homely-0.1.11}/src/python_homely.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-homely"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.11"
|
|
8
8
|
description = "Async Python client for the Homely cloud API, built for Home Assistant but usable anywhere."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -39,7 +39,7 @@ def auth_header_value(token: str | None) -> str:
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def _response_preview(payload: Any) -> str:
|
|
42
|
-
"""Return a short
|
|
42
|
+
"""Return a short preview of a response payload for exceptions."""
|
|
43
43
|
text = repr(payload)
|
|
44
44
|
if len(text) <= 200:
|
|
45
45
|
return text
|
|
@@ -61,10 +61,7 @@ def _text_preview(text: str | None) -> str | None:
|
|
|
61
61
|
|
|
62
62
|
def _error_detail(err: BaseException) -> str:
|
|
63
63
|
"""Return a compact detail string for logs and typed results."""
|
|
64
|
-
|
|
65
|
-
if detail:
|
|
66
|
-
return detail
|
|
67
|
-
return err.__class__.__name__
|
|
64
|
+
return type(err).__name__
|
|
68
65
|
|
|
69
66
|
|
|
70
67
|
def _coarse_token_reason(reason: TokenFailureReason | None) -> str | None:
|
|
@@ -317,7 +314,11 @@ class HomelyClient:
|
|
|
317
314
|
try:
|
|
318
315
|
return _text_preview(await response.text())
|
|
319
316
|
except (TypeError, ValueError, UnicodeDecodeError) as err:
|
|
320
|
-
_LOGGER.debug(
|
|
317
|
+
_LOGGER.debug(
|
|
318
|
+
"Could not read response text status=%s: %s",
|
|
319
|
+
response.status,
|
|
320
|
+
_error_detail(err),
|
|
321
|
+
)
|
|
321
322
|
return None
|
|
322
323
|
|
|
323
324
|
def _raise_token_endpoint_failure(
|
|
@@ -366,7 +367,7 @@ class HomelyClient:
|
|
|
366
367
|
_LOGGER.debug(
|
|
367
368
|
"Locations fetch returned invalid JSON status=%s: %s",
|
|
368
369
|
response.status,
|
|
369
|
-
err,
|
|
370
|
+
_error_detail(err),
|
|
370
371
|
)
|
|
371
372
|
return None, response.status
|
|
372
373
|
if not isinstance(parsed, list):
|
|
@@ -382,7 +383,7 @@ class HomelyClient:
|
|
|
382
383
|
_LOGGER.debug("Locations fetch failed with status=%s", response.status)
|
|
383
384
|
return None, response.status
|
|
384
385
|
except (aiohttp.ClientError, TimeoutError) as err:
|
|
385
|
-
_LOGGER.debug("Locations fetch network error: %s", err)
|
|
386
|
+
_LOGGER.debug("Locations fetch network error: %s", _error_detail(err))
|
|
386
387
|
return None, None
|
|
387
388
|
|
|
388
389
|
async def get_locations(self, token: str) -> list[dict[str, Any]] | None:
|
|
@@ -433,7 +434,7 @@ class HomelyClient:
|
|
|
433
434
|
"status=%s location_id=%s: %s",
|
|
434
435
|
response.status,
|
|
435
436
|
_log_identifier(location_id),
|
|
436
|
-
err,
|
|
437
|
+
_error_detail(err),
|
|
437
438
|
)
|
|
438
439
|
return None, response.status
|
|
439
440
|
if not isinstance(parsed, dict):
|
|
@@ -446,25 +447,17 @@ class HomelyClient:
|
|
|
446
447
|
)
|
|
447
448
|
return None, response.status
|
|
448
449
|
return parsed, response.status
|
|
449
|
-
retry_after = response.headers.get("Retry-After")
|
|
450
|
-
try:
|
|
451
|
-
body = await response.text()
|
|
452
|
-
except Exception:
|
|
453
|
-
body = "<unreadable>"
|
|
454
450
|
_LOGGER.debug(
|
|
455
|
-
"Location data fetch failed with status=%s location_id=%s
|
|
456
|
-
"retry_after=%s body=%s",
|
|
451
|
+
"Location data fetch failed with status=%s location_id=%s",
|
|
457
452
|
response.status,
|
|
458
453
|
_log_identifier(location_id),
|
|
459
|
-
retry_after,
|
|
460
|
-
body[:500] if body else None,
|
|
461
454
|
)
|
|
462
455
|
return None, response.status
|
|
463
456
|
except (aiohttp.ClientError, TimeoutError) as err:
|
|
464
457
|
_LOGGER.debug(
|
|
465
458
|
"Location data fetch network error location_id=%s: %s",
|
|
466
459
|
_log_identifier(location_id),
|
|
467
|
-
err,
|
|
460
|
+
_error_detail(err),
|
|
468
461
|
)
|
|
469
462
|
return None, None
|
|
470
463
|
|
|
@@ -96,7 +96,7 @@ class _FakeAsyncCallable:
|
|
|
96
96
|
async def test_sdk_exports_public_symbols():
|
|
97
97
|
"""The SDK should expose a clean public surface."""
|
|
98
98
|
assert auth_header_value("token") == "Bearer token"
|
|
99
|
-
assert __version__ == "0.1.
|
|
99
|
+
assert __version__ == "0.1.11"
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
async def test_authenticate_returns_typed_token():
|
|
@@ -721,3 +721,36 @@ async def test_websocket_connect_or_raise_uses_typed_exception():
|
|
|
721
721
|
pass
|
|
722
722
|
else:
|
|
723
723
|
raise AssertionError("Expected HomelyWebSocketError")
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
async def test_home_error_does_not_log_response_content(caplog):
|
|
727
|
+
"""Home failures should log HTTP status without copying the response body."""
|
|
728
|
+
marker = "synthetic-private-home-value"
|
|
729
|
+
client = HomelyClient(
|
|
730
|
+
_FakeSession(get_response=_FakeResponse(status=503, text_data=marker))
|
|
731
|
+
)
|
|
732
|
+
|
|
733
|
+
with caplog.at_level("DEBUG", logger="homely.client"):
|
|
734
|
+
assert await client.get_home_data_with_status("token", "loc-1") == (None, 503)
|
|
735
|
+
|
|
736
|
+
assert "status=503" in caplog.text
|
|
737
|
+
assert marker not in caplog.text
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
async def test_malformed_token_does_not_log_response_values(caplog):
|
|
741
|
+
"""Malformed credential payloads should log metadata without raw values."""
|
|
742
|
+
marker = "synthetic-private-auth-value"
|
|
743
|
+
client = HomelyClient(
|
|
744
|
+
_FakeSession(
|
|
745
|
+
post_response=_FakeResponse(
|
|
746
|
+
status=200,
|
|
747
|
+
json_exc=ValueError(marker),
|
|
748
|
+
)
|
|
749
|
+
)
|
|
750
|
+
)
|
|
751
|
+
|
|
752
|
+
with caplog.at_level("DEBUG", logger="homely.client"):
|
|
753
|
+
result = await client.fetch_token_details("user", "password")
|
|
754
|
+
|
|
755
|
+
assert result.reason == "invalid_json"
|
|
756
|
+
assert marker not in caplog.text
|
|
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
|
{python_homely-0.1.10 → python_homely-0.1.11}/src/python_homely.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|