Fix RTS device delays in Overkiz integration (#67124)
This commit is contained in:
parent
731f9ca7e0
commit
cb070f3138
1 changed files with 19 additions and 1 deletions
|
@ -4,12 +4,22 @@ from __future__ import annotations
|
|||
from typing import Any
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from pyoverkiz.enums.command import OverkizCommand
|
||||
from pyoverkiz.enums import OverkizCommand, Protocol
|
||||
from pyoverkiz.models import Command, Device
|
||||
from pyoverkiz.types import StateType as OverkizStateType
|
||||
|
||||
from .coordinator import OverkizDataUpdateCoordinator
|
||||
|
||||
# Commands that don't support setting
|
||||
# the delay to another value
|
||||
COMMANDS_WITHOUT_DELAY = [
|
||||
OverkizCommand.IDENTIFY,
|
||||
OverkizCommand.OFF,
|
||||
OverkizCommand.ON,
|
||||
OverkizCommand.ON_WITH_TIMER,
|
||||
OverkizCommand.TEST,
|
||||
]
|
||||
|
||||
|
||||
class OverkizExecutor:
|
||||
"""Representation of an Overkiz device with execution handler."""
|
||||
|
@ -58,6 +68,14 @@ class OverkizExecutor:
|
|||
|
||||
async def async_execute_command(self, command_name: str, *args: Any) -> None:
|
||||
"""Execute device command in async context."""
|
||||
# Set the execution duration to 0 seconds for RTS devices on supported commands
|
||||
# Default execution duration is 30 seconds and will block consecutive commands
|
||||
if (
|
||||
self.device.protocol == Protocol.RTS
|
||||
and command_name not in COMMANDS_WITHOUT_DELAY
|
||||
):
|
||||
args = args + (0,)
|
||||
|
||||
exec_id = await self.coordinator.client.execute_command(
|
||||
self.device.device_url,
|
||||
Command(command_name, list(args)),
|
||||
|
|
Loading…
Add table
Reference in a new issue