Skip to content

Commit

Permalink
Fix brightness type (home-assistant#25818)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsayre authored and balloob committed Aug 9, 2019
1 parent 5b516fc commit 6909235
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion homeassistant/components/smartthings/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ async def async_update(self):
"""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(
Expand Down
6 changes: 4 additions & 2 deletions tests/components/smartthings/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 6909235

Please sign in to comment.