mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Improve code quality for Overkiz integration (#67060)
This commit is contained in:
parent
a60c37cdb8
commit
30c9b8ee56
@ -6,7 +6,7 @@ import logging
|
||||
|
||||
from aiohttp import ServerDisconnectedError
|
||||
from pyoverkiz.client import OverkizClient
|
||||
from pyoverkiz.enums import EventName, ExecutionState
|
||||
from pyoverkiz.enums import EventName, ExecutionState, Protocol
|
||||
from pyoverkiz.exceptions import (
|
||||
BadCredentialsException,
|
||||
InvalidEventListenerIdException,
|
||||
@ -55,9 +55,7 @@ class OverkizDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Device]]):
|
||||
self.client = client
|
||||
self.devices: dict[str, Device] = {d.device_url: d for d in devices}
|
||||
self.is_stateless = all(
|
||||
device.device_url.startswith("rts://")
|
||||
or device.device_url.startswith("internal://")
|
||||
for device in devices
|
||||
device.protocol in (Protocol.RTS, Protocol.INTERNAL) for device in devices
|
||||
)
|
||||
self.executions: dict[str, dict[str, str]] = {}
|
||||
self.areas = self._places_to_area(places)
|
||||
|
@ -8,7 +8,6 @@ from pyoverkiz.enums.command import OverkizCommand
|
||||
from pyoverkiz.models import Command, Device
|
||||
from pyoverkiz.types import StateType as OverkizStateType
|
||||
|
||||
from .const import LOGGER
|
||||
from .coordinator import OverkizDataUpdateCoordinator
|
||||
|
||||
|
||||
@ -59,15 +58,11 @@ class OverkizExecutor:
|
||||
|
||||
async def async_execute_command(self, command_name: str, *args: Any) -> None:
|
||||
"""Execute device command in async context."""
|
||||
try:
|
||||
exec_id = await self.coordinator.client.execute_command(
|
||||
self.device.device_url,
|
||||
Command(command_name, list(args)),
|
||||
"Home Assistant",
|
||||
)
|
||||
except Exception as exception: # pylint: disable=broad-except
|
||||
LOGGER.error(exception)
|
||||
return
|
||||
|
||||
# ExecutionRegisteredEvent doesn't contain the device_url, thus we need to register it here
|
||||
self.coordinator.executions[exec_id] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user