mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Handle brightness being None for senseme (#65372)
This commit is contained in:
parent
37f9c833c0
commit
95d4be375c
@ -51,7 +51,8 @@ class HASensemeLight(SensemeEntity, LightEntity):
|
|||||||
def _async_update_attrs(self) -> None:
|
def _async_update_attrs(self) -> None:
|
||||||
"""Update attrs from device."""
|
"""Update attrs from device."""
|
||||||
self._attr_is_on = self._device.light_on
|
self._attr_is_on = self._device.light_on
|
||||||
self._attr_brightness = int(min(255, self._device.light_brightness * 16))
|
if self._device.light_brightness is not None:
|
||||||
|
self._attr_brightness = int(min(255, self._device.light_brightness * 16))
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn on the light."""
|
"""Turn on the light."""
|
||||||
|
@ -74,6 +74,21 @@ async def test_fan_light(hass: HomeAssistant) -> None:
|
|||||||
assert device.light_on is True
|
assert device.light_on is True
|
||||||
|
|
||||||
|
|
||||||
|
async def test_fan_light_no_brightness(hass: HomeAssistant) -> None:
|
||||||
|
"""Test a fan light without brightness."""
|
||||||
|
device = _mock_device()
|
||||||
|
device.brightness = None
|
||||||
|
await _setup_mocked_entry(hass, device)
|
||||||
|
entity_id = "light.haiku_fan"
|
||||||
|
|
||||||
|
state = hass.states.get(entity_id)
|
||||||
|
assert state.state == STATE_ON
|
||||||
|
attributes = state.attributes
|
||||||
|
assert attributes[ATTR_BRIGHTNESS] == 255
|
||||||
|
assert attributes[ATTR_COLOR_MODE] == COLOR_MODE_BRIGHTNESS
|
||||||
|
assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS]
|
||||||
|
|
||||||
|
|
||||||
async def test_standalone_light(hass: HomeAssistant) -> None:
|
async def test_standalone_light(hass: HomeAssistant) -> None:
|
||||||
"""Test a standalone light."""
|
"""Test a standalone light."""
|
||||||
device = _mock_device()
|
device = _mock_device()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user