Skip to content

Commit e57ecc9

Browse files
andrewsayreballoob
authored andcommitted
Fix brightness type (#25818)
1 parent e1fee1b commit e57ecc9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

homeassistant/components/smartthings/light.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ async def async_update(self):
133133
"""Update entity attributes when the device status has changed."""
134134
# Brightness and transition
135135
if self._supported_features & SUPPORT_BRIGHTNESS:
136-
self._brightness = convert_scale(self._device.status.level, 100, 255)
136+
self._brightness = int(
137+
convert_scale(self._device.status.level, 100, 255, 0)
138+
)
137139
# Color Temperature
138140
if self._supported_features & SUPPORT_COLOR_TEMP:
139141
self._color_temp = color_util.color_temperature_kelvin_to_mired(

tests/components/smartthings/test_light.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ async def test_entity_state(hass, light_devices):
8484
state.attributes[ATTR_SUPPORTED_FEATURES]
8585
== SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
8686
)
87+
assert isinstance(state.attributes[ATTR_BRIGHTNESS], int)
8788
assert state.attributes[ATTR_BRIGHTNESS] == 255
8889

8990
# Color Dimmer 1
@@ -103,6 +104,7 @@ async def test_entity_state(hass, light_devices):
103104
)
104105
assert state.attributes[ATTR_BRIGHTNESS] == 255
105106
assert state.attributes[ATTR_HS_COLOR] == (273.6, 55.0)
107+
assert isinstance(state.attributes[ATTR_COLOR_TEMP], int)
106108
assert state.attributes[ATTR_COLOR_TEMP] == 222
107109

108110

@@ -191,7 +193,7 @@ async def test_turn_on_with_brightness(hass, light_devices):
191193
assert state is not None
192194
assert state.state == "on"
193195
# round-trip rounding error (expected)
194-
assert state.attributes[ATTR_BRIGHTNESS] == 73.95
196+
assert state.attributes[ATTR_BRIGHTNESS] == 74
195197

196198

197199
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):
216218
assert state is not None
217219
assert state.state == "on"
218220
# round-trip rounding error (expected)
219-
assert state.attributes[ATTR_BRIGHTNESS] == 2.55
221+
assert state.attributes[ATTR_BRIGHTNESS] == 3
220222

221223

222224
async def test_turn_on_with_color(hass, light_devices):

0 commit comments

Comments
 (0)