pywmswebcontrolpro 0.7.0__tar.gz → 0.8.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 (38) hide show
  1. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/CHANGELOG.md +9 -1
  2. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/PKG-INFO +2 -2
  3. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/README.md +1 -1
  4. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/cover.py +9 -3
  5. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/test_cover.py +17 -5
  6. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/.github/workflows/release.yaml +0 -0
  7. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/.github/workflows/validate.yaml +0 -0
  8. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/.gitignore +0 -0
  9. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/.python-version +0 -0
  10. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/LICENSE +0 -0
  11. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/mypy.ini +0 -0
  12. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pyproject.toml +0 -0
  13. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pytest.ini +0 -0
  14. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/__init__.py +0 -0
  15. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/action.py +0 -0
  16. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/const.py +0 -0
  17. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/destination.py +0 -0
  18. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/exceptions.py +0 -0
  19. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/py.typed +0 -0
  20. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/refresh.py +0 -0
  21. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/room.py +0 -0
  22. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/scene.py +0 -0
  23. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/store.py +0 -0
  24. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/travel.py +0 -0
  25. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/pywmswebcontrolpro/webcontrol.py +0 -0
  26. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/requirements_lint.txt +0 -0
  27. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/requirements_test.txt +0 -0
  28. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/ruff.toml +0 -0
  29. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/simulator/simulator.py +0 -0
  30. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/__init__.py +0 -0
  31. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/conftest.py +0 -0
  32. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/test_client.py +0 -0
  33. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/test_configuration.py +0 -0
  34. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/test_import.py +0 -0
  35. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/test_refresh.py +0 -0
  36. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/test_rotation.py +0 -0
  37. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/test_settings.py +0 -0
  38. {pywmswebcontrolpro-0.7.0 → pywmswebcontrolpro-0.8.0}/tests/test_travel.py +0 -0
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
 
3
- ## 0.7.0 (unreleased)
3
+ ## 0.8.0 (unreleased)
4
+
5
+ Breaking changes:
6
+
7
+ - `Cover.apply_measurement` is a coroutine. It stores a changed state at once, until
8
+ now a measured value reached `state.json` only with the next status request or
9
+ command.
10
+
11
+ ## 0.7.0
4
12
 
5
13
  Breaking changes:
6
14
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pywmswebcontrolpro
3
- Version: 0.7.0
3
+ Version: 0.8.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
@@ -183,7 +183,7 @@ with commands that keep the two together:
183
183
  requested to check the result. A command that the hub rejects raises a
184
184
  `WebControlProError` and leaves the model unchanged.
185
185
  `advance()` and `apply_measurement(percentage, rotation)` use the same clock as the
186
- commands. The hub takes whole numbers, so the percentage and the rotation are
186
+ commands, `apply_measurement` stores a change at once. The hub takes whole numbers, so the percentage and the rotation are
187
187
  rounded when they are sent.
188
188
  - A rotation while a drive runs is sent together with the drive to its target, so the
189
189
  blind keeps driving and turns its slats at the end. A drive counts as running during
@@ -169,7 +169,7 @@ with commands that keep the two together:
169
169
  requested to check the result. A command that the hub rejects raises a
170
170
  `WebControlProError` and leaves the model unchanged.
171
171
  `advance()` and `apply_measurement(percentage, rotation)` use the same clock as the
172
- commands. The hub takes whole numbers, so the percentage and the rotation are
172
+ commands, `apply_measurement` stores a change at once. The hub takes whole numbers, so the percentage and the rotation are
173
173
  rounded when they are sent.
174
174
  - A rotation while a drive runs is sent together with the drive to its target, so the
175
175
  blind keeps driving and turns its slats at the end. A drive counts as running during
@@ -62,11 +62,17 @@ class Cover:
62
62
  """Move the displayed percentage to now, True if a drive ended with it."""
63
63
  return self.model.advance(monotonic())
64
64
 
65
- def apply_measurement(
65
+ async def apply_measurement(
66
66
  self, percentage: float | None, rotation: int | None
67
67
  ) -> Measurement:
68
- """Take over a measured percentage or rotation unless a drive is running."""
69
- return self._drive.apply_measurement(monotonic(), percentage, rotation)
68
+ """Take over a measured percentage or rotation unless a drive is running.
69
+
70
+ A change is stored at once, so the state after a restart is the
71
+ measured one even when no command or status request follows.
72
+ """
73
+ result = self._drive.apply_measurement(monotonic(), percentage, rotation)
74
+ await self._drive.sync()
75
+ return result
70
76
 
71
77
  async def move(self, percentage: float, rotation: float | None = None) -> float:
72
78
  """Drive to a percentage (0 open, 100 closed) and, if given, turn the slats.
@@ -130,7 +130,7 @@ async def cover(control: WebControlPro, clock: Clock) -> Cover:
130
130
  cover = control.dests[SLAT_DEST_ID].cover(ACTION_DESC.SlatDrive)
131
131
  for direction in TravelDirection:
132
132
  await cover.drive.set_travel_time(direction, TRAVEL_TIME)
133
- cover.apply_measurement(100, 75)
133
+ await cover.apply_measurement(100, 75)
134
134
  return cover
135
135
 
136
136
 
@@ -246,7 +246,7 @@ async def test_open_and_close_turn_the_slats_like_the_hub(
246
246
  percentage: int,
247
247
  rotation: int,
248
248
  ) -> None:
249
- cover.apply_measurement(50, 0)
249
+ await cover.apply_measurement(50, 0)
250
250
 
251
251
  await getattr(cover, command)()
252
252
 
@@ -257,7 +257,7 @@ async def test_open_and_close_turn_the_slats_like_the_hub(
257
257
  async def test_open_and_close_soon_after_a_rotation_keep_the_rotation(
258
258
  cover: Cover, gateway: FakeGateway, clock: Clock, command: str
259
259
  ) -> None:
260
- cover.apply_measurement(50, 0)
260
+ await cover.apply_measurement(50, 0)
261
261
  await cover.set_rotation(45)
262
262
  clock.at(1)
263
263
 
@@ -451,7 +451,19 @@ async def test_measurement_is_taken_over_only_while_the_cover_stands_still(
451
451
  await cover.move(40)
452
452
  clock.at(10)
453
453
 
454
- assert cover.apply_measurement(80, 0).applied is False
454
+ assert (await cover.apply_measurement(80, 0)).applied is False
455
455
  clock.at(30)
456
- assert cover.apply_measurement(42, 15).applied is True
456
+ assert (await cover.apply_measurement(42, 15)).applied is True
457
457
  assert (cover.model.percentage_int, cover.model.rotation) == (42, 15)
458
+
459
+
460
+ async def test_measurement_is_stored_at_once(
461
+ cover: Cover, clock: Clock, tmp_path: Path
462
+ ) -> None:
463
+ clock.at(1)
464
+
465
+ await cover.apply_measurement(42, 15)
466
+
467
+ assert stored_state(tmp_path, SLAT_DEST_ID) == {
468
+ str(DRIVE_ID): {"percentage": 42, "rotation": 15}
469
+ }