mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-11-06 07:31:55 +00:00
Use getter names instead of setters
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user