diff --git a/homeassistant/components/sensibo/select.py b/homeassistant/components/sensibo/select.py index 12e7364d6eecae..b542c51d22f72b 100644 --- a/homeassistant/components/sensibo/select.py +++ b/homeassistant/components/sensibo/select.py @@ -16,7 +16,6 @@ SelectEntityDescription, ) from homeassistant.core import HomeAssistant -from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.issue_registry import ( @@ -137,6 +136,13 @@ def __init__( self.entity_description = entity_description self._attr_unique_id = f"{device_id}-{entity_description.key}" + @property + def available(self) -> bool: + """Return True if entity is available.""" + if self.entity_description.key not in self.device_data.active_features: + return False + return super().available + @property def current_option(self) -> str | None: """Return the current selected option.""" @@ -152,17 +158,6 @@ def options(self) -> list[str]: async def async_select_option(self, option: str) -> None: """Set state to the selected option.""" - if self.entity_description.key not in self.device_data.active_features: - hvac_mode = self.device_data.hvac_mode if self.device_data.hvac_mode else "" - raise HomeAssistantError( - translation_domain=DOMAIN, - translation_key="select_option_not_available", - translation_placeholders={ - "hvac_mode": hvac_mode, - "key": self.entity_description.key, - }, - ) - await self.async_send_api_call( key=self.entity_description.data_key, value=option, diff --git a/homeassistant/components/sensibo/strings.json b/homeassistant/components/sensibo/strings.json index a1f60c247a3bf4..adebd268ccd1e7 100644 --- a/homeassistant/components/sensibo/strings.json +++ b/homeassistant/components/sensibo/strings.json @@ -575,9 +575,6 @@ "service_raised": { "message": "Could not perform action for {name} with error {error}" }, - "select_option_not_available": { - "message": "Current mode {hvac_mode} doesn't support setting {key}" - }, "climate_react_not_available": { "message": "Use Sensibo Enable Climate React action once to enable switch or the Sensibo app" }, diff --git a/tests/components/sensibo/test_select.py b/tests/components/sensibo/test_select.py index c93eff92f3a867..75dbdc88840f88 100644 --- a/tests/components/sensibo/test_select.py +++ b/tests/components/sensibo/test_select.py @@ -16,7 +16,7 @@ ) from homeassistant.components.sensibo.const import DOMAIN from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_ENTITY_ID, Platform +from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_registry as er, issue_registry as ir @@ -63,7 +63,7 @@ async def test_select_set_option( """Test the Sensibo select service.""" mock_client.async_get_devices_data.return_value.parsed[ - "ABC999111" + "AAZZAAZZ" ].active_features = [ "timestamp", "on", @@ -97,13 +97,11 @@ async def test_select_set_option( assert state.state == "on" mock_client.async_get_devices_data.return_value.parsed[ - "ABC999111" + "AAZZAAZZ" ].active_features = [ "timestamp", "on", "mode", - "targetTemperature", - "horizontalSwing", "light", ] @@ -142,6 +140,21 @@ async def test_select_set_option( state = hass.states.get("select.kitchen_light") assert state.state == "dim" + mock_client.async_get_devices_data.return_value.parsed[ + "AAZZAAZZ" + ].active_features = [ + "timestamp", + "on", + "mode", + ] + + freezer.tick(timedelta(minutes=5)) + async_fire_time_changed(hass) + await hass.async_block_till_done() + + state = hass.states.get("select.kitchen_light") + assert state.state == STATE_UNAVAILABLE + @pytest.mark.parametrize( "load_platforms",