blebox-uniapi 2.2.0__tar.gz → 2.2.2__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 (54) hide show
  1. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/CONTRIBUTING.rst +2 -2
  2. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/HISTORY.rst +9 -0
  3. blebox_uniapi-2.2.2/PKG-INFO +208 -0
  4. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/README.rst +5 -6
  5. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/__init__.py +1 -1
  6. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/box.py +39 -5
  7. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/box_types.py +132 -14
  8. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/sensor.py +7 -1
  9. blebox_uniapi-2.2.2/blebox_uniapi.egg-info/PKG-INFO +208 -0
  10. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi.egg-info/SOURCES.txt +15 -2
  11. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/setup.cfg +5 -5
  12. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/setup.py +1 -1
  13. blebox_uniapi-2.2.2/tests/__init__.py +1 -0
  14. blebox_uniapi-2.2.2/tests/conftest.py +331 -0
  15. blebox_uniapi-2.2.2/tests/test_box.py +210 -0
  16. blebox_uniapi-2.2.2/tests/test_box_types.py +70 -0
  17. blebox_uniapi-2.2.2/tests/test_button.py +49 -0
  18. blebox_uniapi-2.2.2/tests/test_climate.py +385 -0
  19. blebox_uniapi-2.2.2/tests/test_cover.py +728 -0
  20. blebox_uniapi-2.2.2/tests/test_error.py +48 -0
  21. blebox_uniapi-2.2.2/tests/test_light.py +1157 -0
  22. blebox_uniapi-2.2.2/tests/test_light_unit.py +141 -0
  23. blebox_uniapi-2.2.2/tests/test_sensor.py +401 -0
  24. blebox_uniapi-2.2.2/tests/test_session.py +155 -0
  25. blebox_uniapi-2.2.2/tests/test_switch.py +462 -0
  26. blebox_uniapi-2.2.2/tests/test_unknown.py +59 -0
  27. blebox_uniapi-2.2.0/AUTHORS.rst +0 -13
  28. blebox_uniapi-2.2.0/PKG-INFO +0 -199
  29. blebox_uniapi-2.2.0/blebox_uniapi.egg-info/PKG-INFO +0 -199
  30. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/LICENSE +0 -0
  31. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/MANIFEST.in +0 -0
  32. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/binary_sensor.py +0 -0
  33. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/button.py +0 -0
  34. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/climate.py +0 -0
  35. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/cover.py +0 -0
  36. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/error.py +0 -0
  37. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/feature.py +0 -0
  38. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/light.py +0 -0
  39. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/session.py +0 -0
  40. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi/switch.py +0 -0
  41. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi.egg-info/dependency_links.txt +0 -0
  42. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi.egg-info/not-zip-safe +0 -0
  43. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi.egg-info/requires.txt +0 -0
  44. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/blebox_uniapi.egg-info/top_level.txt +0 -0
  45. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/Makefile +0 -0
  46. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/authors.rst +0 -0
  47. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/conf.py +0 -0
  48. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/contributing.rst +0 -0
  49. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/history.rst +0 -0
  50. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/index.rst +0 -0
  51. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/installation.rst +0 -0
  52. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/make.bat +0 -0
  53. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/readme.rst +0 -0
  54. {blebox_uniapi-2.2.0 → blebox_uniapi-2.2.2}/docs/usage.rst +0 -0
@@ -15,7 +15,7 @@ Types of Contributions
15
15
  Report Bugs
16
16
  ~~~~~~~~~~~
17
17
 
18
- Report bugs at https://github.com/gadgetmobile/blebox_uniapi/issues.
18
+ Report bugs at https://github.com/blebox/blebox_uniapi/issues.
19
19
 
20
20
  If you are reporting a bug, please include:
21
21
 
@@ -45,7 +45,7 @@ articles, and such.
45
45
  Submit Feedback
46
46
  ~~~~~~~~~~~~~~~
47
47
 
48
- The best way to send feedback is to file an issue at https://github.com/gadgetmobile/blebox_uniapi/issues.
48
+ The best way to send feedback is to file an issue at https://github.com/blebox/blebox_uniapi/issues.
49
49
 
50
50
  If you are proposing a feature:
51
51
 
@@ -1,6 +1,15 @@
1
1
  =======
2
2
  History
3
3
  =======
4
+ 2.2.2 (2024-02-07)
5
+ ------------------
6
+ * fixed wind reading units to get proper raw m/s value (division by 10, see PR #150)
7
+
8
+
9
+ 2.2.1 (2024-01-26)
10
+ ------------------
11
+ * fixed support for power measurement capabilities of switchBox and switchBoxD devices
12
+
4
13
  2.2.0 (2023-08-29)
5
14
  ------------------
6
15
  * added last_reset to energy sensor class
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.1
2
+ Name: blebox_uniapi
3
+ Version: 2.2.2
4
+ Summary: Python API for accessing BleBox smart home devices
5
+ Home-page: https://github.com/blebox/blebox_uniapi
6
+ Author: BleBox
7
+ Author-email: opensource@blebox.eu
8
+ License: Apache Software License 2.0
9
+ Keywords: blebox_uniapi
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Requires-Python: >=3.9
17
+ License-File: LICENSE
18
+ Requires-Dist: aiohttp>=3
19
+
20
+ ====================
21
+ BleBox Python UniAPI
22
+ ====================
23
+
24
+
25
+ .. image:: https://img.shields.io/pypi/v/blebox_uniapi.svg
26
+ :target: https://pypi.python.org/pypi/blebox_uniapi
27
+
28
+ .. image:: https://travis-ci.com/blebox/blebox_uniapi.svg?branch=master
29
+ :target: https://travis-ci.com/blebox/blebox_uniapi
30
+
31
+ .. image:: https://readthedocs.org/projects/blebox-uniapi/badge/?version=latest
32
+ :target: https://blebox-uniapi.readthedocs.io/en/latest/?badge=latest
33
+ :alt: Documentation Status
34
+
35
+
36
+
37
+
38
+ Python API for accessing BleBox smart home devices
39
+
40
+
41
+ * Free software: Apache Software License 2.0
42
+ * Documentation: https://blebox-uniapi.readthedocs.io.
43
+
44
+
45
+ Features
46
+ --------
47
+
48
+ * supports `11 BleBox smart home devices`_
49
+ * contains functional/integration tests
50
+ * every device supports at least minimum functionality for most common automation needs
51
+ * insight of integration level are accesible from file `box_types.py <blebox_uniapi/box_types.py#L43>`_
52
+
53
+ (devices with apiLevel lower than defined in BOX_TYPE_CONF will not be supported but higher will)
54
+
55
+
56
+ Contributions are welcome!
57
+
58
+ Credits
59
+ -------
60
+
61
+
62
+ .. _Cookiecutter: https://github.com/audreyr/cookiecutter
63
+ .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
64
+ .. _`11 BleBox smart home devices`: https://blebox.eu/produkty/?lang=en
65
+
66
+
67
+ =======
68
+ History
69
+ =======
70
+ 2.2.2 (2024-02-07)
71
+ ------------------
72
+ * fixed wind reading units to get proper raw m/s value (division by 10, see PR #150)
73
+
74
+
75
+ 2.2.1 (2024-01-26)
76
+ ------------------
77
+ * fixed support for power measurement capabilities of switchBox and switchBoxD devices
78
+
79
+ 2.2.0 (2023-08-29)
80
+ ------------------
81
+ * added last_reset to energy sensor class
82
+ * added BasicAuth support to http client
83
+
84
+ 2.1.4 (2023-01-03)
85
+ ------------------
86
+ * added tilt position support for :code:`cover.Shutter`
87
+ * added :code:`Wind` for wind sensor of multisensors
88
+ * added :code:`Energy` sensor class for power consumption tracking
89
+ * implementing :code:`default_api_level` for
90
+ * dimmerBox
91
+ * wLightBox
92
+ * wLightBoxS
93
+
94
+ 2.1.3 (2022-10-27)
95
+ ------------------
96
+ * thermoBox boost mode doesn't corrupt state
97
+
98
+ 2.1.2 (2022-10-17)
99
+ ------------------
100
+
101
+ * fixed CCT, CCTx2 modes for wLightBox v1 & v2
102
+
103
+ 2.1.1 (2022-10-11)
104
+ ------------------
105
+ * added support for thermoBox devices:
106
+ * added thermoBox config to :code:`BOX_TYPE_CONFIG`
107
+ * :code:`Climate` uses factory method implementation
108
+ * added test coverage
109
+
110
+
111
+ 2.1.0 (2022-08-05)
112
+ ------------------
113
+ * added support for multiSensor API:
114
+ * :code:`airQuality` moved to sensor module
115
+ * new binary_sensor module, introducing :code:`Rain` class
116
+
117
+
118
+ 2.0.2 (2022-07-06)
119
+ ------------------
120
+ * added :code:`query_string` property in :code:`Button` class
121
+ * fixed test assertions after changes in error raised ValueError
122
+
123
+ 2.0.1 (2022-06-01)
124
+ ------------------
125
+ * used :code:`ValueError` type instead of :code:`BadOnValueError` in methods:
126
+
127
+ * evaluate_brightness_from_rgb
128
+ * apply_brightness
129
+ * normalise_elements_of_rgb
130
+ * _set_last_on_value
131
+ * async_on
132
+
133
+ 2.0.0 (2022-06-21)
134
+ ------------------
135
+
136
+ * extended support for color modes in wLightBox devices
137
+ * initial support for tvLiftBox device
138
+ * major backward-incompatible architectural changes to enable dynamic configuration of devices
139
+ * removed products.py module and replaced with factory method on Box class
140
+ * general overhaul of public interfaces
141
+
142
+ 1.3.3 (2021-05-12)
143
+ ------------------
144
+
145
+ * fix support for wLightBoxS with wLightBox API
146
+ * fix state detection in gateBox
147
+
148
+ 1.3.2 (2020-04-2)
149
+ ------------------
150
+
151
+ * use proper module-level logger by default
152
+ * fix formatting
153
+
154
+ 1.3.1 (2020-04-2)
155
+ ------------------
156
+
157
+ * never skip command requests
158
+ * improve error messages
159
+
160
+ 1.2.0 (2020-03-30)
161
+ ------------------
162
+
163
+ * expose device info
164
+ * always add ip/port in connection errors
165
+ * fixed gateController support
166
+ * support for sauna min/max temp
167
+
168
+ 1.1.0 (2020-03-24)
169
+ ------------------
170
+
171
+ * fix bad wLightBox API path
172
+ * wrap api calls in semaphore (to serialize reqests to each box)
173
+ * throttle updates to 2/second (to avoid unnecessary requests)
174
+ * rework error handling and hierarchy (for cleaner usage)
175
+ * use actual device name (to help recognize the device)
176
+ * handle asyncio.TimeoutError (to handle timeout-related errors nicely)
177
+ * properly re-raise exceptions (to avoid lengthy call stacktraces)
178
+ * rename wLightBoxS feature to "brightness"
179
+
180
+ 1.1.0 (2020-03-24)
181
+ ------------------
182
+
183
+ * fix switchBox support
184
+ * fix minimum position handling
185
+ * drop Python 3.6 support (still may work)
186
+ * misc fixes, cleanup and increased test coverage
187
+
188
+ 1.0.0 (2020-03-24)
189
+ ------------------
190
+
191
+ * Fixed wLightBox issues
192
+ * Fixed wLightBoxS issues
193
+ * Fixed shutterBox issues
194
+ * Handle unknown shutterBox position
195
+ * Improved error handling + lots of new diagnostics
196
+ * Increased tests and test coverage (almost 100%)
197
+ * Lots of rework
198
+
199
+
200
+ 0.1.1 (2020-03-15)
201
+ ------------------
202
+
203
+ * Fixed switchBox support (newer API versions)
204
+
205
+ 0.1.0 (2020-03-10)
206
+ ------------------
207
+
208
+ * First release on PyPI.
@@ -29,17 +29,16 @@ Features
29
29
  * supports `11 BleBox smart home devices`_
30
30
  * contains functional/integration tests
31
31
  * every device supports at least minimum functionality for most common automation needs
32
- * insight of integration level are accesible from file `box_types.py <blebox_uniapi/box_types.py#L43>`_
33
-
34
- (devices with apiLevel lower than defined in BOX_TYPE_CONF will not be supported but higher will)
35
-
32
+ * insight of integration level are accesible from file `box_types.py <blebox_uniapi/box_types.py#L43>`_
36
33
 
37
- Contributions are most welcome!
34
+ (devices with apiLevel lower than defined in BOX_TYPE_CONF will not be supported but higher will)
35
+
36
+
37
+ Contributions are welcome!
38
38
 
39
39
  Credits
40
40
  -------
41
41
 
42
- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
43
42
 
44
43
  .. _Cookiecutter: https://github.com/audreyr/cookiecutter
45
44
  .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
@@ -2,4 +2,4 @@
2
2
 
3
3
  __author__ = """BleBox"""
4
4
  __email__ = "opensource@blebox.eu"
5
- __version__ = "2.2.0"
5
+ __version__ = "2.2.2"
@@ -37,6 +37,8 @@ class Box:
37
37
  _name: str
38
38
  _data_path: str
39
39
  _last_real_update: Optional[float]
40
+ _last_data: Optional[Any]
41
+
40
42
  api_session: ApiHost
41
43
  info: dict
42
44
  config: dict
@@ -49,6 +51,7 @@ class Box:
49
51
  config,
50
52
  extended_state,
51
53
  ) -> None:
54
+ self._last_data = None
52
55
  self._last_real_update = None
53
56
  self._sem = asyncio.BoundedSemaphore()
54
57
  self._session = api_session
@@ -243,6 +246,38 @@ class Box:
243
246
  await self._async_api(True, "GET", self._data_path)
244
247
 
245
248
  def _update_last_data(self, new_data: Optional[dict]) -> None:
249
+ # Note: on certain more complex devices that inlcude multiple features
250
+ # like switches and sensors (e.g. SwitchboxD) it may happen that activating
251
+ # single feature would result only in partial update of the self._last_data.
252
+ # We can know that by comparing keys of both states.
253
+ #
254
+ # Notable example of device exhibiting this behavior is SwitchboxD (20200831)
255
+ # It has two relays (switches) and power measurement capabilities (sensor).
256
+ # Toggling the relay does return state of all relays, but does not return
257
+ # sensor information (partial state). Accepting the new state as-is would
258
+ # break the update of sensory information.
259
+ #
260
+ # Note that SwitchboxD is just an example. It is possible that APIs of other
261
+ # box types also exhibit this kind of behavior.
262
+ if (
263
+ isinstance(self._last_data, dict) and
264
+ isinstance(new_data, dict) and
265
+ self._last_data.keys() != new_data.keys()
266
+ ):
267
+ # ... In such a case we need to merge both states instead of overwriting
268
+ # the old one as-is.
269
+ #
270
+ # The only risk is that if certain features are somehow coupled inside
271
+ # the device, we will have inconsistent information about the device.
272
+ # However, this should be eventually consistent as new updates arrive.
273
+ # In the end, it is better to have an inconsistent state, rather than
274
+ # have broken one (e.g. missing keys) that results in broken features.
275
+ #
276
+ # Refs:
277
+ # - https://github.com/blebox/blebox_uniapi/pull/152
278
+ # - https://github.com/blebox/blebox_uniapi/issues/137
279
+ new_data = {**self._last_data, **new_data}
280
+
246
281
  self._last_data = new_data
247
282
  for feature_set in self._features.values():
248
283
  for feature in feature_set:
@@ -255,7 +290,7 @@ class Box:
255
290
 
256
291
  def follow(self, data: dict, path: str) -> Any:
257
292
  """
258
- Return payloadu from device response json.
293
+ Return payload from device response json.
259
294
  :param self:
260
295
  :param data:
261
296
  :param path:
@@ -268,8 +303,7 @@ class Box:
268
303
  current_tree = data
269
304
 
270
305
  for chunk in results:
271
- with_string_value = re.compile("^\\[(.*)='(.*)'\\]$")
272
-
306
+ with_string_value = re.compile(r"^\[(.*)='(.*)']$")
273
307
  match = with_string_value.match(chunk)
274
308
  if match:
275
309
  name = match.group(1)
@@ -288,7 +322,7 @@ class Box:
288
322
 
289
323
  continue # pragma: no cover
290
324
 
291
- with_int_value = re.compile("^\\[(.*)=(\\d+)\\]$")
325
+ with_int_value = re.compile(r"^\[(.*)=(\d+)]$")
292
326
  match = with_int_value.match(chunk)
293
327
  if match:
294
328
  name = match.group(1)
@@ -311,7 +345,7 @@ class Box:
311
345
  raise JPathFailed(f"with: {name}={value}", path, data)
312
346
  continue # pragma: no cover
313
347
 
314
- with_index = re.compile("^\\[(\\d+)\\]$")
348
+ with_index = re.compile(r"^\[(\d+)]$")
315
349
  match = with_index.match(chunk)
316
350
  if match:
317
351
  index = int(match.group(1))
@@ -245,17 +245,6 @@ BOX_TYPE_CONF: dict[str, dict[int, dict[str, Any]]] = {
245
245
  }
246
246
  },
247
247
  "switchBox": {
248
- 20220114: {
249
- "api_path": "/state",
250
- "extended_state_path": "/state/extended",
251
- "api": {
252
- "on": lambda x=None: ("GET", f"/s/{x}/1", None),
253
- "off": lambda x=None: ("GET", f"/s/{x}/0", None),
254
- },
255
- "switches": [
256
- ["relay", {"state": lambda x: f"relays/[relay={x}]/state"}, "relay"]
257
- ],
258
- },
259
248
  20180604: {
260
249
  "model": "switchBox",
261
250
  "api_path": "/api/relay/state",
@@ -265,6 +254,7 @@ BOX_TYPE_CONF: dict[str, dict[int, dict[str, Any]]] = {
265
254
  "off": lambda x=None: ("GET", "/s/0", None),
266
255
  },
267
256
  "switches": [["0.relay", {"state": "[relay=0]/state"}, "relay"]],
257
+ # note: does not support power measurement
268
258
  },
269
259
  20190808: {
270
260
  "api_path": "/api/relay/extended/state",
@@ -287,11 +277,107 @@ BOX_TYPE_CONF: dict[str, dict[int, dict[str, Any]]] = {
287
277
  ]
288
278
  ],
289
279
  },
280
+ 20200229: {
281
+ "extended_state_path": "/state/extended",
282
+ "api_path": "/state/extended",
283
+ "api": {
284
+ "on": lambda x=None: ("GET", "/s/1", None),
285
+ "off": lambda x=None: ("GET", "/s/0", None),
286
+ },
287
+ "switches": [
288
+ ["0.relay", {"state": lambda x: f"relays/[relay={x}]/state"}, "relay"]
289
+ ],
290
+ "sensors": [
291
+ [
292
+ "switchBox.energy",
293
+ {
294
+ "energy": "powerMeasuring/powerConsumption/[0]/value",
295
+ "periodS": "powerMeasuring/powerConsumption/[0]/periodS",
296
+ "measurment_enabled": "powerMeasuring/enabled",
297
+ },
298
+ ]
299
+ ],
300
+ },
301
+ 20200831: {
302
+ "extended_state_path": "/state/extended",
303
+ "api_path": "/state/extended",
304
+ "api": {
305
+ "on": lambda x=None: ("GET", "/s/1", None),
306
+ "off": lambda x=None: ("GET", "/s/0", None),
307
+ },
308
+ "switches": [
309
+ ["0.relay", {"state": lambda x: f"relays/[relay={x}]/state"}, "relay"]
310
+ ],
311
+ "sensors": [
312
+ [
313
+ "switchBox.energy",
314
+ {
315
+ "energy": "powerMeasuring/powerConsumption/[0]/value",
316
+ "periodS": "powerMeasuring/powerConsumption/[0]/periodS",
317
+ "measurment_enabled": "powerMeasuring/enabled",
318
+ },
319
+ ]
320
+ ],
321
+ },
322
+ 20220114: {
323
+ "api_path": "/state/extended",
324
+ "extended_state_path": "/state/extended",
325
+ "api": {
326
+ # note: old control api (i.e. /s/0, /s/1, /s/2) still supported but
327
+ # now deprecated. switchBox has now API consistent with switchBoxD
328
+ "on": lambda x=None: ("GET", f"/s/{x}/1", None),
329
+ "off": lambda x=None: ("GET", f"/s/{x}/0", None),
330
+ },
331
+ "switches": [
332
+ ["relay", {"state": lambda x: f"relays/[relay={x}]/state"}, "relay"]
333
+ ],
334
+ "sensors": [
335
+ [
336
+ "switchBox.energy",
337
+ {
338
+ "energy": "powerMeasuring/powerConsumption/[0]/value",
339
+ "periodS": "powerMeasuring/powerConsumption/[0]/periodS",
340
+ "measurment_enabled": "powerMeasuring/enabled",
341
+ },
342
+ ]
343
+ ],
344
+ },
290
345
  },
291
- # switchBoxD
292
346
  "switchBoxD": {
293
347
  20190808: {
294
- "extended_state_path": "/state/extended", # tylko dla testów do usunięcia nie w tym api
348
+ "extended_state_path": "/api/relay/extended/state",
349
+ "api_path": "/api/relay/extended/state",
350
+ "api": {
351
+ "on": lambda x: ("GET", f"/s/{int(x)}/1", None),
352
+ "off": lambda x=None: ("GET", f"/s/{int(x)}/0", None),
353
+ },
354
+ "switches": [
355
+ [
356
+ "0.relay",
357
+ {"state": lambda x: f"relays/[relay={x}]/state"},
358
+ "relay",
359
+ 0,
360
+ ],
361
+ [
362
+ "1.relay",
363
+ {"state": lambda x: f"relays/[relay={x}]/state"},
364
+ "relay",
365
+ 1,
366
+ ],
367
+ ],
368
+ "sensors": [
369
+ [
370
+ "switchBox.energy",
371
+ {
372
+ "energy": "powerMeasuring/powerConsumption/[0]/value",
373
+ "periodS": "powerMeasuring/powerConsumption/[0]/periodS",
374
+ "measurment_enabled": "powerMeasuring/enabled",
375
+ },
376
+ ]
377
+ ],
378
+ },
379
+ 20200229: {
380
+ "extended_state_path": "/state/extended",
295
381
  "api_path": "/state/extended",
296
382
  "api": {
297
383
  "on": lambda x: ("GET", f"/s/{int(x)}/1", None),
@@ -321,7 +407,39 @@ BOX_TYPE_CONF: dict[str, dict[int, dict[str, Any]]] = {
321
407
  },
322
408
  ]
323
409
  ],
324
- }
410
+ },
411
+ 20200831: {
412
+ "extended_state_path": "/state/extended",
413
+ "api_path": "/state/extended",
414
+ "api": {
415
+ "on": lambda x: ("GET", f"/s/{int(x)}/1", None),
416
+ "off": lambda x=None: ("GET", f"/s/{int(x)}/0", None),
417
+ },
418
+ "switches": [
419
+ [
420
+ "0.relay",
421
+ {"state": lambda x: f"relays/[relay={x}]/state"},
422
+ "relay",
423
+ 0,
424
+ ],
425
+ [
426
+ "1.relay",
427
+ {"state": lambda x: f"relays/[relay={x}]/state"},
428
+ "relay",
429
+ 1,
430
+ ],
431
+ ],
432
+ "sensors": [
433
+ [
434
+ "switchBox.energy",
435
+ {
436
+ "energy": "powerMeasuring/powerConsumption/[0]/value",
437
+ "periodS": "powerMeasuring/powerConsumption/[0]/periodS",
438
+ "measurment_enabled": "powerMeasuring/enabled",
439
+ },
440
+ ]
441
+ ],
442
+ },
325
443
  },
326
444
  # tempSensor
327
445
  "tempSensor": {
@@ -140,7 +140,13 @@ class Wind(BaseSensor):
140
140
  def _read_wind_speed(self):
141
141
  product = self._product
142
142
  if product.last_data is not None:
143
- return self.raw_value("wind")
143
+ raw = self.raw_value("wind")
144
+ if raw is not None:
145
+ alias = self._alias
146
+ # wind value unit in API is "0.1 m/s" so to get m/s we need to divide by 10
147
+ # min value = 0, max value for sure not bigger than 200km/h so about 60m/s so 600 in API
148
+ return round(product.expect_int(alias, raw, 600, 0) / 10.0, 1)
149
+ return None
144
150
 
145
151
  def after_update(self) -> None:
146
152
  self._native_value = self._read_wind_speed()