Fix brightness type (#25818)

pull/25849/head
Andrew Sayre 2019-08-09 13:41:50 -05:00 committed by Paulus Schoutsen
parent 5b516fc0cd
commit 6909235d8a
2 changed files with 7 additions and 3 deletions

View File

@ -133,7 +133,9 @@ class SmartThingsLight(SmartThingsEntity, Light):
"""Update entity attributes when the device status has changed."""
# Brightness and transition
if self._supported_features & SUPPORT_BRIGHTNESS:
self._brightness = convert_scale(self._device.status.level, 100, 255)
self._brightness = int(
convert_scale(self._device.status.level, 100, 255, 0)
)
# Color Temperature
if self._supported_features & SUPPORT_COLOR_TEMP:
self._color_temp = color_util.color_temperature_kelvin_to_mired(

View File

@ -84,6 +84,7 @@ async def test_entity_state(hass, light_devices):
state.attributes[ATTR_SUPPORTED_FEATURES]
== SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
)
assert isinstance(state.attributes[ATTR_BRIGHTNESS], int)
assert state.attributes[ATTR_BRIGHTNESS] == 255
# Color Dimmer 1
@ -103,6 +104,7 @@ async def test_entity_state(hass, light_devices):
)
assert state.attributes[ATTR_BRIGHTNESS] == 255
assert state.attributes[ATTR_HS_COLOR] == (273.6, 55.0)
assert isinstance(state.attributes[ATTR_COLOR_TEMP], int)
assert state.attributes[ATTR_COLOR_TEMP] == 222
@ -191,7 +193,7 @@ async def test_turn_on_with_brightness(hass, light_devices):
assert state is not None
assert state.state == "on"
# round-trip rounding error (expected)
assert state.attributes[ATTR_BRIGHTNESS] == 73.95
assert state.attributes[ATTR_BRIGHTNESS] == 74
async def test_turn_on_with_minimal_brightness(hass, light_devices):
@ -216,7 +218,7 @@ async def test_turn_on_with_minimal_brightness(hass, light_devices):
assert state is not None
assert state.state == "on"
# round-trip rounding error (expected)
assert state.attributes[ATTR_BRIGHTNESS] == 2.55
assert state.attributes[ATTR_BRIGHTNESS] == 3
async def test_turn_on_with_color(hass, light_devices):