Skip to content

Commit 174617c

Browse files
authored
Harvest enum values from controllable definitions and fixtures, fix generation docs (#2085)
## Summary While reviewing the enum-generation documentation, I found the generator was leaving real data on the table and the docs describing it were partly wrong. This PR fixes both. ### 1. Harvest `OverkizCommandParam` from controllable definitions `extract_state_values_from_servers` only read `OverkizCommandParam` values from `protocols.*.states[].enumValues`, missing: - ~1600 `DiscreteState` `values` arrays in `controllableDefinitions` - `enumValues` on command parameters in the protocols section This adds **313 previously-missing parameter values** (e.g. `A_B_C`, `AUTO_FAN`, `MAINS_SINGLE_PHASE`). Two safety details: - Purely numeric values (`"1"`–`"9"`) can't be valid Python identifiers — now skipped and reported in the run output instead of emitting broken code. - Two verbatim API values contain Cyrillic characters (`pусский`, `yкраїнськийon` from the Atlantic server) — `RUF001` added to the generated file's `noqa` header. ### 2. Merge UI enum values from setup fixtures `state.py` and `command.py` already merged `tests/fixtures/setup/*.json`, but `ui.py` and `ui_profile.py` did not. They now do, capturing real devices whose UI values the reference endpoints of our available servers don't expose. Adds the `Startable` and `StatefulStartable` profiles and lets three previously hardcoded widgets come from real data. `protocol.py` stays metadata-only — Protocol members need the full `id`/`prefix`/`name`/`label`, which fixtures don't carry. ### 3. Fix `docs/development-utils.md` The `generate_enums.py` "Generates" table omitted `state.py` entirely, listed an incomplete source for `command.py`, and didn't reflect fixtures as a source for the UI enums. Corrected and expanded. ## Test plan - [x] `uv run utils/generate_enums.py` regenerates cleanly - [x] `ruff`, `mypy`, `ty` pass - [x] 456 tests pass
1 parent c80be27 commit 174617c

5 files changed

Lines changed: 419 additions & 23 deletions

File tree

docs/development-utils.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,17 @@ uv run utils/generate_enums.py
6565
| File | Source |
6666
|------|--------|
6767
| `pyoverkiz/enums/protocol.py` | `referenceMetadata.protocolTypes` |
68-
| `pyoverkiz/enums/ui.py` | `referenceMetadata.uiClasses`, `uiWidgets`, `uiClassifiers` |
69-
| `pyoverkiz/enums/ui_profile.py` | `referenceMetadata.uiProfiles` |
70-
| `pyoverkiz/enums/command.py` | `protocols.*.commands` + `tests/fixtures/setup/*.json` |
71-
| `docs/ui-profiles.md` | `referenceMetadata.uiProfiles` |
68+
| `pyoverkiz/enums/ui.py` | `referenceMetadata.uiClasses`/`uiWidgets`/`uiClassifiers` + `tests/fixtures/setup/*.json` |
69+
| `pyoverkiz/enums/ui_profile.py` | `referenceMetadata.uiProfiles` + `tests/fixtures/setup/*.json` |
70+
| `pyoverkiz/enums/state.py` | `protocols.*.states`, `controllableDefinitions.*.states`/`attributes` + `tests/fixtures/setup/*.json` |
71+
| `pyoverkiz/enums/command.py` | `protocols.*.commands`/`states`, `controllableDefinitions.*.states` + `tests/fixtures/setup/*.json` |
72+
| `docs/ui-profiles.md` | `referenceMetadata.uiProfiles` + `tests/fixtures/setup/*.json` |
7273

73-
Data from all available server files is merged (union of all values). Hardcoded entries for protocols and widgets not found on any server are appended.
74+
`state.py` holds `OverkizState` + `OverkizAttribute`; `command.py` holds `OverkizCommand` + `OverkizCommandParam` (parameter values are harvested from discrete state values and command parameter enums). The `ExecutionMode` enum in `command.py` is hand-written and preserved across regeneration.
75+
76+
Data from all available server files is merged (union of all values). The setup fixtures in `tests/fixtures/setup/` are merged in as an additional source: they capture real devices whose UI classes, widgets, classifiers and profiles (and states, commands, attributes) are not always exposed by the reference endpoints of the servers we have access to. Profiles found only in fixtures are added without details. `protocol.py` is the exception — Protocol members need the full `id`/`prefix`/`name`/`label` metadata, which fixtures don't carry, so they come only from `referenceMetadata.protocolTypes` plus the hardcoded `ADDITIONAL_PROTOCOLS`.
77+
78+
Hardcoded entries for protocols and widgets not found on any server are appended (see `ADDITIONAL_PROTOCOLS` and `ADDITIONAL_WIDGETS` in the script). Discrete values that cannot form a valid Python identifier (e.g. the purely numeric `"1"`, `"2"`) are skipped and reported in the run output.
7479

7580
## generate_device_catalog.py
7681

docs/ui-profiles.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ UI profiles describe device capabilities through the commands they accept and th
1010
!!! note
1111
This page is auto-generated. Run `uv run utils/generate_enums.py` to regenerate.
1212

13-
**190 profiles** documented below.
13+
**192 profiles** documented below.
1414

1515
## AirFan
1616

@@ -832,6 +832,10 @@ UI profiles describe device capabilities through the commands they accept and th
832832
| `start` | | Start the default actuator behavior (movement, sound or timer) |
833833
| `stop` | | Stop the current actuator behavior (movement, sound or timer) |
834834

835+
## Startable
836+
837+
*Details unavailable.*
838+
835839
## StatefulAirFan
836840

837841
### Commands
@@ -1767,6 +1771,10 @@ UI profiles describe device capabilities through the commands they accept and th
17671771
|-------|------|-------------|
17681772
| `core:StartedStoppedState` | `string``started`, `stopped` | Indicate if the sequence if started or stopped |
17691773

1774+
## StatefulStartable
1775+
1776+
*Details unavailable.*
1777+
17701778
## StatefulSwitchable
17711779

17721780
### Commands

0 commit comments

Comments
 (0)