Skip to content

Commit

Permalink
Improve code quality for Overkiz integration (#67060)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl committed Feb 22, 2022
1 parent a60c37c commit 30c9b8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
6 changes: 2 additions & 4 deletions homeassistant/components/overkiz/coordinator.py
Expand Up @@ -6,7 +6,7 @@

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,
Expand Down Expand Up @@ -55,9 +55,7 @@ def __init__(
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)
Expand Down
15 changes: 5 additions & 10 deletions homeassistant/components/overkiz/executor.py
Expand Up @@ -8,7 +8,6 @@
from pyoverkiz.models import Command, Device
from pyoverkiz.types import StateType as OverkizStateType

from .const import LOGGER
from .coordinator import OverkizDataUpdateCoordinator


Expand Down Expand Up @@ -59,15 +58,11 @@ def select_attribute(self, *attributes: str) -> OverkizStateType:

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
exec_id = await self.coordinator.client.execute_command(
self.device.device_url,
Command(command_name, list(args)),
"Home Assistant",
)

# ExecutionRegisteredEvent doesn't contain the device_url, thus we need to register it here
self.coordinator.executions[exec_id] = {
Expand Down

0 comments on commit 30c9b8e

Please sign in to comment.