pysmarlaapi 0.3.0__py3-none-any.whl → 0.4.0__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.

Potentially problematic release.


This version of pysmarlaapi might be problematic. Click here for more details.

pysmarlaapi/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "0.3.0"
1
+ __version__ = "0.4.0"
2
2
 
3
3
  from .classes import Connection
4
4
  from .federwiege import Federwiege
@@ -4,7 +4,7 @@ import threading
4
4
  from ..classes import Connection
5
5
  from ..connection_hub import ConnectionHub
6
6
  from .classes import Service
7
- from .services import AnalyserService, BabywiegeService
7
+ from .services import AnalyserService, BabywiegeService, InfoService
8
8
 
9
9
 
10
10
  class Federwiege:
@@ -28,6 +28,7 @@ class Federwiege:
28
28
  self.services: dict[str, Service] = {
29
29
  "babywiege": BabywiegeService(self.hub),
30
30
  "analyser": AnalyserService(self.hub),
31
+ "info": InfoService(self.hub),
31
32
  }
32
33
 
33
34
  self.registered = False
@@ -8,8 +8,8 @@ _VT = TypeVar("_VT")
8
8
 
9
9
  class Property(Generic[_VT]):
10
10
 
11
- def __init__(self, connection_hub: ConnectionHub):
12
- self.hub = connection_hub
11
+ def __init__(self, hub: ConnectionHub):
12
+ self.hub = hub
13
13
  self.value: _VT = None
14
14
  self.listeners = set()
15
15
  self.lock = asyncio.Lock()
@@ -1,11 +1,9 @@
1
- from ...connection_hub import ConnectionHub
2
1
  from .property import Property
3
2
 
4
3
 
5
4
  class Service:
6
5
 
7
- def __init__(self, connection_hub: ConnectionHub):
8
- self.hub = connection_hub
6
+ def __init__(self):
9
7
  self.registered = False
10
8
  self.props: dict[str, Property] = {}
11
9
 
@@ -1,2 +1,3 @@
1
1
  from .analyser_service import AnalyserService
2
2
  from .babywiege_service import BabywiegeService
3
+ from .info_service import InfoService
@@ -4,10 +4,11 @@ from ..classes import Property, Service
4
4
 
5
5
  class AnalyserService(Service):
6
6
 
7
- def __init__(self, connection_hub: ConnectionHub):
8
- super().__init__(connection_hub)
9
- self.add_property("oscillation", OscillationProperty(self.hub))
10
- self.add_property("activity", ActivityProperty(self.hub))
7
+ def __init__(self, hub: ConnectionHub):
8
+ super().__init__()
9
+ self.add_property("oscillation", OscillationProperty(hub))
10
+ self.add_property("activity", ActivityProperty(hub))
11
+ self.add_property("swing_count", SwingCountProperty(hub))
11
12
 
12
13
 
13
14
  class OscillationProperty(Property[list[int, int]]):
@@ -17,8 +18,8 @@ class OscillationProperty(Property[list[int, int]]):
17
18
  self.set(value, push=False)
18
19
  await self.notify_listeners(value)
19
20
 
20
- def __init__(self, parent: Service):
21
- super().__init__(parent)
21
+ def __init__(self, hub: ConnectionHub):
22
+ super().__init__(hub)
22
23
  self.value = [0, 0]
23
24
 
24
25
  def pull(self):
@@ -35,8 +36,8 @@ class ActivityProperty(Property[int]):
35
36
  self.set(value, push=False)
36
37
  await self.notify_listeners(value)
37
38
 
38
- def __init__(self, parent: Service):
39
- super().__init__(parent)
39
+ def __init__(self, hub: ConnectionHub):
40
+ super().__init__(hub)
40
41
  self.value = 0
41
42
 
42
43
  def pull(self):
@@ -44,3 +45,21 @@ class ActivityProperty(Property[int]):
44
45
 
45
46
  def register(self):
46
47
  self.hub.client.on("GetActivityCallback", self.on_callback)
48
+
49
+
50
+ class SwingCountProperty(Property[int]):
51
+
52
+ async def on_callback(self, args):
53
+ value = args[0]["value"]
54
+ self.set(value, push=False)
55
+ await self.notify_listeners(value)
56
+
57
+ def __init__(self, hub: ConnectionHub):
58
+ super().__init__(hub)
59
+ self.value = 0
60
+
61
+ def pull(self):
62
+ self.hub.send_serialized_data("GetSwingCount")
63
+
64
+ def register(self):
65
+ self.hub.client.on("GetSwingCountCallback", self.on_callback)
@@ -4,11 +4,11 @@ from ..classes import Property, Service
4
4
 
5
5
  class BabywiegeService(Service):
6
6
 
7
- def __init__(self, connection_hub: ConnectionHub):
8
- super().__init__(connection_hub)
9
- self.add_property("swing_active", SwingActiveProperty(self.hub))
10
- self.add_property("intensity", IntensityProperty(self.hub))
11
- self.add_property("smartmode", SmartModeProperty(self.hub))
7
+ def __init__(self, hub: ConnectionHub):
8
+ super().__init__()
9
+ self.add_property("swing_active", SwingActiveProperty(hub))
10
+ self.add_property("intensity", IntensityProperty(hub))
11
+ self.add_property("smartmode", SmartModeProperty(hub))
12
12
 
13
13
 
14
14
  class SwingActiveProperty(Property[bool]):
@@ -18,8 +18,8 @@ class SwingActiveProperty(Property[bool]):
18
18
  self.set(value, push=False)
19
19
  await self.notify_listeners(value)
20
20
 
21
- def __init__(self, parent: Service):
22
- super().__init__(parent)
21
+ def __init__(self, hub: ConnectionHub):
22
+ super().__init__(hub)
23
23
  self.value = False
24
24
 
25
25
  def pull(self):
@@ -39,8 +39,8 @@ class IntensityProperty(Property[int]):
39
39
  self.set(value, push=False)
40
40
  await self.notify_listeners(value)
41
41
 
42
- def __init__(self, parent: Service):
43
- super().__init__(parent)
42
+ def __init__(self, hub: ConnectionHub):
43
+ super().__init__(hub)
44
44
  self.value = 0
45
45
 
46
46
  def pull(self):
@@ -60,8 +60,8 @@ class SmartModeProperty(Property[bool]):
60
60
  self.set(value, push=False)
61
61
  await self.notify_listeners(value)
62
62
 
63
- def __init__(self, parent: Service):
64
- super().__init__(parent)
63
+ def __init__(self, hub: ConnectionHub):
64
+ super().__init__(hub)
65
65
  self.value = False
66
66
 
67
67
  def pull(self):
@@ -0,0 +1,46 @@
1
+ from ...connection_hub import ConnectionHub
2
+ from ..classes import Property, Service
3
+
4
+
5
+ class InfoService(Service):
6
+
7
+ def __init__(self, hub: ConnectionHub):
8
+ super().__init__()
9
+ self.add_property("display_name", DisplayNameProperty(hub))
10
+ self.add_property("version", VersionProperty(hub))
11
+
12
+
13
+ class DisplayNameProperty(Property[str]):
14
+
15
+ async def on_callback(self, args):
16
+ value = args[0]["value"]
17
+ self.set(value, push=False)
18
+ await self.notify_listeners(value)
19
+
20
+ def __init__(self, hub: ConnectionHub):
21
+ super().__init__(hub)
22
+ self.value = "Smarla"
23
+
24
+ def pull(self):
25
+ self.hub.send_serialized_data("GetDisplayName")
26
+
27
+ def register(self):
28
+ self.hub.client.on("GetDisplayNameCallback", self.on_callback)
29
+
30
+
31
+ class VersionProperty(Property[str]):
32
+
33
+ async def on_callback(self, args):
34
+ value = args[0]["value"]
35
+ self.set(value, push=False)
36
+ await self.notify_listeners(value)
37
+
38
+ def __init__(self, hub: ConnectionHub):
39
+ super().__init__(hub)
40
+ self.value = "1.0.0"
41
+
42
+ def pull(self):
43
+ self.hub.send_serialized_data("GetVersion")
44
+
45
+ def register(self):
46
+ self.hub.client.on("GetVersionCallback", self.on_callback)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pysmarlaapi
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Swing2Sleep Smarla API
5
5
  Author-email: Robin Lintermann <robin.lintermann@explicatis.com>
6
6
  Requires-Python: >=3.11.9
@@ -0,0 +1,16 @@
1
+ pysmarlaapi/__init__.py,sha256=7NFNMBkl7qODMJYvG4pHJy4qdfoAqloPqXoKRbkrUoE,94
2
+ pysmarlaapi/classes/__init__.py,sha256=4F4LRzLQtj6AmzrXn74iHEZl-YElpMkb7MhEGkab504,71
3
+ pysmarlaapi/classes/auth_token.py,sha256=bxpp0gDzWuLzNSgUksN4mMlyvkDWLhqs3fT76Mb-0c8,950
4
+ pysmarlaapi/classes/connection.py,sha256=tmMaPEN1lu8fC8cV-SX6l4aVUkaAOh-32aZUhR7nMSU,1403
5
+ pysmarlaapi/connection_hub/__init__.py,sha256=6bLOH7cY_AyZwsMLKlFEA-kwmhKCI4pb0aLrflgfWdQ,4600
6
+ pysmarlaapi/federwiege/__init__.py,sha256=uFExZeBgoKfmfE7YZ20V_AynZzN61ZrH2DdztGOhjq8,1800
7
+ pysmarlaapi/federwiege/classes/__init__.py,sha256=1cCe3iToaNmbUfy_7PynoPenNHtVcKC03rFc4ADqnbE,62
8
+ pysmarlaapi/federwiege/classes/property.py,sha256=7CmNN-vQ-6BBYDvp9I7Md15S-LvADlAGpZr4HXlW14U,1062
9
+ pysmarlaapi/federwiege/classes/service.py,sha256=Um2EQYtHdPvUGn4Q9cZM45yciSFBMNYL6Nyf5ln2WMc,660
10
+ pysmarlaapi/federwiege/services/__init__.py,sha256=20A54vK90HAmAF3VvXSAaHSujCVr0o6xqT6YG2G582c,135
11
+ pysmarlaapi/federwiege/services/analyser_service.py,sha256=PJmPqEIytrb9RUyuHDm5ShvpyrmiAXWO0LfINku_NVE,1854
12
+ pysmarlaapi/federwiege/services/babywiege_service.py,sha256=Uup7oU_GUImNAOojbRMbKdROZ2X9Vmu7Eqq43ZdcXbA,2127
13
+ pysmarlaapi/federwiege/services/info_service.py,sha256=dfODCRBK3Vinme73IlmjSqsvwfPrXeqDz_EEA9cWnhk,1294
14
+ pysmarlaapi-0.4.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
15
+ pysmarlaapi-0.4.0.dist-info/METADATA,sha256=9yzsOhL2NBsUH7VtuAmgu-GR_N4PgluXJ5xDeeGdKh8,925
16
+ pysmarlaapi-0.4.0.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- pysmarlaapi/__init__.py,sha256=rYc5cElE-1A-6kEjomlPREjWX-q3rtM96h_cU1qBtcE,94
2
- pysmarlaapi/classes/__init__.py,sha256=4F4LRzLQtj6AmzrXn74iHEZl-YElpMkb7MhEGkab504,71
3
- pysmarlaapi/classes/auth_token.py,sha256=bxpp0gDzWuLzNSgUksN4mMlyvkDWLhqs3fT76Mb-0c8,950
4
- pysmarlaapi/classes/connection.py,sha256=tmMaPEN1lu8fC8cV-SX6l4aVUkaAOh-32aZUhR7nMSU,1403
5
- pysmarlaapi/connection_hub/__init__.py,sha256=6bLOH7cY_AyZwsMLKlFEA-kwmhKCI4pb0aLrflgfWdQ,4600
6
- pysmarlaapi/federwiege/__init__.py,sha256=6Hk_Oqrk8AKoomNGdq3o-2pBW6E8ejvKArAc0DdOBGw,1743
7
- pysmarlaapi/federwiege/classes/__init__.py,sha256=1cCe3iToaNmbUfy_7PynoPenNHtVcKC03rFc4ADqnbE,62
8
- pysmarlaapi/federwiege/classes/property.py,sha256=YZnpw0cD2NUPnlWo6TBjOzNTWcSJG1tvArXs1dRT6dY,1084
9
- pysmarlaapi/federwiege/classes/service.py,sha256=J_4WjL0SyyxwlvBp-zpO9EaXNUUcTnOLoPfSdU1FrjA,771
10
- pysmarlaapi/federwiege/services/__init__.py,sha256=F_54VQIYWAZaGm2ITzCJeG7G-6ARW2PfWvqaut56WN8,96
11
- pysmarlaapi/federwiege/services/analyser_service.py,sha256=tQb6ijNlrtbz4igH7awdoBnOVHu4TO6SPJmMW5yeT3A,1340
12
- pysmarlaapi/federwiege/services/babywiege_service.py,sha256=SJFPAsZaf4nSRmt6ojJq-9MtWqk1MdtcaPzBmTN3H0Y,2167
13
- pysmarlaapi-0.3.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
14
- pysmarlaapi-0.3.0.dist-info/METADATA,sha256=8XEqDobkr-EKHAYZGT2QQKRe0AJBRSqMqGn2bO6YpPM,925
15
- pysmarlaapi-0.3.0.dist-info/RECORD,,