Skip to content

Commit

Permalink
Remove unsupported settings first after initialization is done (#1736)
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Feb 16, 2023
1 parent 2a33f41 commit 53a1c52
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion miio/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def _setting_descriptors_from_status(
) -> Dict[str, SettingDescriptor]:
"""Get the setting descriptors from a DeviceStatus."""
settings = status.settings()
unsupported_settings = []
for key, setting in settings.items():
if setting.setter_name is not None:
setting.setter = getattr(self, setting.setter_name)
Expand All @@ -200,7 +201,7 @@ def _setting_descriptors_from_status(
try:
setting.choices = retrieve_choices_function()
except UnsupportedFeatureException:
settings.pop(key)
unsupported_settings.append(key)
continue

elif setting.setting_type == SettingType.Number:
Expand All @@ -219,6 +220,9 @@ def _setting_descriptors_from_status(
"Unknown setting type: %s" % setting.setting_type
)

for unsupp_key in unsupported_settings:
settings.pop(unsupp_key)

return settings

def _sensor_descriptors_from_status(
Expand Down

0 comments on commit 53a1c52

Please sign in to comment.