mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Replace OpenUV logged errors with HomeAssistantError
in service handlers (#62349)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
dbb4c1b5f0
commit
fed18fe142
@ -18,7 +18,7 @@ from homeassistant.const import (
|
|||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
from homeassistant.helpers.dispatcher import (
|
from homeassistant.helpers.dispatcher import (
|
||||||
async_dispatcher_connect,
|
async_dispatcher_connect,
|
||||||
@ -147,7 +147,7 @@ class OpenUV:
|
|||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self._entry = entry
|
self._entry = entry
|
||||||
self.client = client
|
self.client = client
|
||||||
self.data: dict[str, Any] = {}
|
self.data: dict[str, Any] = {DATA_PROTECTION_WINDOW: {}, DATA_UV: {}}
|
||||||
|
|
||||||
async def async_update_protection_data(self) -> None:
|
async def async_update_protection_data(self) -> None:
|
||||||
"""Update binary sensor (protection window) data."""
|
"""Update binary sensor (protection window) data."""
|
||||||
@ -155,20 +155,24 @@ class OpenUV:
|
|||||||
high = self._entry.options.get(CONF_TO_WINDOW, DEFAULT_TO_WINDOW)
|
high = self._entry.options.get(CONF_TO_WINDOW, DEFAULT_TO_WINDOW)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = await self.client.uv_protection_window(low=low, high=high)
|
data = await self.client.uv_protection_window(low=low, high=high)
|
||||||
self.data[DATA_PROTECTION_WINDOW] = resp["result"]
|
|
||||||
except OpenUvError as err:
|
except OpenUvError as err:
|
||||||
LOGGER.error("Error during protection data update: %s", err)
|
raise HomeAssistantError(
|
||||||
self.data[DATA_PROTECTION_WINDOW] = {}
|
f"Error during protection data update: {err}"
|
||||||
|
) from err
|
||||||
|
|
||||||
|
self.data[DATA_PROTECTION_WINDOW] = data["result"]
|
||||||
|
|
||||||
async def async_update_uv_index_data(self) -> None:
|
async def async_update_uv_index_data(self) -> None:
|
||||||
"""Update sensor (uv index, etc) data."""
|
"""Update sensor (uv index, etc) data."""
|
||||||
try:
|
try:
|
||||||
data = await self.client.uv_index()
|
data = await self.client.uv_index()
|
||||||
self.data[DATA_UV] = data
|
|
||||||
except OpenUvError as err:
|
except OpenUvError as err:
|
||||||
LOGGER.error("Error during uv index data update: %s", err)
|
raise HomeAssistantError(
|
||||||
self.data[DATA_UV] = {}
|
f"Error during UV index data update: {err}"
|
||||||
|
) from err
|
||||||
|
|
||||||
|
self.data[DATA_UV] = data
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update sensor/binary sensor data."""
|
"""Update sensor/binary sensor data."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user