mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +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 aiohttp import ServerDisconnectedError
|
||||||
from pyoverkiz.client import OverkizClient
|
from pyoverkiz.client import OverkizClient
|
||||||
from pyoverkiz.enums import EventName, ExecutionState
|
from pyoverkiz.enums import EventName, ExecutionState, Protocol
|
||||||
from pyoverkiz.exceptions import (
|
from pyoverkiz.exceptions import (
|
||||||
BadCredentialsException,
|
BadCredentialsException,
|
||||||
InvalidEventListenerIdException,
|
InvalidEventListenerIdException,
|
||||||
@ -55,9 +55,7 @@ class OverkizDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Device]]):
|
|||||||
self.client = client
|
self.client = client
|
||||||
self.devices: dict[str, Device] = {d.device_url: d for d in devices}
|
self.devices: dict[str, Device] = {d.device_url: d for d in devices}
|
||||||
self.is_stateless = all(
|
self.is_stateless = all(
|
||||||
device.device_url.startswith("rts://")
|
device.protocol in (Protocol.RTS, Protocol.INTERNAL) for device in devices
|
||||||
or device.device_url.startswith("internal://")
|
|
||||||
for device in devices
|
|
||||||
)
|
)
|
||||||
self.executions: dict[str, dict[str, str]] = {}
|
self.executions: dict[str, dict[str, str]] = {}
|
||||||
self.areas = self._places_to_area(places)
|
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.models import Command, Device
|
||||||
from pyoverkiz.types import StateType as OverkizStateType
|
from pyoverkiz.types import StateType as OverkizStateType
|
||||||
|
|
||||||
from .const import LOGGER
|
|
||||||
from .coordinator import OverkizDataUpdateCoordinator
|
from .coordinator import OverkizDataUpdateCoordinator
|
||||||
|
|
||||||
|
|
||||||
@ -59,15 +58,11 @@ class OverkizExecutor:
|
|||||||
|
|
||||||
async def async_execute_command(self, command_name: str, *args: Any) -> None:
|
async def async_execute_command(self, command_name: str, *args: Any) -> None:
|
||||||
"""Execute device command in async context."""
|
"""Execute device command in async context."""
|
||||||
try:
|
exec_id = await self.coordinator.client.execute_command(
|
||||||
exec_id = await self.coordinator.client.execute_command(
|
self.device.device_url,
|
||||||
self.device.device_url,
|
Command(command_name, list(args)),
|
||||||
Command(command_name, list(args)),
|
"Home Assistant",
|
||||||
"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
|
# ExecutionRegisteredEvent doesn't contain the device_url, thus we need to register it here
|
||||||
self.coordinator.executions[exec_id] = {
|
self.coordinator.executions[exec_id] = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user