livisi 0.0.19__py3-none-any.whl → 0.0.21__py3-none-any.whl
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.
- livisi/__init__.py +1 -1
- livisi/livisi_event.py +2 -3
- livisi/websocket.py +18 -12
- {livisi-0.0.19.dist-info → livisi-0.0.21.dist-info}/METADATA +1 -1
- livisi-0.0.21.dist-info/RECORD +11 -0
- livisi-0.0.19.dist-info/RECORD +0 -11
- {livisi-0.0.19.dist-info → livisi-0.0.21.dist-info}/LICENSE +0 -0
- {livisi-0.0.19.dist-info → livisi-0.0.21.dist-info}/WHEEL +0 -0
- {livisi-0.0.19.dist-info → livisi-0.0.21.dist-info}/top_level.txt +0 -0
livisi/__init__.py
CHANGED
livisi/livisi_event.py
CHANGED
livisi/websocket.py
CHANGED
@@ -3,11 +3,11 @@ from typing import Callable
|
|
3
3
|
import urllib.parse
|
4
4
|
|
5
5
|
import websockets
|
6
|
-
|
6
|
+
import json
|
7
7
|
|
8
|
-
from
|
8
|
+
from livisi.livisi_event import LivisiEvent
|
9
9
|
|
10
|
-
from
|
10
|
+
from livisi import AioLivisi
|
11
11
|
from .const import (
|
12
12
|
AVATAR_PORT,
|
13
13
|
IS_REACHABLE,
|
@@ -30,18 +30,18 @@ from .const import (
|
|
30
30
|
class Websocket:
|
31
31
|
"""Represents the websocket class."""
|
32
32
|
|
33
|
-
def __init__(self,
|
33
|
+
def __init__(self, livisi: AioLivisi) -> None:
|
34
34
|
"""Initialize the websocket."""
|
35
|
-
self.
|
35
|
+
self.livisi = livisi
|
36
36
|
self.connection_url: str = None
|
37
37
|
|
38
38
|
async def connect(self, on_data, on_close, port: int) -> None:
|
39
39
|
"""Connect to the socket."""
|
40
40
|
if port == AVATAR_PORT:
|
41
|
-
token = urllib.parse.quote(self.
|
41
|
+
token = urllib.parse.quote(self.livisi.token)
|
42
42
|
else:
|
43
|
-
token = self.
|
44
|
-
ip_address = self.
|
43
|
+
token = self.livisi.token
|
44
|
+
ip_address = self.livisi.livisi_connection_data["ip_address"]
|
45
45
|
self.connection_url = f"ws://{ip_address}:{port}/events?token={token}"
|
46
46
|
try:
|
47
47
|
async with websockets.connect(
|
@@ -65,14 +65,20 @@ class Websocket:
|
|
65
65
|
"""Used when data is transmited using the websocket."""
|
66
66
|
async for message in websocket:
|
67
67
|
try:
|
68
|
-
|
69
|
-
|
68
|
+
parsed_json = json.loads(message)
|
69
|
+
# Only include keys that are fields in the LivisiEvent dataclass
|
70
|
+
event_data_dict = {
|
71
|
+
f.name: parsed_json.get(f.name)
|
72
|
+
for f in fields(LivisiEvent)
|
73
|
+
}
|
74
|
+
event_data = LivisiEvent(**event_data_dict)
|
75
|
+
except json.JSONDecodeError:
|
76
|
+
continue
|
77
|
+
if event_data.properties is None:
|
70
78
|
continue
|
71
79
|
|
72
80
|
if "device" in event_data.source:
|
73
81
|
event_data.source = event_data.source.replace("/device/", "")
|
74
|
-
if event_data.properties is None:
|
75
|
-
continue
|
76
82
|
|
77
83
|
if event_data.type == EVENT_STATE_CHANGED:
|
78
84
|
if ON_STATE in event_data.properties.keys():
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: livisi
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.21
|
4
4
|
Summary: Connection library for the abandoned Livisi Smart Home system
|
5
5
|
Author-email: Stefan Iacob <stefan.iacob.extern@livisi.de>, Felix Rotthowe <felix@planbnet.org>
|
6
6
|
License: Apache License
|
@@ -0,0 +1,11 @@
|
|
1
|
+
livisi/__init__.py,sha256=WfjrI1lKksaRhrL8vgN7rOWmmHvA1cxVcXrmdd3TSAc,220
|
2
|
+
livisi/aiolivisi.py,sha256=kOqeNa-dg3d5lApd-_wzbw43dkD5UjPcf7m_QvQAHeg,9539
|
3
|
+
livisi/const.py,sha256=1JaKhrRSwevc8mWwiTONEITVFJEOGjysDvUHTazF3T0,1088
|
4
|
+
livisi/errors.py,sha256=ys6cS5yNGXPmJbU9BtUBuhlWqaKkcGSsnie8HMVnvDU,540
|
5
|
+
livisi/livisi_event.py,sha256=Z3VN1nW737O1xMt1yj62lC0KTiiXFIlRPEog33IsJpw,456
|
6
|
+
livisi/websocket.py,sha256=D2z7zP-hYkEtQTWFW01l4CRSGCEp7MUVSBNiwjTaVGI,4452
|
7
|
+
livisi-0.0.21.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
8
|
+
livisi-0.0.21.dist-info/METADATA,sha256=o3l_pisspoT_0Z4B6DjAwhpLtNKcGyrPcQW9pk__zCo,13832
|
9
|
+
livisi-0.0.21.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
10
|
+
livisi-0.0.21.dist-info/top_level.txt,sha256=ctiU5MMpBSwoQR7mJWIuyB1ND1_g004Xa3vNmMsSiCs,7
|
11
|
+
livisi-0.0.21.dist-info/RECORD,,
|
livisi-0.0.19.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
livisi/__init__.py,sha256=e-7-FaNhioPB18drtbyLaLDfy7XHCZf_QQP42TpBORw,219
|
2
|
-
livisi/aiolivisi.py,sha256=kOqeNa-dg3d5lApd-_wzbw43dkD5UjPcf7m_QvQAHeg,9539
|
3
|
-
livisi/const.py,sha256=1JaKhrRSwevc8mWwiTONEITVFJEOGjysDvUHTazF3T0,1088
|
4
|
-
livisi/errors.py,sha256=ys6cS5yNGXPmJbU9BtUBuhlWqaKkcGSsnie8HMVnvDU,540
|
5
|
-
livisi/livisi_event.py,sha256=vgP4Ol8OcAt54xpgL0gwov9MsIDxrIqb3ODIOwD8UQU,510
|
6
|
-
livisi/websocket.py,sha256=YEjRvSI9JHGxCPOIXke6_muW73Ar5GIQ6y8xIlEY03w,4211
|
7
|
-
livisi-0.0.19.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
8
|
-
livisi-0.0.19.dist-info/METADATA,sha256=rSuj4eHMLvdmVxawkOOmshQzoEsXBX5OSEF_BuFuB5o,13832
|
9
|
-
livisi-0.0.19.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
10
|
-
livisi-0.0.19.dist-info/top_level.txt,sha256=ctiU5MMpBSwoQR7mJWIuyB1ND1_g004Xa3vNmMsSiCs,7
|
11
|
-
livisi-0.0.19.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|