Support continue_on_error for command execution in Overkiz (#103591)

This commit is contained in:
Mick Vleeshouwer 2023-11-08 00:02:34 +01:00 committed by GitHub
parent d935d06265
commit a11091890f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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] = {