Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Connections / Websocket / Other cleanup #562

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
70aaaca
Refactor Websocket-Connection
hahn-th Nov 17, 2024
92d7219
Add httpx-based connection; use new connection in home
hahn-th Nov 18, 2024
b1de8ee
migrate devices
hahn-th Nov 18, 2024
3e92fb9
delete samples
hahn-th Nov 18, 2024
651f0f6
migrate groups
hahn-th Nov 18, 2024
b7db840
migrate functional channels
hahn-th Nov 18, 2024
58e79a3
make Home inherit from AsyncHome
hahn-th Nov 20, 2024
2ab44e7
increase test coverage
hahn-th Nov 20, 2024
034f3f4
clean up
hahn-th Nov 20, 2024
a72bee9
remove old certs; small clean ups
hahn-th Nov 20, 2024
75cec6a
cleanup requirements; fix test
hahn-th Nov 21, 2024
6d44ec9
dropped python < 3.12 from github workflows
hahn-th Nov 21, 2024
f2ed09e
lower requirements to fit into home assistant
hahn-th Nov 21, 2024
a7613f3
add connectioncontextbuilder, other small refactorings
hahn-th Nov 23, 2024
c19679f
rename download_configuration, get_current_state; fix handling of hea…
hahn-th Nov 24, 2024
00529ca
Fix auth script
hahn-th Nov 26, 2024
6c39bcc
stuff
hahn-th Dec 5, 2024
defbcdc
add flag to hide status logs from connection
hahn-th Dec 15, 2024
cc01d7c
Merge branch 'refs/heads/master' into connection_refactor
hahn-th Dec 15, 2024
647bec4
Fix missing import; rename Connection folder
hahn-th Dec 15, 2024
339ed94
Fix channel event stuff
hahn-th Dec 15, 2024
c649bfb
Add accesspoint id to auth headers
hahn-th Dec 22, 2024
c757705
Add possibility to inject httpx session
hahn-th Dec 22, 2024
232146b
Merge branch 'master' into connection_refactor
hahn-th Feb 16, 2025
c8d9e08
Fix headers in auth
hahn-th Feb 22, 2025
d3cb1ee
Refactor async initialization methods and update README examples
hahn-th Feb 22, 2025
0cc4cad
Update SSL context retrieval in websocket handler to use connection c…
hahn-th Feb 22, 2025
ae70998
Enhance connection handling by allowing custom httpx client session i…
hahn-th Feb 23, 2025
6bf19e4
Allow custom httpx client session in connection initialization
hahn-th Feb 23, 2025
40dfaf3
Code Cleanup and refactorings
hahn-th Feb 23, 2025
c4ba54f
Add access point ID to additional headers in websocket connection
hahn-th Feb 24, 2025
39eabb6
Refactor type hints to support None values in ChannelEvent and Connec…
hahn-th Feb 24, 2025
594ec01
Refactor websocket handling and improve type hints
hahn-th Feb 24, 2025
0994dab
Fix signal handling for SIGINT in websocket connection
hahn-th Feb 24, 2025
dd928ef
Use websocket asyncio client
hahn-th Feb 25, 2025
6c73d55
Refactor CLI to support asynchronous operations and improve signal ha…
hahn-th Feb 25, 2025
8dc3021
Add async fixture for fake_home
hahn-th Feb 25, 2025
b9ea045
Refactor websocket handling and use asynchome i run.py
hahn-th Feb 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,26 +260,26 @@ It’s also possible to use push notifications based on a websocket connection:

```python
# Example function to display incoming events.
def print_events(event_list):
for event in event_list:
print("EventType: {} Data: {}".format(event["eventType"], event["data"]))


# Initialise the API.
config = homematicip.find_and_load_config_file()
home = Home()
home.set_auth_token(config.auth_token)
home.init(config.access_point)

# Add function to handle events and start the connection.
home.onEvent += print_events
home.enable_events()

try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print("Interrupt.")
def print_events(event_list):
for event in event_list:
print("EventType: {} Data: {}".format(event["eventType"], event["data"]))


# Initialise the API.
config = homematicip.find_and_load_config_file()
home = Home()
home.set_auth_token(config.auth_token)
home.init(config.access_point)

# Add function to handle events and start the connection.
home.onEvent += print_events
home.enable_events()

try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print("Interrupt.")
```

## Pathes for config.ini
Expand Down
4 changes: 2 additions & 2 deletions bin/homematicip_cli_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pprint import pprint
import homematicip

from homematicip.aio.home import AsyncHome
from homematicip.async_home import AsyncHome
from homematicip.base.base_connection import HmipConnectionError


Expand All @@ -31,7 +31,7 @@ async def get_home(loop):

home = AsyncHome(loop)
home.set_auth_token(_config.auth_token)
await home.init(_config.access_point)
await home.init_async(_config.access_point)
return home


Expand Down
12 changes: 12 additions & 0 deletions homematicip_demo/client.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-----BEGIN CERTIFICATE-----
MIIByjCCAW+gAwIBAgIUQDAh8y47NcnO/WWc3/nkrU7IV9MwCgYIKoZIzj0EAwIw
QDEXMBUGA1UECgwOdHJ1c3RtZSB2MS4yLjAxJTAjBgNVBAsMHFRlc3RpbmcgQ0Eg
I1EtenFyeGh3Vl8zV01NWEYwIBcNMDAwMTAxMDAwMDAwWhgPMzAwMDAxMDEwMDAw
MDBaMEAxFzAVBgNVBAoMDnRydXN0bWUgdjEuMi4wMSUwIwYDVQQLDBxUZXN0aW5n
IENBICNRLXpxcnhod1ZfM1dNTVhGMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE
kKHIZlTL0OPtVRzmqskzQeDBChB/PH7T0hOAxZ21iPY5ZIU0g803huQinL/qE8T6
EZR3JiZPsi0snTLEWfejf6NFMEMwHQYDVR0OBBYEFPRnOfQB4OXdgHNiBfjeZhEd
wHT2MBIGA1UdEwEB/wQIMAYBAf8CAQkwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49
BAMCA0kAMEYCIQCd3KQr2apEcvYBWrqrfVxyi5TPBrVVgEkVjrsoM8V7PgIhAM/t
YBsqJyPLz8TXXnaAYbvkG/5fJ6y33nsFU2gUMKWD
-----END CERTIFICATE-----
4 changes: 4 additions & 0 deletions homematicip_demo/fake_cloud_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ async def post_hmip_home_heating_deactivateVacation(

return web.json_response(None)

@validate_authorization
async def post_hmip_home_heating_setCooling(self, request: web.Request) -> web.Response:
return web.json_response()

# endregion

# region rule
Expand Down
19 changes: 0 additions & 19 deletions homematicip_demo/server.crt

This file was deleted.

32 changes: 5 additions & 27 deletions homematicip_demo/server.key
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA5SCSfeNf+x2DoYa54YMcIz6ychRVjd8zoPiNePIGGdPdOoob
WUnAIZhHXUAP7ZIlimlT7DhBoXphnAx5kErL6ZVD34KtVjIpATuP0fxeA0QdX0FD
OitqBPyWJrx4Llo5DNR5fwDEJJJuyfJP9f5LUgp13S3Es55k4PqlbAmhzd2kMQuC
WTZvW3OHI3YaNC/dpEePnk/HvXbsx5nJFfA4MWleulufCKHg6qQDgRi2aoVtm20Y
TMyF3hjmaRvK5FsYz4gT32hAky+ciSMB9SjRoqcOtwAiRYKTAshyL1Mgbq7dHU/Z
Of4dhWe3NBngGfFqdsU1DlL0BF3fnb0SY7cHNQIDAQABAoIBAG9BJ6B03VADfrzZ
vDwh+3Gpqd/2u6wNqvYIejk123yDATLBiJIMW3x0goJm7tT+V7gjeJqEnmmYEPlC
nWxQxT6AOdq3iw8FgB+XGjhuAAA5/MEZ4VjHZ81QEGBytzBaosT2DqB6cMMJTz5D
qEvb1Brb9WsWJCLLUFRloBkbfDOG9lMvt34ixYTTmqjsVj5WByD5BhzKH51OJ72L
00IYpvrsEOtSev1hNV4199CHPYE90T/YQVooRBiHtTcfN+/KNVJu6Rf/zcaJ3WMS
1l3MBI8HwMimjKKkbddpoMHyFMtSNmS9Yq+4a9w7XZo1F5rt88hYSCtAF8HRAarX
0VBCJmkCgYEA9HenBBnmfDoN857femzoTHdWQQrZQ4YPAKHvKPlcgudizE5tQbs0
iTpwm+IsecgJS2Rio7zY+P7A5nKFz3N5c0IX3smYo0J2PoakkLAm25KMxFZYBuz4
MFWVdfByAU7d28BdNfyOVbA2kU2eal9lJ0yPLpMLbH8+bbvw5uBS808CgYEA7++p
ftwib3DvKWMpl6G5eA1C2xprdbE0jm2fSr3LYp/vZ4QN2V6kK2YIlyUqQvhYCnxX
oIP3v2MWDRHKKwJtBWR4+t23PaDaSXS2Ifm0qhRxwSm/oqpAJQXbR7VzxXp4/4FP
1SgkLe51bubc4h+cDngqBLcplCanvj52CqhqzDsCgYAEIhG8zANNjl22BLWaiETV
Jh9bMifCMH4IcLRuaOjbfbX55kmKlvOobkiBGi3OUUd28teIFSVF8GiqfL0uaLFg
9XkZ1yaxe+or3HLjz1aY171xhFQwqcj4aDoCqHIE+6Rclr/8raxqXnRNuJY5DivT
okO5cdr7lpsjl83W2WwNmQKBgCPXi1xWChbXqgJmu8nY8NnMMVaFpdPY+t7j5U3G
+GDtP1gZU/BKwP9yqInblWqXqp82X+isjg/a/2pIZAj0vdB2Z9Qh1sOwCau7cZG1
uZVGpI+UavojsJ1XOKCHrJmtZ/HTIVfYPT9XRdehSRHGYwuOS8iUi/ODqr8ymXOS
IRINAoGBAMEmhTihgFz6Y8ezRK3QTubguehHZG1zIvtgVhOk+8hRUTSJPI9nBJPC
4gOZsPx4g2oLK6PiudPR79bhxRxPACCMnXkdwZ/8FaIdmvRHsWVs8T80wID0wthI
r5hW4uqi9CcKZrGWH7mx9cVJktspeGUczvKyzNMfCaojwzA/49Z1
-----END RSA PRIVATE KEY-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIK5/HnR9nKOUN6khHKmBi+cFBAuyNvXxKdNRbB5+HaDOoAoGCCqGSM49
AwEHoUQDQgAEJRnuDisT95DvNlxQ51HowkWJRuDholQOG+axoZAmxmndcadKbyff
ToQ2CUFJXIlRVXjIh9PMNdE1YrnEFMahFw==
-----END EC PRIVATE KEY-----
15 changes: 15 additions & 0 deletions homematicip_demo/server.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----BEGIN CERTIFICATE-----
MIICRjCCAeugAwIBAgIUfbtenV+j6flJfAJo5rSbvTbxPHMwCgYIKoZIzj0EAwIw
QDEXMBUGA1UECgwOdHJ1c3RtZSB2MS4yLjAxJTAjBgNVBAsMHFRlc3RpbmcgQ0Eg
I1EtenFyeGh3Vl8zV01NWEYwIBcNMDAwMTAxMDAwMDAwWhgPMzAwMDAxMDEwMDAw
MDBaMEIxFzAVBgNVBAoMDnRydXN0bWUgdjEuMi4wMScwJQYDVQQLDB5UZXN0aW5n
IGNlcnQgI3Vwd1RCS2xXS1ZndkctbFUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC
AAQlGe4OKxP3kO82XFDnUejCRYlG4OGiVA4b5rGhkCbGad1xp0pvJ99OhDYJQUlc
iVFVeMiH08w10TViucQUxqEXo4G+MIG7MB0GA1UdDgQWBBR1tKNvUFqIzl/NYJiA
RrF4gswtPzAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFPRnOfQB4OXdgHNiBfje
ZhEdwHT2MC8GA1UdEQEB/wQlMCOCCWxvY2FsaG9zdIcEfwAAAYcQAAAAAAAAAAAA
AAAAAAAAATAOBgNVHQ8BAf8EBAMCBaAwKgYDVR0lAQH/BCAwHgYIKwYBBQUHAwIG
CCsGAQUFBwMBBggrBgEFBQcDAzAKBggqhkjOPQQDAgNJADBGAiEAyqU1lqcvBeHO
xnASqRqpPNjarM9BitPvUfJwVhrDvLwCIQDy6mzQrRdsw79fuO4lzeEgpZqWW4aP
OM+hFmEYXiBmIg==
-----END CERTIFICATE-----
105 changes: 0 additions & 105 deletions homematicip_samples/.gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions homematicip_samples/CheckPresenceOnPing/CheckPresenceOnPing.pyproj

This file was deleted.

11 changes: 0 additions & 11 deletions homematicip_samples/CheckPresenceOnPing/Readme.md

This file was deleted.

2 changes: 0 additions & 2 deletions homematicip_samples/CheckPresenceOnPing/requirements.txt

This file was deleted.

49 changes: 0 additions & 49 deletions homematicip_samples/CheckPresenceOnPing/scan.py

This file was deleted.

8 changes: 0 additions & 8 deletions homematicip_samples/ControlDevices/Readme.md

This file was deleted.

23 changes: 0 additions & 23 deletions homematicip_samples/ControlDevices/switch_on_off.py

This file was deleted.

Loading