diff --git a/homeassistant/components/hue/bridge.py b/homeassistant/components/hue/bridge.py index dd6182b244a..e15da5c8489 100644 --- a/homeassistant/components/hue/bridge.py +++ b/homeassistant/components/hue/bridge.py @@ -117,22 +117,19 @@ class HueBridge: self.authorized = True return True - async def async_request_call( - self, task: Callable, *args, allowed_errors: list[str] | None = None, **kwargs - ) -> Any: - """Send request to the Hue bridge, optionally omitting error(s).""" + async def async_request_call(self, task: Callable, *args, **kwargs) -> Any: + """Send request to the Hue bridge.""" try: return await task(*args, **kwargs) except AiohueException as err: - # The (new) Hue api can be a bit fanatic with throwing errors - # some of which we accept in certain conditions - # handle that here. Note that these errors are strings and do not have - # an identifier or something. - if allowed_errors is not None and str(err) in allowed_errors: + # The (new) Hue api can be a bit fanatic with throwing errors so + # we have some logic to treat some responses as warning only. + msg = f"Request failed: {err}" + if "may not have effect" in str(err): # log only - self.logger.debug("Ignored error/warning from Hue API: %s", str(err)) + self.logger.debug(msg) return None - raise HomeAssistantError(f"Request failed: {err}") from err + raise HomeAssistantError(msg) from err except aiohttp.ClientError as err: raise HomeAssistantError( f"Request failed due connection error: {err}" diff --git a/homeassistant/components/hue/v2/group.py b/homeassistant/components/hue/v2/group.py index 948609f4c13..162ef58d320 100644 --- a/homeassistant/components/hue/v2/group.py +++ b/homeassistant/components/hue/v2/group.py @@ -37,21 +37,6 @@ from .helpers import ( normalize_hue_transition, ) -ALLOWED_ERRORS = [ - "device (groupedLight) has communication issues, command (on) may not have effect", - 'device (groupedLight) is "soft off", command (on) may not have effect', - "device (light) has communication issues, command (on) may not have effect", - 'device (light) is "soft off", command (on) may not have effect', - "device (grouped_light) has communication issues, command (.on) may not have effect", - 'device (grouped_light) is "soft off", command (.on) may not have effect' - "device (grouped_light) has communication issues, command (.on.on) may not have effect", - 'device (grouped_light) is "soft off", command (.on.on) may not have effect' - "device (light) has communication issues, command (.on) may not have effect", - 'device (light) is "soft off", command (.on) may not have effect', - "device (light) has communication issues, command (.on.on) may not have effect", - 'device (light) is "soft off", command (.on.on) may not have effect', -] - async def async_setup_entry( hass: HomeAssistant, @@ -183,10 +168,7 @@ class GroupedHueLight(HueBaseEntity, LightEntity): and flash is None ): await self.bridge.async_request_call( - self.controller.set_state, - id=self.resource.id, - on=True, - allowed_errors=ALLOWED_ERRORS, + self.controller.set_state, id=self.resource.id, on=True ) return @@ -202,7 +184,6 @@ class GroupedHueLight(HueBaseEntity, LightEntity): color_xy=xy_color if light.supports_color else None, color_temp=color_temp if light.supports_color_temperature else None, transition_time=transition, - allowed_errors=ALLOWED_ERRORS, ) for light in self.controller.get_lights(self.resource.id) ] @@ -222,10 +203,7 @@ class GroupedHueLight(HueBaseEntity, LightEntity): # To set other features, you'll have to control the attached lights if transition is None: await self.bridge.async_request_call( - self.controller.set_state, - id=self.resource.id, - on=False, - allowed_errors=ALLOWED_ERRORS, + self.controller.set_state, id=self.resource.id, on=False ) return @@ -237,7 +215,6 @@ class GroupedHueLight(HueBaseEntity, LightEntity): light.id, on=False, transition_time=transition, - allowed_errors=ALLOWED_ERRORS, ) for light in self.controller.get_lights(self.resource.id) ] diff --git a/homeassistant/components/hue/v2/light.py b/homeassistant/components/hue/v2/light.py index ff20e7f5881..28d972b54ec 100644 --- a/homeassistant/components/hue/v2/light.py +++ b/homeassistant/components/hue/v2/light.py @@ -36,15 +36,6 @@ from .helpers import ( normalize_hue_transition, ) -ALLOWED_ERRORS = [ - "device (light) has communication issues, command (on) may not have effect", - 'device (light) is "soft off", command (on) may not have effect', - "device (light) has communication issues, command (.on) may not have effect", - 'device (light) is "soft off", command (.on) may not have effect', - "device (light) has communication issues, command (.on.on) may not have effect", - 'device (light) is "soft off", command (.on.on) may not have effect', -] - async def async_setup_entry( hass: HomeAssistant, @@ -188,7 +179,6 @@ class HueLight(HueBaseEntity, LightEntity): color_xy=xy_color, color_temp=color_temp, transition_time=transition, - allowed_errors=ALLOWED_ERRORS, ) async def async_turn_off(self, **kwargs: Any) -> None: @@ -208,7 +198,6 @@ class HueLight(HueBaseEntity, LightEntity): id=self.resource.id, on=False, transition_time=transition, - allowed_errors=ALLOWED_ERRORS, ) async def async_set_flash(self, flash: str) -> None: diff --git a/tests/components/hue/conftest.py b/tests/components/hue/conftest.py index d0d15d320e0..d730d3f18f5 100644 --- a/tests/components/hue/conftest.py +++ b/tests/components/hue/conftest.py @@ -60,7 +60,7 @@ def create_mock_bridge(hass, api_version=1): bridge.async_initialize_bridge = async_initialize_bridge - async def async_request_call(task, *args, allowed_errors=None, **kwargs): + async def async_request_call(task, *args, **kwargs): await task(*args, **kwargs) bridge.async_request_call = async_request_call