Improve type hints in vesync lights (#75998)

* Improve type hints in vesync lights

* Adjust import
This commit is contained in:
epenet 2022-08-03 09:56:13 +02:00 committed by GitHub
parent 98f0b24c42
commit 1ba18f8df6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 27 deletions

View file

@ -67,7 +67,7 @@ class VeSyncBaseLight(VeSyncDevice, LightEntity):
"""Base class for VeSync Light Devices Representations."""
@property
def brightness(self):
def brightness(self) -> int:
"""Get light brightness."""
# get value from pyvesync library api,
result = self.device.brightness
@ -141,10 +141,12 @@ class VeSyncTunableWhiteLightHA(VeSyncBaseLight, LightEntity):
"""Representation of a VeSync Tunable White Light device."""
_attr_color_mode = ColorMode.COLOR_TEMP
_attr_max_mireds = 370 # 1,000,000 divided by 2700 Kelvin = 370 Mireds
_attr_min_mireds = 154 # 1,000,000 divided by 6500 Kelvin = 154 Mireds
_attr_supported_color_modes = {ColorMode.COLOR_TEMP}
@property
def color_temp(self):
def color_temp(self) -> int:
"""Get device white temperature."""
# get value from pyvesync library api,
result = self.device.color_temp_pct
@ -169,13 +171,3 @@ class VeSyncTunableWhiteLightHA(VeSyncBaseLight, LightEntity):
)
# ensure value between minimum and maximum Mireds
return max(self.min_mireds, min(color_temp_value, self.max_mireds))
@property
def min_mireds(self):
"""Set device coldest white temperature."""
return 154 # 154 Mireds ( 1,000,000 divided by 6500 Kelvin = 154 Mireds)
@property
def max_mireds(self):
"""Set device warmest white temperature."""
return 370 # 370 Mireds ( 1,000,000 divided by 2700 Kelvin = 370 Mireds)