Fix round typing [shelly] (#82436)

This commit is contained in:
Marc Mueller 2022-11-20 22:45:34 +01:00 committed by GitHub
parent 574f6f3fd1
commit e897c8c47c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,16 +184,17 @@ class BlockShellyLight(ShellyBlockEntity, LightEntity):
@property @property
def brightness(self) -> int: def brightness(self) -> int:
"""Return the brightness of this light between 0..255.""" """Return the brightness of this light between 0..255."""
brightness_pct: int
if self.mode == "color": if self.mode == "color":
if self.control_result: if self.control_result:
brightness_pct = self.control_result["gain"] brightness_pct = self.control_result["gain"]
else: else:
brightness_pct = self.block.gain brightness_pct = cast(int, self.block.gain)
else: else:
if self.control_result: if self.control_result:
brightness_pct = self.control_result["brightness"] brightness_pct = self.control_result["brightness"]
else: else:
brightness_pct = self.block.brightness brightness_pct = cast(int, self.block.brightness)
return round(255 * brightness_pct / 100) return round(255 * brightness_pct / 100)