mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Replace Guardian logged errors with HomeAssistantError in service handlers (#62342)
This commit is contained in:
parent
8eb33ede43
commit
443003795b
@ -21,6 +21,7 @@ from homeassistant.const import (
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import (
|
||||
config_validation as cv,
|
||||
device_registry as dr,
|
||||
@ -203,7 +204,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async with client:
|
||||
await func(call, client)
|
||||
except GuardianError as err:
|
||||
LOGGER.error("Error while executing %s: %s", func.__name__, err)
|
||||
raise HomeAssistantError(
|
||||
f"Error while executing {func.__name__}: {err}"
|
||||
) from err
|
||||
|
||||
return wrapper
|
||||
|
||||
|
@ -9,11 +9,12 @@ from aioguardian.errors import GuardianError
|
||||
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from . import ValveControllerEntity
|
||||
from .const import API_VALVE_STATUS, DATA_CLIENT, DATA_COORDINATOR, DOMAIN, LOGGER
|
||||
from .const import API_VALVE_STATUS, DATA_CLIENT, DATA_COORDINATOR, DOMAIN
|
||||
|
||||
ATTR_AVG_CURRENT = "average_current"
|
||||
ATTR_INST_CURRENT = "instantaneous_current"
|
||||
@ -97,8 +98,7 @@ class ValveControllerSwitch(ValveControllerEntity, SwitchEntity):
|
||||
async with self._client:
|
||||
await self._client.valve.close()
|
||||
except GuardianError as err:
|
||||
LOGGER.error("Error while closing the valve: %s", err)
|
||||
return
|
||||
raise HomeAssistantError(f"Error while closing the valve: {err}") from err
|
||||
|
||||
self._attr_is_on = False
|
||||
self.async_write_ha_state()
|
||||
@ -109,8 +109,7 @@ class ValveControllerSwitch(ValveControllerEntity, SwitchEntity):
|
||||
async with self._client:
|
||||
await self._client.valve.open()
|
||||
except GuardianError as err:
|
||||
LOGGER.error("Error while opening the valve: %s", err)
|
||||
return
|
||||
raise HomeAssistantError(f"Error while opening the valve: {err}") from err
|
||||
|
||||
self._attr_is_on = True
|
||||
self.async_write_ha_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user