mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use LightEntityFeature enum in smartthings (#71057)
This commit is contained in:
parent
2fb16fd06c
commit
6bb685eaba
@ -14,8 +14,8 @@ from homeassistant.components.light import (
|
||||
SUPPORT_BRIGHTNESS,
|
||||
SUPPORT_COLOR,
|
||||
SUPPORT_COLOR_TEMP,
|
||||
SUPPORT_TRANSITION,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -86,7 +86,7 @@ class SmartThingsLight(SmartThingsEntity, LightEntity):
|
||||
features = 0
|
||||
# Brightness and transition
|
||||
if Capability.switch_level in self._device.capabilities:
|
||||
features |= SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
|
||||
features |= SUPPORT_BRIGHTNESS | LightEntityFeature.TRANSITION
|
||||
# Color Temperature
|
||||
if Capability.color_temperature in self._device.capabilities:
|
||||
features |= SUPPORT_COLOR_TEMP
|
||||
@ -124,7 +124,10 @@ class SmartThingsLight(SmartThingsEntity, LightEntity):
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
"""Turn the light off."""
|
||||
# Switch/transition
|
||||
if self._supported_features & SUPPORT_TRANSITION and ATTR_TRANSITION in kwargs:
|
||||
if (
|
||||
self._supported_features & LightEntityFeature.TRANSITION
|
||||
and ATTR_TRANSITION in kwargs
|
||||
):
|
||||
await self.async_set_level(0, int(kwargs[ATTR_TRANSITION]))
|
||||
else:
|
||||
await self._device.switch_off(set_status=True)
|
||||
|
@ -16,7 +16,7 @@ from homeassistant.components.light import (
|
||||
SUPPORT_BRIGHTNESS,
|
||||
SUPPORT_COLOR,
|
||||
SUPPORT_COLOR_TEMP,
|
||||
SUPPORT_TRANSITION,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.components.smartthings.const import DOMAIN, SIGNAL_SMARTTHINGS_UPDATE
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
@ -82,7 +82,7 @@ async def test_entity_state(hass, light_devices):
|
||||
assert state.state == "on"
|
||||
assert (
|
||||
state.attributes[ATTR_SUPPORTED_FEATURES]
|
||||
== SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
|
||||
== SUPPORT_BRIGHTNESS | LightEntityFeature.TRANSITION
|
||||
)
|
||||
assert isinstance(state.attributes[ATTR_BRIGHTNESS], int)
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 255
|
||||
@ -92,7 +92,7 @@ async def test_entity_state(hass, light_devices):
|
||||
assert state.state == "off"
|
||||
assert (
|
||||
state.attributes[ATTR_SUPPORTED_FEATURES]
|
||||
== SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | SUPPORT_COLOR
|
||||
== SUPPORT_BRIGHTNESS | LightEntityFeature.TRANSITION | SUPPORT_COLOR
|
||||
)
|
||||
|
||||
# Color Dimmer 2
|
||||
@ -100,7 +100,10 @@ async def test_entity_state(hass, light_devices):
|
||||
assert state.state == "on"
|
||||
assert (
|
||||
state.attributes[ATTR_SUPPORTED_FEATURES]
|
||||
== SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | SUPPORT_COLOR | SUPPORT_COLOR_TEMP
|
||||
== SUPPORT_BRIGHTNESS
|
||||
| LightEntityFeature.TRANSITION
|
||||
| SUPPORT_COLOR
|
||||
| SUPPORT_COLOR_TEMP
|
||||
)
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 255
|
||||
assert state.attributes[ATTR_HS_COLOR] == (273.6, 55.0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user