Skip to content

Commit f8733f3

Browse files
committed
Release 0.1.2
1 parent 0e32e89 commit f8733f3

10 files changed

Lines changed: 519 additions & 117 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ The format is based on Keep a Changelog, and this project follows Semantic Versi
66

77
## [Unreleased]
88

9+
## [0.1.2] - 2026-03-19
10+
11+
### Added
12+
13+
- Added `TokenEndpointResult` with detailed auth/refresh failure metadata.
14+
- Added `fetch_token_details()` and `fetch_refresh_token_details()` for typed, non-raising
15+
token endpoint diagnostics.
16+
17+
### Changed
18+
19+
- `authenticate()` and `refresh_access_token()` now classify malformed responses, HTTP failures,
20+
auth failures, and network failures more precisely.
21+
- `HomelyResponseError` now carries `body_preview` in addition to HTTP status metadata.
22+
- Legacy token helpers remain available as compatibility wrappers on top of the new detailed
23+
token methods.
24+
925
## [0.1.1] - 2026-03-17
1026

1127
### Changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,23 @@ async def main() -> None:
6969

7070
- `authenticate(username, password) -> TokenResponse`
7171
- `refresh_access_token(refresh_token) -> TokenResponse`
72+
- `fetch_token_details(username, password) -> TokenEndpointResult`
73+
- `fetch_refresh_token_details(refresh_token) -> TokenEndpointResult`
7274
- `get_locations_or_raise(token) -> list[dict]`
7375
- `get_home_data_or_raise(token, location_id) -> dict`
7476
- `HomelyWebSocket(...).connect_or_raise()`
7577

78+
Legacy compatibility helpers remain available:
79+
80+
- `fetch_token_with_reason(username, password) -> tuple[dict | None, str | None]`
81+
- `fetch_token(username, password) -> dict | None`
82+
- `fetch_refresh_token(refresh_token) -> dict | None`
83+
7684
Main exports:
7785

7886
- `HomelyClient`
7987
- `HomelyWebSocket`
88+
- `TokenEndpointResult`
8089
- `TokenResponse`
8190
- `HomelyConnectionError`
8291
- `HomelyAuthError`
@@ -88,12 +97,33 @@ Main exports:
8897
- `HomelyConnectionError`: network or service unavailable
8998
- `HomelyAuthError`: invalid credentials or rejected token
9099
- `HomelyResponseError`: unexpected response or HTTP failure
100+
Carries `status` and `body_preview` when available.
91101
- `HomelyWebSocketError`: websocket could not be established
92102

103+
## Token Diagnostics
104+
105+
If you need more than success/failure, use the detailed token helpers:
106+
107+
```python
108+
result = await client.fetch_refresh_token_details(refresh_token)
109+
if result.ok:
110+
print(result.token.access_token)
111+
else:
112+
print(result.reason, result.status, result.detail, result.body_preview)
113+
```
114+
115+
`TokenEndpointResult.reason` can distinguish between invalid credentials, invalid refresh
116+
tokens, network errors, timeouts, malformed JSON, malformed payloads, empty responses, and
117+
unexpected HTTP failures.
118+
119+
## Websocket Note
120+
121+
Refreshing an access token does not require forcing an already-connected websocket to reconnect.
122+
The websocket token only matters when a new websocket connection is established or re-established.
123+
93124
## License
94125

95126
MIT. See [LICENSE](LICENSE).
96127

97128

98-
⭐ If you find this integration useful, please consider giving it a star on [GitHub](https://github.com/ludvikroed/python-homely)! ⭐
99-
129+
⭐ If you find this package useful, please consider giving it a star on [GitHub](https://github.com/ludvikroed/python-homely)! ⭐

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "python-homely"
7-
version = "0.1.1"
7+
version = "0.1.2"
88
description = "Async Python client for the Homely cloud API, built for Home Assistant but usable anywhere."
99
readme = "README.md"
1010
requires-python = ">=3.12"
@@ -51,6 +51,9 @@ package-dir = {"" = "src"}
5151
[tool.setuptools.packages.find]
5252
where = ["src"]
5353

54+
[tool.setuptools.package-data]
55+
homely = ["py.typed"]
56+
5457
[tool.pytest.ini_options]
5558
asyncio_mode = "auto"
5659
testpaths = ["tests"]

src/homely/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Reusable Homely client package extracted from the integration."""
22

3-
__version__ = "0.1.1"
3+
__version__ = "0.1.2"
44

55
from .client import (
66
BASE_URL,
@@ -15,7 +15,7 @@
1515
HomelyResponseError,
1616
HomelyWebSocketError,
1717
)
18-
from .models import TokenResponse
18+
from .models import TokenEndpointResult, TokenResponse
1919
from .websocket import HomelyWebSocket
2020

2121
__all__ = [
@@ -29,6 +29,7 @@
2929
"HomelyAuthError",
3030
"HomelyResponseError",
3131
"HomelyWebSocketError",
32+
"TokenEndpointResult",
3233
"TokenResponse",
3334
"auth_header_value",
3435
]

0 commit comments

Comments
 (0)