mirror of
https://github.com/home-assistant/core.git
synced 2026-10-07 06:50:41 -04:00
Fix Raise HomeAssistantError for all Liebherr errors in actions (#184163)
This commit is contained in:
@@ -5,8 +5,7 @@ from typing import Any
|
||||
|
||||
from pyliebherrhomeapi import (
|
||||
DeviceControl,
|
||||
LiebherrConnectionError,
|
||||
LiebherrTimeoutError,
|
||||
LiebherrError,
|
||||
TemperatureControl,
|
||||
ZonePosition,
|
||||
)
|
||||
@@ -61,7 +60,7 @@ class LiebherrEntity(CoordinatorEntity[LiebherrCoordinator]):
|
||||
"""Send a command and optimistically apply its successful result."""
|
||||
try:
|
||||
await command
|
||||
except (LiebherrConnectionError, LiebherrTimeoutError) as err:
|
||||
except LiebherrError as err:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="communication_error",
|
||||
|
||||
@@ -30,9 +30,7 @@ rules:
|
||||
unique-config-entry: done
|
||||
|
||||
# Silver
|
||||
action-exceptions:
|
||||
status: exempt
|
||||
comment: Integration does not register custom actions.
|
||||
action-exceptions: done
|
||||
config-entry-unloading: done
|
||||
docs-configuration-parameters:
|
||||
status: exempt
|
||||
|
||||
@@ -7,7 +7,7 @@ from unittest.mock import MagicMock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from pyliebherrhomeapi import Device, DeviceState, DeviceType, PresentationLightControl
|
||||
from pyliebherrhomeapi.exceptions import LiebherrConnectionError
|
||||
from pyliebherrhomeapi.exceptions import LiebherrServerError
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
@@ -122,10 +122,10 @@ async def test_light_failure(
|
||||
hass: HomeAssistant,
|
||||
mock_liebherr_client: MagicMock,
|
||||
) -> None:
|
||||
"""Test light fails gracefully on connection error."""
|
||||
"""Test light fails gracefully on a library error."""
|
||||
entity_id = "light.test_fridge_presentation_light"
|
||||
mock_liebherr_client.set_presentation_light.side_effect = LiebherrConnectionError(
|
||||
"Connection failed"
|
||||
mock_liebherr_client.set_presentation_light.side_effect = LiebherrServerError(
|
||||
"Server error"
|
||||
)
|
||||
|
||||
with pytest.raises(
|
||||
|
||||
Reference in New Issue
Block a user