Commit 9e55549
authored
## Summary
Fixes #2089. `Command.parameters` could not be typed with `dict`
elements, even though the Overkiz API accepts (and some commands
require) a dict parameter. This forced consumers to `cast()` around the
type, defeating the type checker for the exact case where it matters.
Examples of dict-valued command parameters:
- `setAbsenceStartDate` / `setAbsenceEndDate` — take a date dict
(`{"year": ..., "month": ..., ...}`)
- `setCurrentOperatingMode` — takes `{"relaunch": "off", "absence":
"on"}`
## Changes
- **Widen `CommandParameterValue`** in `pyoverkiz/types.py` to include
`dict[str, Any]` and `list[Any]`, consistent with how `StateType` is
already defined.
- **Fix `Command.to_payload`** in `pyoverkiz/models.py`. The serializer
previously stringified anything that wasn't a `str`/`int`/`float`/`bool`
(to handle `OverkizCommandParam` enums), so a dict parameter would have
been sent as a Python `repr` string instead of a JSON object. Dicts and
lists now pass through untouched.
- **Add a test** asserting a dict parameter survives `to_payload`
round-trip.
## Notes
The issue's code snippet referenced a stale `class Command(dict)` shape;
the type now lives in `CommandParameterValue` (`types.py`), which is
where this patch widens it.
Once released and the requirement is bumped, the `cast()` workaround in
the Home Assistant `overkiz` integration (water heater absence-date
commands) can be removed.
## Test plan
- [x] `pytest tests/` — 457 passed
- [x] `mypy` clean on changed files
- [x] `ruff check` clean
1 parent 4cc0635 commit 9e55549
3 files changed
Lines changed: 41 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
927 | 927 | | |
928 | 928 | | |
929 | 929 | | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
930 | 967 | | |
931 | 968 | | |
932 | 969 | | |
| |||
0 commit comments