pywmswebcontrolpro 0.5.0__tar.gz → 0.6.0__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 (36) hide show
  1. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/CHANGELOG.md +11 -1
  2. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/PKG-INFO +25 -1
  3. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/README.md +24 -0
  4. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/action.py +33 -1
  5. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/travel.py +53 -0
  6. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/tests/test_rotation.py +125 -1
  7. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/.github/workflows/release.yaml +0 -0
  8. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/.github/workflows/validate.yaml +0 -0
  9. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/.gitignore +0 -0
  10. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/.python-version +0 -0
  11. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/LICENSE +0 -0
  12. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/mypy.ini +0 -0
  13. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pyproject.toml +0 -0
  14. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pytest.ini +0 -0
  15. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/__init__.py +0 -0
  16. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/const.py +0 -0
  17. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/destination.py +0 -0
  18. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/exceptions.py +0 -0
  19. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/py.typed +0 -0
  20. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/refresh.py +0 -0
  21. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/room.py +0 -0
  22. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/scene.py +0 -0
  23. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/store.py +0 -0
  24. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/pywmswebcontrolpro/webcontrol.py +0 -0
  25. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/requirements_lint.txt +0 -0
  26. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/requirements_test.txt +0 -0
  27. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/ruff.toml +0 -0
  28. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/simulator/simulator.py +0 -0
  29. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/tests/__init__.py +0 -0
  30. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/tests/conftest.py +0 -0
  31. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/tests/test_client.py +0 -0
  32. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/tests/test_configuration.py +0 -0
  33. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/tests/test_import.py +0 -0
  34. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/tests/test_refresh.py +0 -0
  35. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/tests/test_settings.py +0 -0
  36. {pywmswebcontrolpro-0.5.0 → pywmswebcontrolpro-0.6.0}/tests/test_travel.py +0 -0
@@ -1,6 +1,16 @@
1
1
  # Changelog
2
2
 
3
- ## 0.5.0 (unreleased)
3
+ ## 0.6.0
4
+
5
+ Added:
6
+
7
+ - Tilt model of slat drives for the cover tilt of Home Assistant 2026.12, see the
8
+ README: `Action.open_rotation`, `Action.open_tilt`, `Action.closed_tilts` and
9
+ `Action.tilt_angles`, calculated with the rotation limits in use. The functions
10
+ `open_rotation`, `open_tilt`, `closed_tilts`, `rotation_to_angle` and `tilt_angles`
11
+ in `travel.py` take the limits as arguments.
12
+
13
+ ## 0.5.0
4
14
 
5
15
  Added:
6
16
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pywmswebcontrolpro
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Python library for the Warema WMS WebControl pro API
5
5
  Author-email: Marc Hoersken <info@marc-hoersken.de>
6
6
  Maintainer: zomtec
@@ -151,6 +151,30 @@ The library works around it in `pywmswebcontrolpro/action.py`:
151
151
  The workaround ends by itself when a firmware reports other limits. It can be removed
152
152
  from the library once such a firmware is available.
153
153
 
154
+ ## Tilt model of slat drives
155
+
156
+ Since Home Assistant 2026.12 a cover can describe its tilt with an open tilt position,
157
+ closed tilt positions and the slat angles at tilt 0 and tilt 100. A rotation action
158
+ provides these values with the limits in use, so they follow the workaround, learned
159
+ and overwritten limits:
160
+
161
+ - `Action.open_rotation` is the rotation of open slats: 0 (horizontal) if it lies within
162
+ the limits, else the limit closest to 0. `Action.open_tilt` is its tilt, 50 with the
163
+ limits -75 and 75.
164
+ - `Action.closed_tilts` are the tilts of closed slats: the end where the slats lie the
165
+ flattest, the largest absolute rotation. Slats that turn evenly over the horizontal
166
+ position close at both ends, a slat roof with uneven limits at one: `[0, 100]` with
167
+ -75 and 75, `[0]` with -60 and 80, `[100]` with -100 and 50. An end
168
+ where the open tilt lies is left out. The first entry is the one to close to: tilt 0,
169
+ the maximum rotation, which the hub also turns the slats to when it closes the cover.
170
+ - `Action.tilt_angles` are the slat angles in whole degrees at tilt 0 and at tilt 100,
171
+ from -90 to 90, with the sign of the rotation of the hub: `(75, -75)` with the limits
172
+ -75 and 75. The rotation of the hub is in degrees, 0 is horizontal. `None` if the
173
+ limits do not give two different angles.
174
+
175
+ The functions behind them are in `pywmswebcontrolpro/travel.py` and take the limits as
176
+ arguments.
177
+
154
178
  ## Development
155
179
 
156
180
  ```bash
@@ -137,6 +137,30 @@ The library works around it in `pywmswebcontrolpro/action.py`:
137
137
  The workaround ends by itself when a firmware reports other limits. It can be removed
138
138
  from the library once such a firmware is available.
139
139
 
140
+ ## Tilt model of slat drives
141
+
142
+ Since Home Assistant 2026.12 a cover can describe its tilt with an open tilt position,
143
+ closed tilt positions and the slat angles at tilt 0 and tilt 100. A rotation action
144
+ provides these values with the limits in use, so they follow the workaround, learned
145
+ and overwritten limits:
146
+
147
+ - `Action.open_rotation` is the rotation of open slats: 0 (horizontal) if it lies within
148
+ the limits, else the limit closest to 0. `Action.open_tilt` is its tilt, 50 with the
149
+ limits -75 and 75.
150
+ - `Action.closed_tilts` are the tilts of closed slats: the end where the slats lie the
151
+ flattest, the largest absolute rotation. Slats that turn evenly over the horizontal
152
+ position close at both ends, a slat roof with uneven limits at one: `[0, 100]` with
153
+ -75 and 75, `[0]` with -60 and 80, `[100]` with -100 and 50. An end
154
+ where the open tilt lies is left out. The first entry is the one to close to: tilt 0,
155
+ the maximum rotation, which the hub also turns the slats to when it closes the cover.
156
+ - `Action.tilt_angles` are the slat angles in whole degrees at tilt 0 and at tilt 100,
157
+ from -90 to 90, with the sign of the rotation of the hub: `(75, -75)` with the limits
158
+ -75 and 75. The rotation of the hub is in degrees, 0 is horizontal. `None` if the
159
+ limits do not give two different angles.
160
+
161
+ The functions behind them are in `pywmswebcontrolpro/travel.py` and take the limits as
162
+ arguments.
163
+
140
164
  ## Development
141
165
 
142
166
  ```bash
@@ -10,7 +10,16 @@ from .const import (
10
10
  WMS_WebControl_pro_API_responseType,
11
11
  )
12
12
  from .store import ActionSettings, TravelDirection, valid_percent
13
- from .travel import CoverModel, Measurement, rotation_to_tilt, tilt_to_rotation
13
+ from .travel import (
14
+ CoverModel,
15
+ Measurement,
16
+ closed_tilts,
17
+ open_rotation,
18
+ open_tilt,
19
+ rotation_to_tilt,
20
+ tilt_angles,
21
+ tilt_to_rotation,
22
+ )
14
23
 
15
24
  if TYPE_CHECKING:
16
25
  from .destination import Destination
@@ -238,6 +247,29 @@ class Action:
238
247
  """Convert a tilt (0 closed, 100 open) to a rotation with the limits in use."""
239
248
  return tilt_to_rotation(tilt, *self.rotation_range)
240
249
 
250
+ @property
251
+ def open_rotation(self) -> int:
252
+ """Return the rotation of open slats, closest to 0 within the limits in use."""
253
+ return open_rotation(*self.rotation_range)
254
+
255
+ @property
256
+ def open_tilt(self) -> int:
257
+ """Return the tilt of open slats with the limits in use."""
258
+ return open_tilt(*self.rotation_range)
259
+
260
+ @property
261
+ def closed_tilts(self) -> list[int]:
262
+ """Return the tilts of closed slats with the limits in use, see closed_tilts."""
263
+ return closed_tilts(*self.rotation_range)
264
+
265
+ @property
266
+ def tilt_angles(self) -> tuple[int, int] | None:
267
+ """Return the slat angles in degrees at tilt 0 and at tilt 100.
268
+
269
+ None if the limits in use do not give two different angles.
270
+ """
271
+ return tilt_angles(*self.rotation_range)
272
+
241
273
  def start_move(self, now: float, target: float, tilt: int | None = None) -> float:
242
274
  """Handle an accepted drive command with the stored travel times.
243
275
 
@@ -78,6 +78,59 @@ def tilt_to_rotation(tilt: float, minimum: float, maximum: float) -> int:
78
78
  return math.floor(rotation + 0.5)
79
79
 
80
80
 
81
+ def open_rotation(minimum: float, maximum: float) -> int:
82
+ """Return the rotation of open slats, the rotation closest to 0 within the limits.
83
+
84
+ At rotation 0 the slats are horizontal and let the most light through.
85
+ The hub takes whole numbers, so the result is rounded.
86
+ """
87
+ return math.floor(max(minimum, min(maximum, 0.0)) + 0.5)
88
+
89
+
90
+ def open_tilt(minimum: float, maximum: float) -> int:
91
+ """Return the tilt of open slats, see open_rotation."""
92
+ return rotation_to_tilt(open_rotation(minimum, maximum), minimum, maximum)
93
+
94
+
95
+ def closed_tilts(minimum: float, maximum: float) -> list[int]:
96
+ """Return the tilts of closed slats, the one to close to first.
97
+
98
+ Closed is the end where the slats lie the flattest, the largest absolute
99
+ rotation, so slats that turn evenly over the horizontal position close at
100
+ both ends and a slat roof with uneven limits at one. Tilt 0, the maximum
101
+ rotation, comes first: the hub turns the slats there when it closes the
102
+ cover. The end of the open tilt is never closed.
103
+ """
104
+ opened = open_tilt(minimum, maximum)
105
+ flattest = max(abs(minimum), abs(maximum))
106
+ return [
107
+ tilt
108
+ for tilt, rotation in ((0, maximum), (100, minimum))
109
+ if abs(rotation) == flattest and tilt != opened
110
+ ]
111
+
112
+
113
+ def rotation_to_angle(rotation: float) -> int:
114
+ """Convert a rotation to a slat angle in whole degrees from -90 to 90.
115
+
116
+ The rotation of the hub is in degrees, 0 is horizontal.
117
+ """
118
+ return max(-90, min(90, math.floor(rotation + 0.5)))
119
+
120
+
121
+ def tilt_angles(minimum: float, maximum: float) -> tuple[int, int] | None:
122
+ """Return the slat angles at tilt 0 and at tilt 100.
123
+
124
+ Returns None if the limits do not give two different angles.
125
+ """
126
+ if maximum <= minimum:
127
+ return None
128
+ start, end = rotation_to_angle(maximum), rotation_to_angle(minimum)
129
+ if start == end:
130
+ return None
131
+ return start, end
132
+
133
+
81
134
  class CoverModel:
82
135
  """Displayed state of one cover."""
83
136
 
@@ -11,7 +11,14 @@ from pywmswebcontrolpro.const import (
11
11
  WMS_WebControl_pro_API_actionDescription,
12
12
  WMS_WebControl_pro_API_actionType,
13
13
  )
14
- from pywmswebcontrolpro.travel import rotation_to_tilt, tilt_to_rotation
14
+ from pywmswebcontrolpro.travel import (
15
+ closed_tilts,
16
+ open_rotation,
17
+ open_tilt,
18
+ rotation_to_tilt,
19
+ tilt_angles,
20
+ tilt_to_rotation,
21
+ )
15
22
  from pywmswebcontrolpro.webcontrol import WebControlPro
16
23
 
17
24
  from .conftest import FakeGateway, stored_settings
@@ -210,3 +217,120 @@ async def test_rotation_range_can_be_set_and_reset(
210
217
  await action.reset_rotation_range()
211
218
  assert action.rotation_range == (-75, 75)
212
219
  assert not (tmp_path / str(SLAT_DEST_ID)).exists()
220
+
221
+
222
+ @pytest.mark.parametrize(
223
+ ("minimum", "maximum", "rotation", "tilt"),
224
+ [
225
+ (-75, 75, 0, 50),
226
+ (-90, 90, 0, 50),
227
+ (-75, 78, 0, 51),
228
+ (-60, 80, 0, 57),
229
+ (-75, 0, 0, 0),
230
+ (0, 75, 0, 100),
231
+ (10, 75, 10, 100),
232
+ (-75, -10, -10, 0),
233
+ (-74.6, 74.4, 0, 50),
234
+ ],
235
+ )
236
+ def test_open_position_is_the_rotation_closest_to_zero(
237
+ minimum: float, maximum: float, rotation: int, tilt: int
238
+ ) -> None:
239
+ """Horizontal slats let the most light through, else the nearest limit."""
240
+ assert open_rotation(minimum, maximum) == rotation
241
+ assert open_tilt(minimum, maximum) == tilt
242
+
243
+
244
+ @pytest.mark.parametrize(
245
+ ("minimum", "maximum", "closed"),
246
+ [
247
+ (-75, 75, [0, 100]),
248
+ (-75, 78, [0]),
249
+ (-74.6, 74.4, [100]),
250
+ (-90, 90, [0, 100]),
251
+ (-60, 80, [0]),
252
+ (-100, 50, [100]),
253
+ (-50, 100, [0]),
254
+ (-75, 0, [100]),
255
+ (10, 75, [0]),
256
+ (-75, -10, [100]),
257
+ (0, 0, [100]),
258
+ ],
259
+ )
260
+ def test_closed_is_the_flattest_end(
261
+ minimum: float, maximum: float, closed: list[int]
262
+ ) -> None:
263
+ """The flattest end closes, tilt 0 first, never the open end."""
264
+ assert closed_tilts(minimum, maximum) == closed
265
+
266
+
267
+ @pytest.mark.parametrize(
268
+ ("minimum", "maximum", "angles"),
269
+ [
270
+ (-75, 75, (75, -75)),
271
+ (-60, 80, (80, -60)),
272
+ (-74.6, 74.4, (74, -75)),
273
+ (-127, 127, (90, -90)),
274
+ (-75, 0, (0, -75)),
275
+ (0, 0, None),
276
+ (10, 5, None),
277
+ (-0.4, 0.4, None),
278
+ (91, 127, None),
279
+ ],
280
+ )
281
+ def test_tilt_angles_follow_the_limits(
282
+ minimum: float, maximum: float, angles: tuple[int, int] | None
283
+ ) -> None:
284
+ """Tilt 0 is the maximum rotation, the angles are whole degrees within 90."""
285
+ assert tilt_angles(minimum, maximum) == angles
286
+
287
+
288
+ async def test_tilt_model_uses_the_limits_of_the_workaround(
289
+ make_control: ControlFactory, gateway: FakeGateway
290
+ ) -> None:
291
+ """With the limits -127 and 127 of the firmware bug, -75 and 75 are used."""
292
+ action = await rotate_action(make_control, gateway, slat_config())
293
+
294
+ assert action.open_rotation == 0
295
+ assert action.open_tilt == 50
296
+ assert action.closed_tilts == [0, 100]
297
+ assert action.tilt_angles == (75, -75)
298
+
299
+
300
+ async def test_tilt_model_uses_other_limits_of_the_hub(
301
+ make_control: ControlFactory, gateway: FakeGateway
302
+ ) -> None:
303
+ """A firmware with correct limits needs no workaround."""
304
+ action = await rotate_action(make_control, gateway, slat_config(-90, 90))
305
+
306
+ assert action.tilt_angles == (90, -90)
307
+ assert action.open_tilt == 50
308
+
309
+
310
+ async def test_tilt_model_follows_learned_and_set_limits(
311
+ make_control: ControlFactory, gateway: FakeGateway, tmp_path: Path
312
+ ) -> None:
313
+ """Learning, overwriting and resetting the limits change the tilt model."""
314
+ action = await rotate_action(make_control, gateway, slat_config(), tmp_path)
315
+ gateway.status_answers = [status_rotation(78)]
316
+ await action._dest.refresh()
317
+
318
+ assert action.tilt_angles == (78, -75)
319
+ assert action.open_tilt == 51
320
+ assert action.closed_tilts == [0]
321
+
322
+ await action.set_rotation_range(minimum=-60, maximum=80)
323
+
324
+ assert action.tilt_angles == (80, -60)
325
+ assert (action.open_rotation, action.open_tilt) == (0, 57)
326
+ assert action.closed_tilts == [0]
327
+
328
+ await action.set_rotation_range(maximum=0)
329
+
330
+ assert action.tilt_angles == (0, -60)
331
+ assert (action.open_tilt, action.closed_tilts) == (0, [100])
332
+
333
+ await action.reset_rotation_range()
334
+
335
+ assert action.tilt_angles == (75, -75)
336
+ assert action.closed_tilts == [0, 100]