Use assignment expressions 38 (#58828)
This commit is contained in:
parent
b6d9e517c2
commit
72801867d6
15 changed files with 26 additions and 54 deletions
|
@ -465,8 +465,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
|
|||
@property
|
||||
def color_temp(self) -> int:
|
||||
"""Return the color temperature."""
|
||||
temp_in_k = self._get_property("ct")
|
||||
if temp_in_k:
|
||||
if temp_in_k := self._get_property("ct"):
|
||||
self._color_temp = kelvin_to_mired(int(temp_in_k))
|
||||
return self._color_temp
|
||||
|
||||
|
@ -530,9 +529,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
|
|||
@property
|
||||
def rgb_color(self) -> tuple:
|
||||
"""Return the color property."""
|
||||
rgb = self._get_property("rgb")
|
||||
|
||||
if rgb is None:
|
||||
if (rgb := self._get_property("rgb")) is None:
|
||||
return None
|
||||
|
||||
rgb = int(rgb)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue