twist-innovation-api 0.0.5__py3-none-any.whl → 0.0.6__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.
- twist/TwistRgb.py +32 -12
- {twist_innovation_api-0.0.5.dist-info → twist_innovation_api-0.0.6.dist-info}/METADATA +12 -3
- {twist_innovation_api-0.0.5.dist-info → twist_innovation_api-0.0.6.dist-info}/RECORD +6 -6
- {twist_innovation_api-0.0.5.dist-info → twist_innovation_api-0.0.6.dist-info}/WHEEL +1 -1
- {twist_innovation_api-0.0.5.dist-info → twist_innovation_api-0.0.6.dist-info/licenses}/LICENSE +0 -0
- {twist_innovation_api-0.0.5.dist-info → twist_innovation_api-0.0.6.dist-info}/top_level.txt +0 -0
twist/TwistRgb.py
CHANGED
|
@@ -53,10 +53,25 @@ class TwistRgb(TwistModel):
|
|
|
53
53
|
await self._activate_event(TwistRgb.EventIndexes.TOGGLE)
|
|
54
54
|
|
|
55
55
|
async def set_value(self, value: list[int, int, int], fading_time: int | None = None):
|
|
56
|
+
"""Set HSV values.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
value: [H, S, V] where H is 0-360 degrees, S is 0-100%, V is 0-100%
|
|
60
|
+
fading_time: Optional transition time in milliseconds
|
|
61
|
+
"""
|
|
62
|
+
# Convert from standard ranges to device range (0-65535)
|
|
63
|
+
# H: 0-360 -> 0-65535 (multiply by 182.04)
|
|
64
|
+
# S: 0-100 -> 0-65535 (multiply by 655.35)
|
|
65
|
+
# V: 0-100 -> 0-65535 (multiply by 655.35)
|
|
66
|
+
h_value = round(value[0] * 182.04)
|
|
67
|
+
s_value = round(value[1] * 655.35)
|
|
68
|
+
v_value = round(value[2] * 655.35)
|
|
69
|
+
converted_value = [h_value, s_value, v_value]
|
|
70
|
+
|
|
56
71
|
if fading_time is None:
|
|
57
|
-
await self._activate_event(TwistRgb.EventIndexes.VALUE,
|
|
72
|
+
await self._activate_event(TwistRgb.EventIndexes.VALUE, converted_value)
|
|
58
73
|
else:
|
|
59
|
-
await self._activate_event(TwistRgb.EventIndexes.VALUE_FADING,
|
|
74
|
+
await self._activate_event(TwistRgb.EventIndexes.VALUE_FADING, converted_value, fading_time)
|
|
60
75
|
|
|
61
76
|
async def _activate_event(self, index: TwistRgb.EventIndexes, value: tuple[int, int, int] | None = None,
|
|
62
77
|
fading_time: int | None = None):
|
|
@@ -67,28 +82,33 @@ class TwistRgb(TwistModel):
|
|
|
67
82
|
if value is None:
|
|
68
83
|
data["vl"] = []
|
|
69
84
|
elif fading_time is None:
|
|
70
|
-
data["vl"] =
|
|
85
|
+
data["vl"] = list(value)
|
|
71
86
|
else:
|
|
72
|
-
|
|
73
|
-
value.append(fading_time)
|
|
74
|
-
data["vl"] = value
|
|
87
|
+
data["vl"] = list(value) + [fading_time]
|
|
75
88
|
|
|
76
89
|
await self.parent_device.api.activate_event(self, data)
|
|
77
90
|
|
|
78
91
|
async def context_msg(self, payload: str):
|
|
92
|
+
"""Parse context message from device.
|
|
93
|
+
|
|
94
|
+
Device sends HSV in 0-65535 range, convert to standard ranges:
|
|
95
|
+
H: 0-65535 -> 0-360 degrees (divide by 182.04)
|
|
96
|
+
S: 0-65535 -> 0-100% (divide by 655.35)
|
|
97
|
+
V: 0-65535 -> 0-100% (divide by 655.35)
|
|
98
|
+
"""
|
|
79
99
|
data = self.parse_general_context(payload)
|
|
80
100
|
|
|
81
101
|
for ctx in data["cl"]:
|
|
82
102
|
index, value = self._get_value_from_context(ctx)
|
|
83
103
|
if index < ContextErrors.MAX.value:
|
|
84
104
|
if ContextErrors(index) == ContextErrors.ACTUAL:
|
|
85
|
-
self.actual_h = round(value[0] /
|
|
86
|
-
self.actual_s = round(value[1] / 655.35,
|
|
87
|
-
self.actual_v = round(value[2] / 655.35,
|
|
105
|
+
self.actual_h = round(value[0] / 182.04, 1)
|
|
106
|
+
self.actual_s = round(value[1] / 655.35, 1)
|
|
107
|
+
self.actual_v = round(value[2] / 655.35, 1)
|
|
88
108
|
elif ContextErrors(index) == ContextErrors.REQUESTED:
|
|
89
|
-
self.requested_h = round(value[0] /
|
|
90
|
-
self.requested_s = round(value[
|
|
91
|
-
self.requested_v = round(value[
|
|
109
|
+
self.requested_h = round(value[0] / 182.04, 1)
|
|
110
|
+
self.requested_s = round(value[1] / 655.35, 1)
|
|
111
|
+
self.requested_v = round(value[2] / 655.35, 1)
|
|
92
112
|
else:
|
|
93
113
|
if index == 6:
|
|
94
114
|
self.operating_time = value[0]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.0.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: twist_innovation_api
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: Python library to talk to the twist-innovation api
|
|
5
5
|
Home-page: https://github.com/twist-innovation/twist-innovation-api
|
|
6
6
|
Author: Sibrecht Goudsmedt
|
|
@@ -11,6 +11,15 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.7
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: author-email
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
14
23
|
|
|
15
24
|
# Twist Innovation API
|
|
16
25
|
|
|
@@ -7,13 +7,13 @@ twist/TwistGarage.py,sha256=RaE0Pi-1dE9FwHEIANf--Uig9tFt6EAZBt_lxjZgk18,2149
|
|
|
7
7
|
twist/TwistLight.py,sha256=6f-gPfP6v7BgaRJUFt7Q3r990y2L0812d76K_33KSTw,3230
|
|
8
8
|
twist/TwistModel.py,sha256=HKDDm-vaRiNEF-a67N-cjWw2UZDiSPSRMkEmlAIUPTg,3667
|
|
9
9
|
twist/TwistRelay.py,sha256=VL9eKXSOoZ_9GHT8TGZKDU1hGH-cgoogoMmJWLfjOqc,2309
|
|
10
|
-
twist/TwistRgb.py,sha256=
|
|
10
|
+
twist/TwistRgb.py,sha256=rqY0rPZ5OPo96fbftfWuKSg_dyuh-Ai0g2p8JQZ-IFA,4406
|
|
11
11
|
twist/TwistSensor.py,sha256=6eYrwtZFFFOHmoHS68JHmsyi6FVVzoQy19KooGU0vMI,1192
|
|
12
12
|
twist/TwistShutter.py,sha256=gXMbgV_Y-3GLzxE0K6XRP6qqDHEw0uySjZc82IOMsYY,3328
|
|
13
13
|
twist/TwistTypes.py,sha256=k1CdLqjhJi8MyrFZsHkDsEoL9gEXF-HQv6I-r3G7ngA,726
|
|
14
14
|
twist/__init__.py,sha256=gf8GHc9utiG0vD8GP3IfzLFHAG-ev1TXBIm0XUHxy38,201
|
|
15
|
-
twist_innovation_api-0.0.
|
|
16
|
-
twist_innovation_api-0.0.
|
|
17
|
-
twist_innovation_api-0.0.
|
|
18
|
-
twist_innovation_api-0.0.
|
|
19
|
-
twist_innovation_api-0.0.
|
|
15
|
+
twist_innovation_api-0.0.6.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
16
|
+
twist_innovation_api-0.0.6.dist-info/METADATA,sha256=u4V1PvjaMTjwDEbT17UWFCNnrfCs6VSss83W6tuieJc,4335
|
|
17
|
+
twist_innovation_api-0.0.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
18
|
+
twist_innovation_api-0.0.6.dist-info/top_level.txt,sha256=mkoeBkRPFodjnd-3UDf9YndjTQ6Sriz-EKSI4nQ7brs,6
|
|
19
|
+
twist_innovation_api-0.0.6.dist-info/RECORD,,
|
{twist_innovation_api-0.0.5.dist-info → twist_innovation_api-0.0.6.dist-info/licenses}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|