Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Feb 6, 2023
1 parent 24323b4 commit 466ae9a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions miio/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,24 @@ def _setting_descriptors_from_status(
raise Exception(
f"Neither setter or setter_name was defined for {setting}"
)
setting = cast(EnumSettingDescriptor, setting)
if (
setting.setting_type == SettingType.Enum
and setting.choices_attribute is not None
):
retrieve_choices_function = getattr(self, setting.choices_attribute)
setting.choices = retrieve_choices_function()

if setting.setting_type == SettingType.Enum:
setting = cast(EnumSettingDescriptor, setting)
if setting.choices_attribute is not None:
retrieve_choices_function = getattr(self, setting.choices_attribute)
setting.choices = retrieve_choices_function()

elif setting.setting_type == SettingType.Number:
setting = cast(NumberSettingDescriptor, setting)
if setting.range_attribute is not None:
range_def = getattr(self, setting.range_attribute)
setting.min_value = range_def.min_value
setting.max_value = range_def.max_value
setting.step = range_def.step

elif setting.setting_type == SettingType.Boolean:
pass # just to exhaust known types

else:
raise NotImplementedError(
"Unknown setting type: %s" % setting.setting_type
Expand Down

0 comments on commit 466ae9a

Please sign in to comment.