pysmarlaapi 0.7.1__py3-none-any.whl → 0.8.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 +1 -1
- pysmarlaapi/classes/connection.py +12 -8
- pysmarlaapi/federwiege/classes/property.py +2 -2
- pysmarlaapi/federwiege/services/analyser_service.py +4 -7
- pysmarlaapi/federwiege/services/babywiege_service.py +4 -7
- pysmarlaapi/federwiege/services/info_service.py +2 -4
- {pysmarlaapi-0.7.1.dist-info → pysmarlaapi-0.8.0.dist-info}/METADATA +1 -1
- pysmarlaapi-0.8.0.dist-info/RECORD +17 -0
- pysmarlaapi-0.7.1.dist-info/RECORD +0 -17
- {pysmarlaapi-0.7.1.dist-info → pysmarlaapi-0.8.0.dist-info}/WHEEL +0 -0
- {pysmarlaapi-0.7.1.dist-info → pysmarlaapi-0.8.0.dist-info}/licenses/LICENSE +0 -0
pysmarlaapi/__init__.py
CHANGED
|
@@ -27,22 +27,26 @@ class Connection:
|
|
|
27
27
|
async def refresh_token(self) -> bool:
|
|
28
28
|
try:
|
|
29
29
|
async with aiohttp.ClientSession(self.url) as session:
|
|
30
|
-
|
|
31
|
-
"/api/AppParing/getToken",
|
|
32
|
-
headers={"accept": "*/*", "Content-Type": "application/json"},
|
|
33
|
-
data=jsonpickle.encode(self.token, unpicklable=False),
|
|
34
|
-
)
|
|
30
|
+
content = await self._get_token(session)
|
|
35
31
|
except (aiohttp.ClientError, asyncio.TimeoutError):
|
|
36
32
|
return False
|
|
37
33
|
|
|
38
|
-
if
|
|
34
|
+
if not content:
|
|
39
35
|
return False
|
|
40
36
|
|
|
41
|
-
content = await response.json()
|
|
42
|
-
|
|
43
37
|
try:
|
|
44
38
|
self.token = AuthToken.from_json(content)
|
|
45
39
|
except ValueError:
|
|
46
40
|
return False
|
|
47
41
|
|
|
48
42
|
return True
|
|
43
|
+
|
|
44
|
+
async def _get_token(self, session: aiohttp.ClientSession):
|
|
45
|
+
async with await session.post(
|
|
46
|
+
"/api/AppParing/getToken",
|
|
47
|
+
headers={"accept": "*/*", "Content-Type": "application/json"},
|
|
48
|
+
data=jsonpickle.encode(self.token, unpicklable=False),
|
|
49
|
+
) as response:
|
|
50
|
+
if response.status != 200:
|
|
51
|
+
return None
|
|
52
|
+
return await response.json()
|
|
@@ -8,9 +8,9 @@ _VT = TypeVar("_VT")
|
|
|
8
8
|
|
|
9
9
|
class Property(Generic[_VT]):
|
|
10
10
|
|
|
11
|
-
def __init__(self, hub: ConnectionHub):
|
|
11
|
+
def __init__(self, hub: ConnectionHub, value: _VT):
|
|
12
12
|
self.hub = hub
|
|
13
|
-
self.value: _VT =
|
|
13
|
+
self.value: _VT = value
|
|
14
14
|
self.listeners = set()
|
|
15
15
|
self.lock = asyncio.Lock()
|
|
16
16
|
|
|
@@ -11,7 +11,7 @@ class AnalyserService(Service):
|
|
|
11
11
|
self.add_property("swing_count", SwingCountProperty(hub))
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
class OscillationProperty(Property[list[int
|
|
14
|
+
class OscillationProperty(Property[list[int]]):
|
|
15
15
|
|
|
16
16
|
async def on_callback(self, args):
|
|
17
17
|
value = args[0]["value"]
|
|
@@ -19,8 +19,7 @@ class OscillationProperty(Property[list[int, int]]):
|
|
|
19
19
|
await self.notify_listeners(value)
|
|
20
20
|
|
|
21
21
|
def __init__(self, hub: ConnectionHub):
|
|
22
|
-
super().__init__(hub)
|
|
23
|
-
self.value = [0, 0]
|
|
22
|
+
super().__init__(hub, [0, 0])
|
|
24
23
|
|
|
25
24
|
def pull(self):
|
|
26
25
|
self.hub.send_serialized_data("GetOscillation")
|
|
@@ -37,8 +36,7 @@ class ActivityProperty(Property[int]):
|
|
|
37
36
|
await self.notify_listeners(value)
|
|
38
37
|
|
|
39
38
|
def __init__(self, hub: ConnectionHub):
|
|
40
|
-
super().__init__(hub)
|
|
41
|
-
self.value = 0
|
|
39
|
+
super().__init__(hub, 0)
|
|
42
40
|
|
|
43
41
|
def pull(self):
|
|
44
42
|
self.hub.send_serialized_data("GetActivity")
|
|
@@ -55,8 +53,7 @@ class SwingCountProperty(Property[int]):
|
|
|
55
53
|
await self.notify_listeners(value)
|
|
56
54
|
|
|
57
55
|
def __init__(self, hub: ConnectionHub):
|
|
58
|
-
super().__init__(hub)
|
|
59
|
-
self.value = 0
|
|
56
|
+
super().__init__(hub, 0)
|
|
60
57
|
|
|
61
58
|
def pull(self):
|
|
62
59
|
self.hub.send_serialized_data("GetSwingCount")
|
|
@@ -8,7 +8,7 @@ class BabywiegeService(Service):
|
|
|
8
8
|
super().__init__()
|
|
9
9
|
self.add_property("swing_active", SwingActiveProperty(hub))
|
|
10
10
|
self.add_property("intensity", IntensityProperty(hub))
|
|
11
|
-
self.add_property("
|
|
11
|
+
self.add_property("smart_mode", SmartModeProperty(hub))
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class SwingActiveProperty(Property[bool]):
|
|
@@ -19,8 +19,7 @@ class SwingActiveProperty(Property[bool]):
|
|
|
19
19
|
await self.notify_listeners(value)
|
|
20
20
|
|
|
21
21
|
def __init__(self, hub: ConnectionHub):
|
|
22
|
-
super().__init__(hub)
|
|
23
|
-
self.value = False
|
|
22
|
+
super().__init__(hub, False)
|
|
24
23
|
|
|
25
24
|
def pull(self):
|
|
26
25
|
self.hub.send_serialized_data("GetSwingActive")
|
|
@@ -40,8 +39,7 @@ class IntensityProperty(Property[int]):
|
|
|
40
39
|
await self.notify_listeners(value)
|
|
41
40
|
|
|
42
41
|
def __init__(self, hub: ConnectionHub):
|
|
43
|
-
super().__init__(hub)
|
|
44
|
-
self.value = 0
|
|
42
|
+
super().__init__(hub, 0)
|
|
45
43
|
|
|
46
44
|
def pull(self):
|
|
47
45
|
self.hub.send_serialized_data("GetIntensity")
|
|
@@ -61,8 +59,7 @@ class SmartModeProperty(Property[bool]):
|
|
|
61
59
|
await self.notify_listeners(value)
|
|
62
60
|
|
|
63
61
|
def __init__(self, hub: ConnectionHub):
|
|
64
|
-
super().__init__(hub)
|
|
65
|
-
self.value = False
|
|
62
|
+
super().__init__(hub, False)
|
|
66
63
|
|
|
67
64
|
def pull(self):
|
|
68
65
|
self.hub.send_serialized_data("GetSmartMode")
|
|
@@ -18,8 +18,7 @@ class DisplayNameProperty(Property[str]):
|
|
|
18
18
|
await self.notify_listeners(value)
|
|
19
19
|
|
|
20
20
|
def __init__(self, hub: ConnectionHub):
|
|
21
|
-
super().__init__(hub)
|
|
22
|
-
self.value = "Smarla"
|
|
21
|
+
super().__init__(hub, "Smarla")
|
|
23
22
|
|
|
24
23
|
def pull(self):
|
|
25
24
|
self.hub.send_serialized_data("GetDisplayName")
|
|
@@ -36,8 +35,7 @@ class VersionProperty(Property[str]):
|
|
|
36
35
|
await self.notify_listeners(value)
|
|
37
36
|
|
|
38
37
|
def __init__(self, hub: ConnectionHub):
|
|
39
|
-
super().__init__(hub)
|
|
40
|
-
self.value = "1.0.0"
|
|
38
|
+
super().__init__(hub, "1.0.0")
|
|
41
39
|
|
|
42
40
|
def pull(self):
|
|
43
41
|
self.hub.send_serialized_data("GetVersion")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
pysmarlaapi/__init__.py,sha256=HvcRKoj47bC-HWwzoPDGj7tN2GXOTcgzsYtnknEE0iE,90
|
|
2
|
+
pysmarlaapi/classes/__init__.py,sha256=N-ZV3Id_t5ciovUlPUGCk5SLLiMUonRoQZWpfOU4ZsM,69
|
|
3
|
+
pysmarlaapi/classes/auth_token.py,sha256=dpo0lBT9Advm3Iyxu-fT9sq078U2OxgXXBuF5gbBZkM,942
|
|
4
|
+
pysmarlaapi/classes/connection.py,sha256=vVC0Ur0KQUb4pNDVuCYnfk-JXs-O-FwYVO-2y1E2g6g,1551
|
|
5
|
+
pysmarlaapi/connection_hub/__init__.py,sha256=NR5xql57L0Xs0JfeEVOVLITWSaVMblEo6pcvB7fn5TQ,4443
|
|
6
|
+
pysmarlaapi/federwiege/__init__.py,sha256=7Fl_GnwN6GbS8fhkHdfMhuYFospKnap40pvUtSGIeoE,1933
|
|
7
|
+
pysmarlaapi/federwiege/classes/__init__.py,sha256=DFJJVOKpra40S4ZX_oq2RyMazg6Nx0c8hoPggmj1bXA,60
|
|
8
|
+
pysmarlaapi/federwiege/classes/property.py,sha256=D98z9T6CGqRBzRjNbeWpxrMQKE5bv5-k1nDCQRMDfbI,1041
|
|
9
|
+
pysmarlaapi/federwiege/classes/service.py,sha256=Y0OQxtQLaHp4qY8Vthj0zRroPoYTiD2WA9ZR96teZTo,632
|
|
10
|
+
pysmarlaapi/federwiege/services/__init__.py,sha256=bJuOsk0lw9WWxB1NZodRTL8Pm_Ra8CuTCxNh33WzxkQ,132
|
|
11
|
+
pysmarlaapi/federwiege/services/analyser_service.py,sha256=ENPULIDBcqyOGCh3Yz6iv86XWBLOEG6yr36J2EZQq1M,1724
|
|
12
|
+
pysmarlaapi/federwiege/services/babywiege_service.py,sha256=vUXRaqOE3pLSZ1HVYZAdh__ApU0Z29_m65928NduC4o,2011
|
|
13
|
+
pysmarlaapi/federwiege/services/info_service.py,sha256=WIH6tALDCKI82PFtNTq8dIMAotnS7wNxjXaTLiyyHeM,1208
|
|
14
|
+
pysmarlaapi-0.8.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
15
|
+
pysmarlaapi-0.8.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
16
|
+
pysmarlaapi-0.8.0.dist-info/METADATA,sha256=92WQrS8n9yu1vrL1udf7QRFrvfKIpcZhQHJSVqwK840,1106
|
|
17
|
+
pysmarlaapi-0.8.0.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
pysmarlaapi/__init__.py,sha256=rDgCmbkCZQZlhzANFZ4JVqkxlURuDWtkn4yS9HKCPqI,90
|
|
2
|
-
pysmarlaapi/classes/__init__.py,sha256=N-ZV3Id_t5ciovUlPUGCk5SLLiMUonRoQZWpfOU4ZsM,69
|
|
3
|
-
pysmarlaapi/classes/auth_token.py,sha256=dpo0lBT9Advm3Iyxu-fT9sq078U2OxgXXBuF5gbBZkM,942
|
|
4
|
-
pysmarlaapi/classes/connection.py,sha256=vbEHENKDUANCemQriH66sofHmPPCe2THSY9dm7SIt1M,1400
|
|
5
|
-
pysmarlaapi/connection_hub/__init__.py,sha256=NR5xql57L0Xs0JfeEVOVLITWSaVMblEo6pcvB7fn5TQ,4443
|
|
6
|
-
pysmarlaapi/federwiege/__init__.py,sha256=7Fl_GnwN6GbS8fhkHdfMhuYFospKnap40pvUtSGIeoE,1933
|
|
7
|
-
pysmarlaapi/federwiege/classes/__init__.py,sha256=DFJJVOKpra40S4ZX_oq2RyMazg6Nx0c8hoPggmj1bXA,60
|
|
8
|
-
pysmarlaapi/federwiege/classes/property.py,sha256=kTVbaGbWmmku5GmVq0mtWF8uSA7G8oHakyZ_LOO9h3c,1028
|
|
9
|
-
pysmarlaapi/federwiege/classes/service.py,sha256=Y0OQxtQLaHp4qY8Vthj0zRroPoYTiD2WA9ZR96teZTo,632
|
|
10
|
-
pysmarlaapi/federwiege/services/__init__.py,sha256=bJuOsk0lw9WWxB1NZodRTL8Pm_Ra8CuTCxNh33WzxkQ,132
|
|
11
|
-
pysmarlaapi/federwiege/services/analyser_service.py,sha256=y02j4cNvRAblBa1pTlJi1u1_7c3vV4xMj9uHe_vwV38,1789
|
|
12
|
-
pysmarlaapi/federwiege/services/babywiege_service.py,sha256=8hCu-uFAcT_G0F5oUD3EqYzb02L2bE5mVF72NrunEpc,2070
|
|
13
|
-
pysmarlaapi/federwiege/services/info_service.py,sha256=03a4eZFAL1zaIaWo1e-a_Zm2wVl0RuFLm2rTS7ABJIQ,1248
|
|
14
|
-
pysmarlaapi-0.7.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
15
|
-
pysmarlaapi-0.7.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
16
|
-
pysmarlaapi-0.7.1.dist-info/METADATA,sha256=bMPiRef95hRV4Yk2JT-2W6dbMGuPI1qAK0hZstD67MY,1106
|
|
17
|
-
pysmarlaapi-0.7.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|