Skip to content

Commit

Permalink
Quick fix for break in parsing modes
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffSteinbok committed Aug 27, 2024
1 parent 736aca5 commit 7804f66
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/dreo/pydreo/pydreofan.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ def parse_speed_range(self, details: Dict[str, list]) -> tuple[int, int]:

def parse_preset_modes(self, details: Dict[str, list]) -> tuple[str, int]:
"""Parse the preset modes from the details."""
preset_modes = []
controls_conf = details.get("controlsConf", None)
if controls_conf is not None:
control = controls_conf.get("control", None)
if (control is not None):
for control_item in control:
if (control_item is not None):
if control_item.get("type", None) == "Mode":
preset_modes = []
for mode_item in control_item.get("items", None):
text = mode_item.get("image", None).split("_")[1]
value = mode_item.get("value", None)
Expand All @@ -118,7 +118,10 @@ def parse_preset_modes(self, details: Dict[str, list]) -> tuple[str, int]:
if (text, value) not in preset_modes:
preset_modes.append((text, value))

preset_modes.sort(key=lambda tup: tup[1]) # sorts in place
preset_modes.sort(key=lambda tup: tup[1]) # sorts in place
if (preset_modes.count is 0):
_LOGGER.debug("PyDreoFan:No preset modes detected")
preset_modes = None
_LOGGER.debug("PyDreoFan:Detected preset modes - %s", preset_modes)
return preset_modes

Expand Down

0 comments on commit 7804f66

Please sign in to comment.