diff --git a/CODEOWNERS b/CODEOWNERS index 0c3f73db76d..9e3c1e8e0b8 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -131,8 +131,8 @@ build.json @home-assistant/supervisor /homeassistant/components/binary_sensor/ @home-assistant/core /tests/components/binary_sensor/ @home-assistant/core /homeassistant/components/bizkaibus/ @UgaitzEtxebarria -/homeassistant/components/blebox/ @bbx-a @bbx-jp @riokuu -/tests/components/blebox/ @bbx-a @bbx-jp @riokuu +/homeassistant/components/blebox/ @bbx-a @riokuu +/tests/components/blebox/ @bbx-a @riokuu /homeassistant/components/blink/ @fronzbot /tests/components/blink/ @fronzbot /homeassistant/components/blueprint/ @home-assistant/core diff --git a/homeassistant/components/blebox/const.py b/homeassistant/components/blebox/const.py index f0c6a2d7586..013a6501068 100644 --- a/homeassistant/components/blebox/const.py +++ b/homeassistant/components/blebox/const.py @@ -3,13 +3,7 @@ from homeassistant.components.cover import CoverDeviceClass from homeassistant.components.sensor import SensorDeviceClass from homeassistant.components.switch import SwitchDeviceClass -from homeassistant.const import ( - STATE_CLOSED, - STATE_CLOSING, - STATE_OPEN, - STATE_OPENING, - TEMP_CELSIUS, -) +from homeassistant.const import TEMP_CELSIUS DOMAIN = "blebox" PRODUCT = "product" @@ -30,19 +24,6 @@ BLEBOX_TO_HASS_DEVICE_CLASSES = { "temperature": SensorDeviceClass.TEMPERATURE, } -BLEBOX_TO_HASS_COVER_STATES = { - None: None, - 0: STATE_CLOSING, # moving down - 1: STATE_OPENING, # moving up - 2: STATE_OPEN, # manually stopped - 3: STATE_CLOSED, # lower limit - 4: STATE_OPEN, # upper limit / open - # gateController - 5: STATE_OPEN, # overload - 6: STATE_OPEN, # motor failure - # 7 is not used - 8: STATE_OPEN, # safety stop -} BLEBOX_TO_UNIT_MAP = {"celsius": TEMP_CELSIUS} diff --git a/homeassistant/components/blebox/cover.py b/homeassistant/components/blebox/cover.py index 368443988a4..8763ec34d34 100644 --- a/homeassistant/components/blebox/cover.py +++ b/homeassistant/components/blebox/cover.py @@ -9,12 +9,26 @@ from homeassistant.components.cover import ( CoverEntityFeature, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPENING +from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import BleBoxEntity, create_blebox_entities -from .const import BLEBOX_TO_HASS_COVER_STATES, BLEBOX_TO_HASS_DEVICE_CLASSES +from .const import BLEBOX_TO_HASS_DEVICE_CLASSES + +BLEBOX_TO_HASS_COVER_STATES = { + None: None, + 0: STATE_CLOSING, # moving down + 1: STATE_OPENING, # moving up + 2: STATE_OPEN, # manually stopped + 3: STATE_CLOSED, # lower limit + 4: STATE_OPEN, # upper limit / open + # gateController + 5: STATE_OPEN, # overload + 6: STATE_OPEN, # motor failure + # 7 is not used + 8: STATE_OPEN, # safety stop +} async def async_setup_entry( diff --git a/homeassistant/components/blebox/light.py b/homeassistant/components/blebox/light.py index 32cc6360db1..2bb6bc91762 100644 --- a/homeassistant/components/blebox/light.py +++ b/homeassistant/components/blebox/light.py @@ -4,7 +4,6 @@ from __future__ import annotations from datetime import timedelta import logging -from blebox_uniapi.error import BadOnValueError import blebox_uniapi.light from blebox_uniapi.light import BleboxColorMode @@ -166,10 +165,10 @@ class BleBoxLightEntity(BleBoxEntity, LightEntity): else: try: await self._feature.async_on(value) - except BadOnValueError as ex: - _LOGGER.error( - "Turning on '%s' failed: Bad value %s (%s)", self.name, value, ex - ) + except ValueError as exc: + raise ValueError( + f"Turning on '{self.name}' failed: Bad value {value}" + ) from exc async def async_turn_off(self, **kwargs): """Turn the light off.""" diff --git a/homeassistant/components/blebox/manifest.json b/homeassistant/components/blebox/manifest.json index 5c57d5f6b9f..08554695316 100644 --- a/homeassistant/components/blebox/manifest.json +++ b/homeassistant/components/blebox/manifest.json @@ -3,8 +3,8 @@ "name": "BleBox devices", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/blebox", - "requirements": ["blebox_uniapi==2.0.0"], - "codeowners": ["@bbx-a", "@bbx-jp", "@riokuu"], + "requirements": ["blebox_uniapi==2.0.1"], + "codeowners": ["@bbx-a", "@riokuu"], "iot_class": "local_polling", "loggers": ["blebox_uniapi"] } diff --git a/requirements_all.txt b/requirements_all.txt index d71232f1fd5..9468e937b57 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -402,7 +402,7 @@ bimmer_connected==0.9.6 bizkaibus==0.1.1 # homeassistant.components.blebox -blebox_uniapi==2.0.0 +blebox_uniapi==2.0.1 # homeassistant.components.blink blinkpy==0.19.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index c2a194ca559..c168bb44ce5 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -317,7 +317,7 @@ bellows==0.31.0 bimmer_connected==0.9.6 # homeassistant.components.blebox -blebox_uniapi==2.0.0 +blebox_uniapi==2.0.1 # homeassistant.components.blink blinkpy==0.19.0 diff --git a/tests/components/blebox/test_light.py b/tests/components/blebox/test_light.py index 4663c216136..f61496714fb 100644 --- a/tests/components/blebox/test_light.py +++ b/tests/components/blebox/test_light.py @@ -509,17 +509,18 @@ async def test_turn_on_failure(feature, hass, config, caplog): caplog.set_level(logging.ERROR) feature_mock, entity_id = feature - feature_mock.async_on = AsyncMock(side_effect=blebox_uniapi.error.BadOnValueError) + feature_mock.async_on = AsyncMock(side_effect=ValueError) await async_setup_entity(hass, config, entity_id) feature_mock.sensible_on_value = 123 - await hass.services.async_call( - "light", - SERVICE_TURN_ON, - {"entity_id": entity_id}, - blocking=True, - ) + with pytest.raises(ValueError) as info: + await hass.services.async_call( + "light", + SERVICE_TURN_ON, + {"entity_id": entity_id}, + blocking=True, + ) - assert ( - f"Turning on '{feature_mock.full_name}' failed: Bad value 123 ()" in caplog.text + assert f"Turning on '{feature_mock.full_name}' failed: Bad value 123" in str( + info.value )