You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix RTS duration injection and add comprehensive tests (#2068)
## Summary
- **Fixes the RTS duration injection logic** to correctly handle
multi-param commands like `tiltPositive` and `moveOf` based on the
Overkiz API documentation
- **Renames `rts_command_duration` to `default_rts_command_duration`**
to make clear it's a default that users can override by passing the
duration themselves
- **Adds 50 tests** covering all RTS injection scenarios
## Problem
The original implementation used `current_count < nparams` which would
incorrectly inject duration into domain-specific parameter slots. For
example, `tiltPositive(nparams=2)` called with only 1 param would get
duration injected as the position value.
## Fix
Per the Overkiz API docs, the **last parameter of every RTS command is
always the execution duration**. The correct injection rule is
`current_count == nparams - 1` — only inject when all domain-specific
params are filled and exactly the duration slot remains empty.
| Command | nparams | Last param | Injection behavior |
|---------|---------|------------|--------------------|
| `close`, `open`, `up`, `down`, `stop`, `my`, `rest` | 1 | duration
(default 30s) | Injected when called with no args |
| `tiltPositive`, `tiltNegative`, `moveOf` | 2 | duration (default 15s)
| Injected when called with position arg only |
| `identify`, `test` | 0 | — | Never injected |
If a user explicitly provides the duration parameter, their value is
never overwritten.
## Test plan
- [x] All 50 RTS injection tests pass
- [x] Full test suite (480 tests) passes
- [x] mypy and ty type checking pass
- [ ] Verify HA integration works with renamed
`default_rts_command_duration` setting
RTS devices have a default execution duration of 30 seconds, which blocks consecutive commands until the duration expires. To avoid this, you can configure `rts_command_duration` in `OverkizClientSettings`. The client will automatically inject the configured duration into RTS commands that support it, based on the command definition (`nparams`).
297
+
For RTS commands, the **last parameter is always the execution duration** (defaults to 15–30 seconds depending on the command). This blocks consecutive commands until the duration expires.
298
+
299
+
You can configure `default_rts_command_duration` in `OverkizClientSettings` to override this default. The client injects this value as the duration parameter only when the user has not already provided it explicitly.
298
300
299
301
```python
300
302
from pyoverkiz.auth.credentials import UsernamePasswordCredentials
@@ -305,11 +307,19 @@ from pyoverkiz.enums import Server
With `rts_command_duration=0`, the execution duration is set to 0 seconds for supported commands, allowing consecutive commands to be sent without delay. Commands that don't accept a duration parameter (like `identify` or `test`) are left unchanged.
314
+
With `default_rts_command_duration=0`, consecutive commands can be sent without delay. If a user passes the duration explicitly (e.g., `Command(name="close", parameters=[5])`), their value takes precedence.
|`close`, `open`, `up`, `down`, `stop`, `my`, `rest`| 1 | duration (default 30s) | Injected when called with no args |
319
+
|`tiltPositive`, `tiltNegative`, `moveOf`| 2 | duration (default 15s) | Injected when called with position arg only |
320
+
|`identify`, `test`| 0 | — | Never injected (no parameters) |
321
+
322
+
The injection rule: duration is injected only when all domain-specific parameters have been provided but the duration slot is still empty (`current_count == nparams - 1`). If the user already provides the duration themselves, the configured default is not applied.
Copy file name to clipboardExpand all lines: docs/migration-v2.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -406,7 +406,7 @@ These are not breaking, but worth knowing about when migrating:
406
406
407
407
-**Client settings** — behavioral configuration is now grouped in `OverkizClientSettings`, passed via the `settings` parameter. This replaces standalone constructor parameters like `action_queue`.
408
408
-**Action queue** — batch device executions automatically. See the [action queue guide](action-queue.md).
409
-
-**RTS command duration** — automatically inject execution duration into RTS commands to prevent the default 30-second blocking behavior. See [RTS command duration](device-control.md#rts-command-duration).
409
+
-**RTS command duration** — override the default execution duration for RTS commands (15–30s) to prevent blocking consecutive commands. See [RTS command duration](device-control.md#rts-command-duration).
410
410
-**Device helpers** — `Device.get_command_definition()` for looking up command metadata.
411
411
-**Reference endpoints** — query server metadata: `get_reference_ui_classes()`, `get_reference_ui_widgets()`, `get_reference_ui_profile()`, `get_reference_controllable_types()`, etc.
0 commit comments