diff --git a/homeassistant/components/tasmota/light.py b/homeassistant/components/tasmota/light.py index 7da8674d270..970d006e79d 100644 --- a/homeassistant/components/tasmota/light.py +++ b/homeassistant/components/tasmota/light.py @@ -22,10 +22,9 @@ from homeassistant.components.light import ( ATTR_HS_COLOR, ATTR_TRANSITION, ATTR_WHITE, - SUPPORT_EFFECT, - SUPPORT_TRANSITION, ColorMode, LightEntity, + LightEntityFeature, brightness_supported, ) from homeassistant.config_entries import ConfigEntry @@ -95,7 +94,6 @@ class TasmotaLight( def __init__(self, **kwds: Any) -> None: """Initialize Tasmota light.""" self._supported_color_modes: set[str] | None = None - self._supported_features = 0 self._brightness: int | None = None self._color_mode: str | None = None @@ -147,12 +145,12 @@ class TasmotaLight( self._color_mode = ColorMode.ONOFF if light_type in [LIGHT_TYPE_RGB, LIGHT_TYPE_RGBW, LIGHT_TYPE_RGBCW]: - supported_features |= SUPPORT_EFFECT + supported_features |= LightEntityFeature.EFFECT if self._tasmota_entity.supports_transition: - supported_features |= SUPPORT_TRANSITION + supported_features |= LightEntityFeature.TRANSITION - self._supported_features = supported_features + self._attr_supported_features = supported_features @callback def state_updated(self, state: bool, **kwargs: Any) -> None: @@ -241,11 +239,6 @@ class TasmotaLight( """Flag supported color modes.""" return self._supported_color_modes - @property - def supported_features(self) -> int: - """Flag supported features.""" - return self._supported_features - async def async_turn_on(self, **kwargs: Any) -> None: """Turn the entity on.""" supported_color_modes = self._supported_color_modes or set() diff --git a/tests/components/tasmota/test_light.py b/tests/components/tasmota/test_light.py index bdad1f8ceef..1c51975b1f8 100644 --- a/tests/components/tasmota/test_light.py +++ b/tests/components/tasmota/test_light.py @@ -10,7 +10,7 @@ from hatasmota.utils import ( get_topic_tele_will, ) -from homeassistant.components.light import SUPPORT_EFFECT, SUPPORT_TRANSITION +from homeassistant.components.light import LightEntityFeature from homeassistant.components.tasmota.const import DEFAULT_PREFIX from homeassistant.const import ATTR_ASSUMED_STATE, STATE_OFF, STATE_ON, Platform @@ -105,7 +105,7 @@ async def test_attributes_dimmer(hass, mqtt_mock, setup_tasmota): assert state.attributes.get("effect_list") is None assert state.attributes.get("min_mireds") is None assert state.attributes.get("max_mireds") is None - assert state.attributes.get("supported_features") == SUPPORT_TRANSITION + assert state.attributes.get("supported_features") == LightEntityFeature.TRANSITION assert state.attributes.get("supported_color_modes") == ["brightness"] assert state.attributes.get("color_mode") == "brightness" @@ -131,7 +131,7 @@ async def test_attributes_ct(hass, mqtt_mock, setup_tasmota): assert state.attributes.get("effect_list") is None assert state.attributes.get("min_mireds") == 153 assert state.attributes.get("max_mireds") == 500 - assert state.attributes.get("supported_features") == SUPPORT_TRANSITION + assert state.attributes.get("supported_features") == LightEntityFeature.TRANSITION assert state.attributes.get("supported_color_modes") == ["color_temp"] assert state.attributes.get("color_mode") == "color_temp" @@ -158,7 +158,7 @@ async def test_attributes_ct_reduced(hass, mqtt_mock, setup_tasmota): assert state.attributes.get("effect_list") is None assert state.attributes.get("min_mireds") == 200 assert state.attributes.get("max_mireds") == 380 - assert state.attributes.get("supported_features") == SUPPORT_TRANSITION + assert state.attributes.get("supported_features") == LightEntityFeature.TRANSITION assert state.attributes.get("supported_color_modes") == ["color_temp"] assert state.attributes.get("color_mode") == "color_temp" @@ -192,7 +192,7 @@ async def test_attributes_rgb(hass, mqtt_mock, setup_tasmota): assert state.attributes.get("max_mireds") is None assert ( state.attributes.get("supported_features") - == SUPPORT_EFFECT | SUPPORT_TRANSITION + == LightEntityFeature.EFFECT | LightEntityFeature.TRANSITION ) assert state.attributes.get("supported_color_modes") == ["hs"] assert state.attributes.get("color_mode") == "hs" @@ -227,7 +227,7 @@ async def test_attributes_rgbw(hass, mqtt_mock, setup_tasmota): assert state.attributes.get("max_mireds") is None assert ( state.attributes.get("supported_features") - == SUPPORT_EFFECT | SUPPORT_TRANSITION + == LightEntityFeature.EFFECT | LightEntityFeature.TRANSITION ) assert state.attributes.get("supported_color_modes") == ["hs", "white"] assert state.attributes.get("color_mode") == "hs" @@ -262,7 +262,7 @@ async def test_attributes_rgbww(hass, mqtt_mock, setup_tasmota): assert state.attributes.get("max_mireds") == 500 assert ( state.attributes.get("supported_features") - == SUPPORT_EFFECT | SUPPORT_TRANSITION + == LightEntityFeature.EFFECT | LightEntityFeature.TRANSITION ) assert state.attributes.get("supported_color_modes") == ["color_temp", "hs"] assert state.attributes.get("color_mode") == "color_temp" @@ -298,7 +298,7 @@ async def test_attributes_rgbww_reduced(hass, mqtt_mock, setup_tasmota): assert state.attributes.get("max_mireds") == 380 assert ( state.attributes.get("supported_features") - == SUPPORT_EFFECT | SUPPORT_TRANSITION + == LightEntityFeature.EFFECT | LightEntityFeature.TRANSITION ) assert state.attributes.get("supported_color_modes") == ["color_temp", "hs"] assert state.attributes.get("color_mode") == "color_temp" @@ -1597,7 +1597,7 @@ async def test_discovery_update_reconfigure_light( async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{config[CONF_MAC]}/config", data1) await hass.async_block_till_done() state = hass.states.get("light.test") - assert state.attributes.get("supported_features") == SUPPORT_TRANSITION + assert state.attributes.get("supported_features") == LightEntityFeature.TRANSITION assert state.attributes.get("supported_color_modes") == ["brightness"] # Reconfigure as RGB light @@ -1606,7 +1606,7 @@ async def test_discovery_update_reconfigure_light( state = hass.states.get("light.test") assert ( state.attributes.get("supported_features") - == SUPPORT_EFFECT | SUPPORT_TRANSITION + == LightEntityFeature.EFFECT | LightEntityFeature.TRANSITION ) assert state.attributes.get("supported_color_modes") == ["hs"]