Use getter names instead of setters

This commit is contained in:
Steven B
2024-11-25 13:36:00 +00:00
parent abc8ea6f4c
commit da83bcc589
2 changed files with 9 additions and 11 deletions

View File

@@ -96,12 +96,10 @@ class LightPreset(SmartModule, LightPresetInterface):
"""Return current preset name."""
light = self._device.modules[SmartModule.Light]
brightness = light.brightness
color_temp = (
light.color_temp if light.has_feature(light.set_color_temp) else None
)
color_temp = light.color_temp if light.has_feature("color_temp") else None
h, s = (
(light.hsv.hue, light.hsv.saturation)
if light.has_feature(light.set_hsv)
if light.has_feature("hsv")
else (None, None)
)
for preset_name, preset in self._presets.items():
@@ -109,7 +107,7 @@ class LightPreset(SmartModule, LightPresetInterface):
preset.brightness == brightness
and (
preset.color_temp == color_temp
or not light.has_feature(light.set_color_temp)
or not light.has_feature("color_temp")
)
and preset.hue == h
and preset.saturation == s
@@ -124,7 +122,7 @@ class LightPreset(SmartModule, LightPresetInterface):
"""Set a light preset for the device."""
light = self._device.modules[SmartModule.Light]
if preset_name == self.PRESET_NOT_SET:
if light.has_feature(light.set_hsv):
if light.has_feature("hsv"):
preset = LightState(hue=0, saturation=0, brightness=100)
else:
preset = LightState(brightness=100)