pywmswebcontrolpro 0.2.0__tar.gz → 0.2.1__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.
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/.github/workflows/release.yaml +4 -3
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/CHANGELOG.md +12 -1
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/PKG-INFO +1 -1
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/action.py +1 -1
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/destination.py +6 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/travel.py +11 -2
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/webcontrol.py +23 -4
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/tests/test_configuration.py +37 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/tests/test_travel.py +18 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/.github/workflows/validate.yaml +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/.gitignore +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/.python-version +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/LICENSE +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/README.md +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/mypy.ini +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pyproject.toml +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pytest.ini +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/__init__.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/const.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/exceptions.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/py.typed +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/refresh.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/room.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/scene.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/pywmswebcontrolpro/store.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/requirements_lint.txt +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/requirements_test.txt +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/ruff.toml +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/simulator/simulator.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/tests/__init__.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/tests/conftest.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/tests/test_client.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/tests/test_import.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/tests/test_refresh.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/tests/test_rotation.py +0 -0
- {pywmswebcontrolpro-0.2.0 → pywmswebcontrolpro-0.2.1}/tests/test_settings.py +0 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: Release
|
|
3
|
-
on:
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "*"
|
|
4
7
|
jobs:
|
|
5
8
|
build:
|
|
6
9
|
runs-on: ubuntu-latest
|
|
@@ -33,7 +36,6 @@ jobs:
|
|
|
33
36
|
skip-existing: true
|
|
34
37
|
print-hash: true
|
|
35
38
|
github-release:
|
|
36
|
-
if: github.ref_type == 'tag'
|
|
37
39
|
runs-on: ubuntu-latest
|
|
38
40
|
needs: test-pypi
|
|
39
41
|
permissions:
|
|
@@ -60,7 +62,6 @@ jobs:
|
|
|
60
62
|
env:
|
|
61
63
|
GH_TOKEN: "${{ github.token }}"
|
|
62
64
|
prod-pypi:
|
|
63
|
-
if: github.ref_type == 'tag'
|
|
64
65
|
runs-on: ubuntu-latest
|
|
65
66
|
needs: github-release
|
|
66
67
|
environment:
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.2.
|
|
3
|
+
## 0.2.1 (unreleased)
|
|
4
|
+
|
|
5
|
+
Changed:
|
|
6
|
+
|
|
7
|
+
- A measured tilt without a position is taken over by the movement model
|
|
8
|
+
(`Measurement.applied` is true). Before, the whole measurement was dropped.
|
|
9
|
+
- `WebControlPro.refresh()` takes over changed names of known destinations and names
|
|
10
|
+
them in `ConfigChanges.renamed`.
|
|
11
|
+
- Packages are only built and uploaded to TestPyPI and PyPI for a tag, no longer for
|
|
12
|
+
every push.
|
|
13
|
+
|
|
14
|
+
## 0.2.0
|
|
4
15
|
|
|
5
16
|
Breaking changes:
|
|
6
17
|
|
|
@@ -292,7 +292,7 @@ class Action:
|
|
|
292
292
|
def apply_measurement(
|
|
293
293
|
self, now: float, position: int | None, tilt: int | None
|
|
294
294
|
) -> Measurement:
|
|
295
|
-
"""Take over a measured position unless a drive is running."""
|
|
295
|
+
"""Take over a measured position or tilt unless a drive is running."""
|
|
296
296
|
return self.model.apply_measurement(now, position, tilt)
|
|
297
297
|
|
|
298
298
|
async def sync(self) -> None:
|
|
@@ -88,6 +88,12 @@ class Destination:
|
|
|
88
88
|
"""Return the name of the destination."""
|
|
89
89
|
return self._names[0]
|
|
90
90
|
|
|
91
|
+
def _rename(self, names: list[str]) -> bool:
|
|
92
|
+
"""Take over the names of the configuration, True if the name changed."""
|
|
93
|
+
changed = names[0] != self.name
|
|
94
|
+
self._names = names
|
|
95
|
+
return changed
|
|
96
|
+
|
|
91
97
|
@property
|
|
92
98
|
def actions(self) -> dict[int, Action]:
|
|
93
99
|
"""Return the actions of the destination by id."""
|
|
@@ -226,10 +226,19 @@ class CoverModel:
|
|
|
226
226
|
def apply_measurement(
|
|
227
227
|
self, now: float, position: int | None, tilt: int | None
|
|
228
228
|
) -> Measurement:
|
|
229
|
-
"""Take over a measured value unless a drive is running.
|
|
229
|
+
"""Take over a measured value unless a drive is running.
|
|
230
|
+
|
|
231
|
+
A tilt without a position is taken over as well, the position and its
|
|
232
|
+
source stay as they are.
|
|
233
|
+
"""
|
|
230
234
|
self.advance(now)
|
|
231
|
-
if self.is_travelling
|
|
235
|
+
if self.is_travelling:
|
|
232
236
|
return Measurement(applied=False, deviation=False)
|
|
237
|
+
if position is None:
|
|
238
|
+
if tilt is None:
|
|
239
|
+
return Measurement(applied=False, deviation=False)
|
|
240
|
+
self.tilt = int(clamp_percent(tilt) + 0.5)
|
|
241
|
+
return Measurement(applied=True, deviation=False)
|
|
233
242
|
old = self.position
|
|
234
243
|
self.position = clamp_percent(position)
|
|
235
244
|
if tilt is not None:
|
|
@@ -39,12 +39,20 @@ DEFAULT_RETRY_DELAY = 1.0
|
|
|
39
39
|
DEFAULT_REQUEST_SPACING = 0.5
|
|
40
40
|
|
|
41
41
|
|
|
42
|
+
def _names(names: object) -> list[str]:
|
|
43
|
+
"""Return the names of a destination or raise ValueError."""
|
|
44
|
+
if not isinstance(names, list) or not names:
|
|
45
|
+
raise ValueError(f"Unexpected names: {names!r}")
|
|
46
|
+
return [str(name) for name in names]
|
|
47
|
+
|
|
48
|
+
|
|
42
49
|
@dataclass(frozen=True)
|
|
43
50
|
class ConfigChanges:
|
|
44
|
-
"""Destinations that appeared or
|
|
51
|
+
"""Destinations that appeared, disappeared or got a new name with a refresh."""
|
|
45
52
|
|
|
46
53
|
added: frozenset[int] = frozenset()
|
|
47
54
|
removed: frozenset[int] = frozenset()
|
|
55
|
+
renamed: frozenset[int] = frozenset()
|
|
48
56
|
|
|
49
57
|
|
|
50
58
|
class WebControlPro:
|
|
@@ -183,9 +191,10 @@ class WebControlPro:
|
|
|
183
191
|
and leaves the known destinations, rooms and scenes unchanged.
|
|
184
192
|
|
|
185
193
|
A destination that is already known stays the same object, so its
|
|
186
|
-
actions keep their movement model and stored state.
|
|
187
|
-
destinations are created, and the
|
|
188
|
-
|
|
194
|
+
actions keep their movement model and stored state. It takes over the
|
|
195
|
+
names of the configuration. Only new destinations are created, and the
|
|
196
|
+
result names the destinations that appeared, disappeared or got a new
|
|
197
|
+
name. Rooms and scenes are created again.
|
|
189
198
|
"""
|
|
190
199
|
config = await self._getConfiguration()
|
|
191
200
|
known = self._dests
|
|
@@ -196,6 +205,11 @@ class WebControlPro:
|
|
|
196
205
|
}
|
|
197
206
|
rooms = {room["id"]: Room(self, **room) for room in config["rooms"]}
|
|
198
207
|
scenes = {scene["id"]: Scene(self, **scene) for scene in config["scenes"]}
|
|
208
|
+
names = {
|
|
209
|
+
dest["id"]: _names(dest["names"])
|
|
210
|
+
for dest in config["destinations"]
|
|
211
|
+
if dest["id"] in known
|
|
212
|
+
}
|
|
199
213
|
except (KeyError, TypeError, ValueError) as err:
|
|
200
214
|
raise WebControlProResponseError(
|
|
201
215
|
f"Unexpected configuration: {err!r}"
|
|
@@ -207,6 +221,11 @@ class WebControlPro:
|
|
|
207
221
|
return ConfigChanges(
|
|
208
222
|
added=frozenset(self._dests) - frozenset(known),
|
|
209
223
|
removed=frozenset(known) - frozenset(self._dests),
|
|
224
|
+
renamed=frozenset(
|
|
225
|
+
dest_id
|
|
226
|
+
for dest_id, dest_names in names.items()
|
|
227
|
+
if dests[dest_id]._rename(dest_names)
|
|
228
|
+
),
|
|
210
229
|
)
|
|
211
230
|
|
|
212
231
|
def dest(self, name: str) -> Destination:
|
|
@@ -4,6 +4,9 @@ from collections.abc import Callable
|
|
|
4
4
|
from copy import deepcopy
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from pywmswebcontrolpro.exceptions import WebControlProResponseError
|
|
7
10
|
from pywmswebcontrolpro.webcontrol import ConfigChanges, WebControlPro
|
|
8
11
|
|
|
9
12
|
from .conftest import CONFIG, DEST_ID, FakeGateway
|
|
@@ -57,3 +60,37 @@ async def test_refresh_keeps_the_known_destinations(
|
|
|
57
60
|
|
|
58
61
|
assert changes == ConfigChanges(added=frozenset({NEW_DEST_ID}))
|
|
59
62
|
assert control.dests[DEST_ID] is known
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
async def test_refresh_takes_over_a_new_name(
|
|
66
|
+
make_control: Callable[..., WebControlPro], gateway: FakeGateway
|
|
67
|
+
) -> None:
|
|
68
|
+
"""A known destination gets the name of the configuration."""
|
|
69
|
+
control = make_control()
|
|
70
|
+
await control.refresh()
|
|
71
|
+
known = control.dests[DEST_ID]
|
|
72
|
+
gateway.config = deepcopy(CONFIG)
|
|
73
|
+
gateway.config["destinations"][0]["names"] = ["Renamed", "", "", ""]
|
|
74
|
+
|
|
75
|
+
changes = await control.refresh()
|
|
76
|
+
|
|
77
|
+
assert changes == ConfigChanges(renamed=frozenset({DEST_ID}))
|
|
78
|
+
assert control.dests[DEST_ID] is known
|
|
79
|
+
assert known.name == "Renamed"
|
|
80
|
+
assert (await control.refresh()) == ConfigChanges()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
async def test_refresh_with_broken_names_keeps_the_name(
|
|
84
|
+
make_control: Callable[..., WebControlPro], gateway: FakeGateway
|
|
85
|
+
) -> None:
|
|
86
|
+
"""Names that are not understood leave the destination unchanged."""
|
|
87
|
+
control = make_control()
|
|
88
|
+
await control.refresh()
|
|
89
|
+
name = control.dests[DEST_ID].name
|
|
90
|
+
gateway.config = deepcopy(CONFIG)
|
|
91
|
+
gateway.config["destinations"][0]["names"] = []
|
|
92
|
+
|
|
93
|
+
with pytest.raises(WebControlProResponseError):
|
|
94
|
+
await control.refresh()
|
|
95
|
+
|
|
96
|
+
assert control.dests[DEST_ID].name == name
|
|
@@ -142,12 +142,30 @@ def test_t11_measurement_after_travel_and_deviation():
|
|
|
142
142
|
|
|
143
143
|
def test_t12_measurement_without_position():
|
|
144
144
|
model = known(60, 10)
|
|
145
|
+
source = model.source
|
|
145
146
|
result = model.apply_measurement(5.0, None, 90)
|
|
147
|
+
assert result == travel.Measurement(True, False)
|
|
148
|
+
assert model.position_int == 60
|
|
149
|
+
assert model.tilt == 90
|
|
150
|
+
assert model.source == source
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def test_t12_measurement_without_position_and_tilt():
|
|
154
|
+
model = known(60, 10)
|
|
155
|
+
result = model.apply_measurement(5.0, None, None)
|
|
146
156
|
assert result == travel.Measurement(False, False)
|
|
147
157
|
assert model.position_int == 60
|
|
148
158
|
assert model.tilt == 10
|
|
149
159
|
|
|
150
160
|
|
|
161
|
+
def test_t12_tilt_measurement_during_a_drive_is_ignored():
|
|
162
|
+
model = known(60, 10)
|
|
163
|
+
model.start_move(0.0, 0, 20.0, 20.0)
|
|
164
|
+
result = model.apply_measurement(5.0, None, 90)
|
|
165
|
+
assert result == travel.Measurement(False, False)
|
|
166
|
+
assert model.tilt == 10
|
|
167
|
+
|
|
168
|
+
|
|
151
169
|
def test_t13_first_measurement_is_no_deviation():
|
|
152
170
|
model = CoverModel()
|
|
153
171
|
assert model.apply_measurement(0.0, 0, 0) == travel.Measurement(True, False)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|