From a11091890f94111f8576c20397820c735cd042c4 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Wed, 8 Nov 2023 00:02:34 +0100 Subject: [PATCH] Support continue_on_error for command execution in Overkiz (#103591) --- homeassistant/components/overkiz/executor.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/overkiz/executor.py b/homeassistant/components/overkiz/executor.py index 9095ec8d38e..af29dbaf523 100644 --- a/homeassistant/components/overkiz/executor.py +++ b/homeassistant/components/overkiz/executor.py @@ -5,9 +5,12 @@ from typing import Any, cast from urllib.parse import urlparse from pyoverkiz.enums import OverkizCommand, Protocol +from pyoverkiz.exceptions import OverkizException from pyoverkiz.models import Command, Device, StateDefinition from pyoverkiz.types import StateType as OverkizStateType +from homeassistant.exceptions import HomeAssistantError + from .coordinator import OverkizDataUpdateCoordinator # Commands that don't support setting @@ -88,11 +91,15 @@ class OverkizExecutor: ): parameters.append(0) - exec_id = await self.coordinator.client.execute_command( - self.device.device_url, - Command(command_name, parameters), - "Home Assistant", - ) + try: + exec_id = await self.coordinator.client.execute_command( + self.device.device_url, + Command(command_name, parameters), + "Home Assistant", + ) + # Catch Overkiz exceptions to support `continue_on_error` functionality + except OverkizException as exception: + raise HomeAssistantError(exception) from exception # ExecutionRegisteredEvent doesn't contain the device_url, thus we need to register it here self.coordinator.executions[exec_id] = {