From 466ae9a1d837e1ed317f84e1846ff566b165f0e7 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Mon, 6 Feb 2023 20:45:58 +0100 Subject: [PATCH] Fix tests --- miio/device.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/miio/device.py b/miio/device.py index 27b24653a..94e926547 100644 --- a/miio/device.py +++ b/miio/device.py @@ -191,13 +191,13 @@ 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: @@ -205,6 +205,10 @@ def _setting_descriptors_from_status( 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