twist-innovation-api 0.0.5__tar.gz → 0.0.6__tar.gz

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.
Files changed (24) hide show
  1. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/PKG-INFO +11 -2
  2. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/setup.py +1 -1
  3. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistRgb.py +32 -12
  4. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist_innovation_api.egg-info/PKG-INFO +12 -3
  5. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/LICENSE +0 -0
  6. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/README.md +0 -0
  7. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/pyproject.toml +0 -0
  8. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/setup.cfg +0 -0
  9. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/BackendAdapter.py +0 -0
  10. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistAPI.py +0 -0
  11. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistBinarySensor.py +0 -0
  12. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistButton.py +0 -0
  13. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistDevice.py +0 -0
  14. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistGarage.py +0 -0
  15. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistLight.py +0 -0
  16. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistModel.py +0 -0
  17. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistRelay.py +0 -0
  18. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistSensor.py +0 -0
  19. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistShutter.py +0 -0
  20. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/TwistTypes.py +0 -0
  21. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist/__init__.py +0 -0
  22. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist_innovation_api.egg-info/SOURCES.txt +0 -0
  23. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist_innovation_api.egg-info/dependency_links.txt +0 -0
  24. {twist_innovation_api-0.0.5 → twist_innovation_api-0.0.6}/twist_innovation_api.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: twist_innovation_api
3
- Version: 0.0.5
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
 
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="twist_innovation_api",
5
- version="0.0.5",
5
+ version="0.0.6",
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  # "requests" # For REST API
@@ -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, value)
72
+ await self._activate_event(TwistRgb.EventIndexes.VALUE, converted_value)
58
73
  else:
59
- await self._activate_event(TwistRgb.EventIndexes.VALUE_FADING, value, fading_time)
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"] = [int(v / 655.35) for v in value]
85
+ data["vl"] = list(value)
71
86
  else:
72
- value = list(value)
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] / 655.35, 0)
86
- self.actual_s = round(value[1] / 655.35, 0)
87
- self.actual_v = round(value[2] / 655.35, 0)
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] / 655.35, 0)
90
- self.requested_s = round(value[0] / 655.35, 0)
91
- self.requested_v = round(value[0] / 655.35, 0)
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.1
2
- Name: twist-innovation-api
3
- Version: 0.0.5
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