Skip to content

Commit ed1eb8f

Browse files
authored
Improve documentation (v2) (#1996)
1 parent a15bac9 commit ed1eb8f

File tree

11 files changed

+77
-123
lines changed

11 files changed

+77
-123
lines changed

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
uses: actions/checkout@v4
2323

2424
- name: Set up Python
25-
uses: actions/setup-python@v5
25+
uses: actions/setup-python@v6
2626
with:
27-
python-version: "3.11"
27+
python-version: "3.12"
2828

2929
- name: Set up uv
3030
uses: astral-sh/setup-uv@v3

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Python
2626
uses: actions/setup-python@v6
2727
with:
28-
python-version: "3.x"
28+
python-version: "3.12"
2929

3030
- name: Retrieve version from tag name
3131
id: retrieve-version

README.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ pip install pyoverkiz
3535

3636
```python
3737
import asyncio
38-
import time
3938

4039
from pyoverkiz.auth.credentials import UsernamePasswordCredentials
4140
from pyoverkiz.client import OverkizClient
42-
from pyoverkiz.models import Action
41+
from pyoverkiz.models import Action, Command
4342
from pyoverkiz.enums import Server, OverkizCommand
4443

4544
USERNAME = ""
@@ -51,16 +50,12 @@ async def main() -> None:
5150
server=Server.SOMFY_EUROPE,
5251
credentials=UsernamePasswordCredentials(USERNAME, PASSWORD),
5352
) as client:
54-
try:
55-
await client.login()
56-
except Exception as exception: # pylint: disable=broad-except
57-
print(exception)
58-
return
53+
await client.login()
5954

6055
devices = await client.get_devices()
6156

6257
for device in devices:
63-
print(f"{device.label} ({device.id}) - {device.controllable_name}")
58+
print(f"{device.label} ({device.device_url}) - {device.controllable_name}")
6459
print(f"{device.widget} - {device.ui_class}")
6560

6661
await client.execute_action_group(
@@ -80,7 +75,7 @@ async def main() -> None:
8075
events = await client.fetch_events()
8176
print(events)
8277

83-
time.sleep(2)
78+
await asyncio.sleep(2)
8479

8580

8681
asyncio.run(main())
@@ -90,7 +85,6 @@ asyncio.run(main())
9085

9186
```python
9287
import asyncio
93-
import time
9488

9589
from pyoverkiz.auth.credentials import LocalTokenCredentials
9690
from pyoverkiz.client import OverkizClient
@@ -110,7 +104,7 @@ async def main() -> None:
110104
) as client:
111105
await client.login()
112106

113-
print("Local API connection succesfull!")
107+
print("Local API connection successful!")
114108

115109
print(await client.get_api_version())
116110

@@ -121,14 +115,14 @@ async def main() -> None:
121115
print(devices)
122116

123117
for device in devices:
124-
print(f"{device.label} ({device.id}) - {device.controllable_name}")
118+
print(f"{device.label} ({device.device_url}) - {device.controllable_name}")
125119
print(f"{device.widget} - {device.ui_class}")
126120

127121
while True:
128122
events = await client.fetch_events()
129123
print(events)
130124

131-
time.sleep(2)
125+
await asyncio.sleep(2)
132126

133127

134128
asyncio.run(main())
@@ -157,7 +151,7 @@ If you use Visual Studio Code with Docker or GitHub Codespaces, you can take adv
157151

158152
- Install [uv](https://docs.astral.sh/uv/getting-started/installation).
159153
- Clone this repository and navigate to it: `cd python-overkiz-api`
160-
- Initialize the project with `uv sync`, then run `uv run pre-commit install`
154+
- Initialize the project with `uv sync`, then run `uv run prek install`
161155

162156
#### Tests
163157

docs/contribute.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ uv run pytest
6969

7070
## Project guidelines
7171

72-
- Use Python 3.10+ features and type annotations.
72+
- Use Python 3.12+ features and type annotations.
7373
- Keep absolute imports and avoid relative imports.
7474
- Preserve existing comments and logging unless your change requires updates.
7575
- Prefer small, focused changes and add tests when behavior changes.

docs/device-control.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ await client.execute_action_group(
169169
- Use a single action group to batch multiple device commands.
170170

171171
```python
172-
from pyoverkiz.enums import OverkizCommand
172+
from pyoverkiz.enums import OverkizCommand, OverkizCommandParam
173173
from pyoverkiz.models import Action, Command
174174

175175
await client.execute_action_group(
@@ -195,6 +195,7 @@ await client.execute_action_group(
195195
],
196196
label="Execution: multiple commands",
197197
)
198+
```
198199

199200
## Limitations and rate limits
200201

docs/error-handling.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

docs/event-handling.md

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -59,38 +59,6 @@ async def main() -> None:
5959
await asyncio.sleep(2)
6060

6161

62-
asyncio.run(main())
63-
```
64-
65-
## Update an in-memory state map
66-
67-
```python
68-
import asyncio
69-
70-
from pyoverkiz.auth.credentials import UsernamePasswordCredentials
71-
from pyoverkiz.client import OverkizClient
72-
from pyoverkiz.enums import Server
73-
74-
75-
async def main() -> None:
76-
async with OverkizClient(
77-
server=Server.SOMFY_EUROPE,
78-
credentials=UsernamePasswordCredentials("you@example.com", "password"),
79-
) as client:
80-
await client.login()
81-
await client.register_event_listener()
82-
83-
state_map: dict[str, dict[str, object]] = {}
84-
85-
while True:
86-
events = await client.fetch_events()
87-
for event in events:
88-
device_id = event.device_id
89-
state_map.setdefault(device_id, {})[event.state_name] = event.state_value
90-
91-
await asyncio.sleep(2)
92-
93-
9462
asyncio.run(main())
9563
```
9664

docs/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This guide will help you install the library, connect to your hub, and perform y
66
77
## Prerequisites
88

9-
- Python 3.10+
9+
- Python 3.12+
1010
- An OverKiz-compatible hub and account
1111

1212
## Install pyOverkiz from PyPI
@@ -97,7 +97,7 @@ Use a cloud server when you want to connect through the vendor’s public API. U
9797

9898
async def main() -> None:
9999
async with OverkizClient(
100-
server=Server.SOMFY_EUROPE,
100+
server=Server.ATLANTIC_COZYTOUCH,
101101
credentials=UsernamePasswordCredentials("you@example.com", "password"),
102102
) as client:
103103
await client.login()

docs/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ pyOverkiz is an async Python library for interacting with Overkiz-based platform
3333
- Somfy TaHoma
3434
- Somfy TaHoma Switch
3535
- Thermor Cozytouch
36-
<!-- - Brandt Smart Control **\*** -->
37-
<!-- - Rexel Energeasy Connect **\*** -->
36+
- Brandt Smart Control **\***
37+
- Rexel Energeasy Connect **\***
38+
39+
\[*] _These servers utilize an authentication method that is currently not supported by this library._

docs/troubleshooting.md

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,65 @@
11
# Troubleshooting
22

3-
## Cloud vs local connectivity
4-
5-
- Cloud servers require internet access and valid vendor credentials.
6-
- Local servers require direct access to the gateway on your LAN.
7-
8-
## SSL and .local hostnames
9-
10-
If the gateway uses a self-signed certificate, pass `verify_ssl=False` when creating `OverkizClient` for local access.
11-
123
## Authentication failures
134

14-
- Confirm the server matches your vendor region.
5+
- Confirm the server matches your vendor and region.
156
- Re-run `login()` and retry the call.
7+
- On `NotAuthenticatedError`, re-authenticate before retrying.
168

179
## Rate limits and concurrency
1810

1911
- Reduce polling frequency.
2012
- Back off on `TooManyRequestsError` or `TooManyConcurrentRequestsError`.
13+
- Use short, jittered delays for transient errors.
14+
15+
```python
16+
import asyncio
17+
18+
from pyoverkiz.auth.credentials import UsernamePasswordCredentials
19+
from pyoverkiz.client import OverkizClient
20+
from pyoverkiz.enums import Server
21+
from pyoverkiz.exceptions import (
22+
NotAuthenticatedError,
23+
TooManyConcurrentRequestsError,
24+
TooManyRequestsError,
25+
)
26+
27+
28+
async def fetch_devices_with_retry() -> None:
29+
async with OverkizClient(
30+
server=Server.SOMFY_EUROPE,
31+
credentials=UsernamePasswordCredentials("you@example.com", "password"),
32+
) as client:
33+
await client.login()
34+
for attempt in range(5):
35+
try:
36+
devices = await client.get_devices()
37+
print(devices)
38+
return
39+
except (TooManyRequestsError, TooManyConcurrentRequestsError):
40+
await asyncio.sleep(0.5 * (attempt + 1))
41+
except NotAuthenticatedError:
42+
await client.login()
43+
44+
45+
asyncio.run(fetch_devices_with_retry())
46+
```
47+
48+
## Common errors
49+
50+
- `NotAuthenticatedError`
51+
- `BadCredentialsError`
52+
- `TooManyRequestsError`
53+
- `TooManyConcurrentRequestsError`
54+
- `TooManyExecutionsError`
55+
- `MaintenanceError`
56+
- `AccessDeniedToGatewayError`
57+
58+
## SSL and local certificates
59+
60+
- Cloud servers require internet access and valid vendor credentials.
61+
- Local servers require direct access to the gateway on your LAN.
62+
- If the gateway uses a self-signed certificate, pass `verify_ssl=False` when creating `OverkizClient` for local access.
2163

2264
## Listener drops
2365

@@ -29,7 +71,11 @@ If the gateway uses a self-signed certificate, pass `verify_ssl=False` when crea
2971
- Refresh setup with `get_setup()` and re-fetch devices.
3072
- Confirm you are using the correct gateway and server.
3173

32-
## Logging tips
74+
## Timeouts
75+
76+
For long-running operations, prefer shorter request timeouts with retries rather than a single long timeout.
77+
78+
## Logging
3379

3480
Enable debug logging in your application to inspect request/response details.
3581

0 commit comments

Comments
 (0)