Skip to content

Conversation

@iMicknl
Copy link
Owner

@iMicknl iMicknl commented Dec 28, 2025

Breaking changes

  • client.execute_command() and client.execute_commands() are replaced by client.execute_action_group()

Enhancements

  • client.execute_action_group() now supports multiple execution modes (high priority, internal, geolocated)
  • client.execute_action_group() now supports multiple device actions in the same request

Proposal

The current execution methods are poorly typed and do not support concurrent execution across multiple devices, which makes it impossible to properly work around TooManyExecutionsException and TooManyConcurrentRequestsException.

The main change is the move from client.execute_command() and client.execute_commands() to a single client.execute_action_group(). An action group takes a list of actions, each of which can include multiple device actions, including multiple commands per action.

Method examples

await client.execute_action_group(
    actions=[
        Action(
            device_url="io://1234-5678-1234/12345678",
            commands=[
                Command(name="down"),
                Command(name="refresh")
            ]
        )
    ],
    label="Execution via Home Assistant"
)

New (mode) options like high priority will be possible now:

await client.execute_action_group(
    actions=[
        Action(
            device_url="io://1234-5678-1234/12345678",
            commands=[
                Command(name=OverkizCommand.SET_CLOSURE, parameters=[0])
            ]
        )
    ],
    label="Execution via Home Assistant",
    mode=CommandMode.HIGH_PRIORITY
)

Next steps

This could serve as a foundation for grouping commands that are executed within a short time window, for example when triggered by a scene or automation in Home Assistant. Requests issued close together could be batched and sent as a single action group, reducing the impact of current Overkiz limitations.

The open question is where this queue should live: inside this integration itself, or as part of the Home Assistant core implementation.

@iMicknl
Copy link
Owner Author

iMicknl commented Dec 28, 2025

I am not a huge fan of how we serialize the models to JSON (and vice-versa) with attrs and humps. We might need to see if moving to pydantic is a cleaner option here.

@iMicknl iMicknl changed the base branch from main to v2/main December 29, 2025 11:34
@iMicknl iMicknl added this to the 2.0 milestone Dec 29, 2025
@iMicknl iMicknl force-pushed the v2/improve_action_execution branch 2 times, most recently from 9b2bc1e to 7ee723f Compare December 29, 2025 15:46
@iMicknl iMicknl marked this pull request as ready for review December 29, 2025 20:25
@iMicknl iMicknl requested a review from tetienne as a code owner December 29, 2025 20:25
Copilot AI review requested due to automatic review settings December 29, 2025 20:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors command execution to use a new execute_action_group() method that replaces the existing execute_command() and execute_commands() methods. The refactoring improves type safety, enables concurrent execution across multiple devices, and introduces support for command execution modes (high priority, geolocated, internal).

Key changes:

  • Introduced a new serializers module to centralize payload formatting (snake_case to camelCase conversion)
  • Refactored the Command class from a dict-based model to an attrs-based class with proper typing and a to_payload() method
  • Added execute_action_group() method with support for CommandMode options

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyoverkiz/serializers.py New module that handles JSON key formatting (snake_case to camelCase) and special abbreviation fixes like deviceURL
pyoverkiz/models.py Refactored Command class to use attrs with typed parameters supporting OverkizCommandParam enums; updated Action class to accept Command objects and added to_payload methods
pyoverkiz/client.py Replaced execute_command/execute_commands with execute_action_group that supports multiple CommandMode options (high priority, geolocated, internal)
tests/test_serializers.py Added comprehensive tests for payload serialization including nested structures and device URL handling
tests/test_models.py Added tests for Command and Action to_payload methods including None field omission and enum conversion
tests/test_client.py Added test to verify execute_action_group correctly omits None fields and applies proper serialization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

iMicknl and others added 5 commits December 29, 2025 20:47
…h camelCase conversion and omission of None fields
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@iMicknl iMicknl force-pushed the v2/improve_action_execution branch from 78fedac to d205616 Compare December 29, 2025 20:48
@iMicknl iMicknl merged commit f617075 into v2/main Dec 29, 2025
6 checks passed
@iMicknl iMicknl deleted the v2/improve_action_execution branch December 29, 2025 20:55
@iMicknl iMicknl mentioned this pull request Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking enhancement New feature or request v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants