Skip to content

Commit f1439ad

Browse files
authored
docs(readme): trim duplicated examples, surface docs site (#2101)
## Summary Trims the main README so it leans on the documentation site rather than duplicating tutorial content. - Replaces the two large Cloud + Local API code blocks (~95 lines) with a single short cloud snippet showing the shape of the library, plus a link to the Getting started guide for commands, events, and the local API. - Adds a **Documentation** section near the top with direct links to the high-value docs pages (getting started, core concepts, device control, event handling, migration, SDK reference). - Keeps the intro, supported hubs, installation, projects-using, and contribute sections unchanged. ## Why The duplicated examples drifted easily (especially across the v2 API renames) and made up over half the README. The docs site is versioned alongside the code, so it's the better home for tutorial-depth content. Net change: -76 / +15 lines.
1 parent a87a665 commit f1439ad

4 files changed

Lines changed: 51 additions & 85 deletions

File tree

README.md

Lines changed: 18 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
A fully asynchronous and user-friendly API client for the OverKiz platform. This client enables interaction with smart devices connected to OverKiz, supporting multiple vendors such as Somfy TaHoma and Atlantic Cozytouch.
44

5-
This package is primarily used by Home Assistant Core to provide the Overkiz integration. If you wish to use this package in your own project, refer to the [full documentation](https://imicknl.github.io/python-overkiz-api/), the [examples below](#getting-started), or explore the [Home Assistant source code](https://github.com/home-assistant/core/tree/dev/homeassistant/components/overkiz) for additional usage examples.
5+
This package is primarily used by Home Assistant Core to provide the Overkiz integration. If you wish to use this package in your own project, refer to the [full documentation](https://imicknl.github.io/python-overkiz-api/), the [example below](#getting-started), or explore the [Home Assistant source code](https://github.com/home-assistant/core/tree/dev/homeassistant/components/overkiz) for additional usage examples.
6+
7+
## Documentation
8+
9+
Full documentation is available at **[imicknl.github.io/python-overkiz-api](https://imicknl.github.io/python-overkiz-api/)**:
10+
11+
- [Getting started](https://imicknl.github.io/python-overkiz-api/getting-started/) — cloud and local API setup
12+
- [Core concepts](https://imicknl.github.io/python-overkiz-api/core-concepts/) — clients, servers, credentials, and models
13+
- [Device control](https://imicknl.github.io/python-overkiz-api/device-control/) and [event handling](https://imicknl.github.io/python-overkiz-api/event-handling/)
14+
- [Migrating from v1](https://imicknl.github.io/python-overkiz-api/migration-v2/)
15+
- [SDK reference](https://imicknl.github.io/python-overkiz-api/sdk-reference/)
616

717
## Supported hubs
818

@@ -11,7 +21,7 @@ This package is primarily used by Home Assistant Core to provide the Overkiz int
1121
- Brandt Smart Control **\***
1222
- Hitachi Hi Kumo
1323
- Nexity Eugénie
14-
- Rexel Energeasy Connect **\***
24+
- Rexel Energeasy Connect **\*\***
1525
- Sauter Cozytouch
1626
- Simu (LiveIn2)
1727
- Somfy Connexoon IO
@@ -20,7 +30,8 @@ This package is primarily used by Home Assistant Core to provide the Overkiz int
2030
- Somfy TaHoma Switch
2131
- Thermor Cozytouch
2232

23-
\[*] _These servers utilize an authentication method that is currently not supported by this library. To use this library with these servers, you will need to obtain an access token (by sniffing the original app) and create a local user on the Overkiz API platform._
33+
\[*] _This server's authentication method isn't supported yet. To use it, obtain an access token (by sniffing the original app) and create a local user on the Overkiz API platform._
34+
\[**] _Requires OAuth credentials provided by Rexel._
2435

2536
## Installation
2637

@@ -30,103 +41,32 @@ pip install pyoverkiz
3041

3142
## Getting started
3243

33-
34-
### Cloud API
44+
Connect to the cloud API, authenticate, and list your devices:
3545

3646
```python
3747
import asyncio
3848

3949
from pyoverkiz.auth.credentials import UsernamePasswordCredentials
4050
from pyoverkiz.client import OverkizClient
41-
from pyoverkiz.models import Action, Command
42-
from pyoverkiz.enums import Server, OverkizCommand
43-
44-
USERNAME = ""
45-
PASSWORD = ""
51+
from pyoverkiz.enums import Server
4652

4753

4854
async def main() -> None:
4955
async with OverkizClient(
5056
server=Server.SOMFY_EUROPE,
51-
credentials=UsernamePasswordCredentials(USERNAME, PASSWORD),
57+
credentials=UsernamePasswordCredentials("username", "password"),
5258
) as client:
5359
await client.login()
5460

5561
devices = await client.get_devices()
56-
5762
for device in devices:
5863
print(f"{device.label} ({device.device_url}) - {device.controllable_name}")
59-
print(f"{device.widget} - {device.ui_class}")
60-
61-
await client.execute_action_group(
62-
actions=[
63-
Action(
64-
device_url="io://1234-5678-1234/12345678",
65-
commands=[
66-
Command(name=OverkizCommand.SET_CLOSURE, parameters=[100])
67-
]
68-
)
69-
],
70-
label="Execution via Python",
71-
# mode=ExecutionMode.HIGH_PRIORITY
72-
)
73-
74-
while True:
75-
events = await client.fetch_events()
76-
print(events)
77-
78-
await asyncio.sleep(2)
7964

8065

8166
asyncio.run(main())
8267
```
8368

84-
### Local API
85-
86-
```python
87-
import asyncio
88-
89-
from pyoverkiz.auth.credentials import LocalTokenCredentials
90-
from pyoverkiz.client import OverkizClient
91-
from pyoverkiz.utils import create_local_server_config
92-
93-
LOCAL_GATEWAY = "gateway-xxxx-xxxx-xxxx.local" # or use the IP address of your gateway
94-
VERIFY_SSL = True # set verify_ssl to False if you don't use the .local hostname
95-
96-
97-
async def main() -> None:
98-
token = "" # generate your token via the Somfy app and include it here
99-
100-
async with OverkizClient(
101-
server=create_local_server_config(host=LOCAL_GATEWAY),
102-
credentials=LocalTokenCredentials(token),
103-
verify_ssl=VERIFY_SSL,
104-
) as client:
105-
await client.login()
106-
107-
print("Local API connection successful!")
108-
109-
print(await client.get_api_version())
110-
111-
setup = await client.get_setup()
112-
print(setup)
113-
114-
devices = await client.get_devices()
115-
print(devices)
116-
117-
for device in devices:
118-
print(f"{device.label} ({device.device_url}) - {device.controllable_name}")
119-
print(f"{device.widget} - {device.ui_class}")
120-
121-
while True:
122-
events = await client.fetch_events()
123-
print(events)
124-
125-
await asyncio.sleep(2)
126-
127-
128-
asyncio.run(main())
129-
```
69+
For executing commands, listening to events, and connecting to the **local API**, see the [Getting started guide](https://imicknl.github.io/python-overkiz-api/getting-started/) in the documentation.
13070

13171
## Projects using pyOverkiz
13272

docs/getting-started.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This guide will help you install the library, connect to your hub, and perform your first actions.
44

5-
> Need the official Overkiz cloud API reference? Visit the [Overkiz API Documentation](https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/doc) ([mirror](/api)). Most endpoints are accessible via the pyOverkiz package.
5+
> Need the official Overkiz cloud API reference? Visit the [Overkiz API Documentation](https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/doc) ([mirror](api/index.html)). Most endpoints are accessible via the pyOverkiz package.
66
77
> Upgrading from pyOverkiz 1.x? See the [migration guide](migration-v2.md) for a full list of breaking changes.
88
@@ -178,6 +178,10 @@ Use a cloud server when you want to connect through the vendor’s public API. U
178178
https://my.home-assistant.io/redirect/oauth?code=AUTHORIZATION_CODE&state=STATE_VALUE
179179
```
180180

181+
Compare the returned `state` against the value from step 1 before
182+
continuing, and reject the response if they differ — this is what guards
183+
against CSRF.
184+
181185
**Step 3: Exchange authorization code for access token**
182186

183187
```python
@@ -187,7 +191,11 @@ Use a cloud server when you want to connect through the vendor’s public API. U
187191
from pyoverkiz.enums import Server
188192
from pyoverkiz.const import REXEL_OAUTH_REDIRECT_URI
189193

190-
async def main() -> None:
194+
async def main(returned_state: str) -> None:
195+
# Verify the state echoed back by the redirect matches step 1.
196+
if returned_state != state:
197+
raise ValueError("State mismatch — possible CSRF, aborting.")
198+
191199
# Use the authorization code from the redirect
192200
async with OverkizClient(
193201
server=Server.REXEL,
@@ -197,10 +205,16 @@ Use a cloud server when you want to connect through the vendor’s public API. U
197205
code_verifier=code_verifier, # From step 1
198206
),
199207
) as client:
200-
await client.login()
208+
await client.login() # auto-selects a sole gateway
209+
210+
# Accounts with more than one gateway must select one explicitly.
211+
gateways = await client.discover_gateways()
212+
if len(gateways) > 1:
213+
client.select_gateway(gateways[0].gateway_id)
214+
201215
# Client is now authenticated and ready to use
202216

203-
asyncio.run(main())
217+
asyncio.run(main(returned_state="STATE_VALUE_FROM_REDIRECT"))
204218
```
205219

206220
=== "Rexel (externally-managed token)"

docs/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ pyOverkiz is an async Python library for interacting with Overkiz-based platform
2424

2525
- Atlantic Cozytouch
2626
- Bouygues Flexom
27+
- Brandt Smart Control **\***
2728
- Hitachi Hi Kumo
2829
- Nexity Eugénie
30+
- Rexel Energeasy Connect **\*\***
2931
- Sauter Cozytouch
3032
- Simu (LiveIn2)
3133
- Somfy Connexoon IO
3234
- Somfy Connexoon RTS
3335
- Somfy TaHoma
3436
- Somfy TaHoma Switch
3537
- Thermor Cozytouch
36-
- Brandt Smart Control **\***
37-
- Rexel Energeasy Connect **\***
3838

39-
\[*] _These servers utilize an authentication method that is currently not supported by this library._
39+
\[*] _This server's authentication method isn't supported yet. To use it, obtain an access token (by sniffing the original app) and create a local user on the Overkiz API platform._
40+
\[**] _Requires OAuth credentials provided by Rexel._

docs/troubleshooting.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
- Re-run `login()` and retry the call.
77
- On `NotAuthenticatedError`, re-authenticate before retrying.
88

9+
## Rexel (Energeasy Connect)
10+
11+
Rexel authenticates with OAuth2 and scopes every request to a single gateway, so its failure modes differ from username/password servers.
12+
13+
- `InvalidTokenError: Consent is missing or revoked for Rexel token.` — the access token does not carry the consent Rexel requires. Re-run the OAuth2 authorization flow so the user grants consent again.
14+
- `InvalidTokenError: Error retrieving Rexel access token: ...` — the code exchange or refresh failed (expired authorization code, reused code, or invalid `code_verifier`). Restart the flow from a freshly generated PKCE pair.
15+
- `NoGatewaySelectedError: Multiple Rexel gateways available; call discover_gateways() ...` — the account has more than one gateway and none is selected. Call `discover_gateways()` and pass one id to `select_gateway()` before making device calls. A single-gateway account is auto-selected on `login()`.
16+
- `AccessDeniedToGatewayError` — the selected `gateway_id` is not reachable for this token. Re-discover gateways and select a valid one; if you persisted a `gateway_id`, confirm it still belongs to the account.
17+
918
## Rate limits and concurrency
1019

1120
- Reduce polling frequency.
@@ -54,6 +63,8 @@ asyncio.run(fetch_devices_with_retry())
5463
- `TooManyExecutionsError`
5564
- `MaintenanceError`
5665
- `AccessDeniedToGatewayError`
66+
- `NoGatewaySelectedError`
67+
- `InvalidTokenError`
5768

5869
## SSL and local certificates
5970

0 commit comments

Comments
 (0)