Fix RTS device delays in Overkiz integration (#67124)

This commit is contained in:
Mick Vleeshouwer 2022-02-23 10:46:08 -08:00 committed by GitHub
parent 731f9ca7e0
commit cb070f3138
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)),