Enable Ruff SIM401 (#86790)

* Enable Ruff SIM401

* Adjust found cases
This commit is contained in:
Franck Nijhof 2023-01-27 13:08:44 +01:00 committed by GitHub
parent bfbf9b9751
commit 8c993116e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 14 additions and 39 deletions

View file

@ -71,16 +71,14 @@ class BlinkStickLight(LightEntity):
"""Turn the device on."""
if ATTR_HS_COLOR in kwargs:
self._attr_hs_color = kwargs[ATTR_HS_COLOR]
if ATTR_BRIGHTNESS in kwargs:
self._attr_brightness = kwargs[ATTR_BRIGHTNESS]
else:
self._attr_brightness = 255
assert self.brightness is not None
self._attr_is_on = self.brightness > 0
brightness: int = kwargs.get(ATTR_BRIGHTNESS, 255)
self._attr_brightness = brightness
self._attr_is_on = bool(brightness)
assert self.hs_color
rgb_color = color_util.color_hsv_to_RGB(
self.hs_color[0], self.hs_color[1], self.brightness / 255 * 100
self.hs_color[0], self.hs_color[1], brightness / 255 * 100
)
self._stick.set_color(red=rgb_color[0], green=rgb_color[1], blue=rgb_color[2])