Skip to content

Commit

Permalink
Fan: Divide properties into multiple requests (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Jun 4, 2018
1 parent a186eb1 commit 2e7dff0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions miio/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,14 @@ def __init__(self, ip: str = None, token: str = None, start_id: int = 0,
def status(self) -> FanStatus:
"""Retrieve properties."""
properties = AVAILABLE_PROPERTIES[self.model]
values = self.send(
"get_prop",
properties
)

# A single request is limited to 16 properties. Therefore the
# properties are divided into multiple requests
_props = properties.copy()
values = []
while _props:
values.extend(self.send("get_prop", _props[:15]))
_props[:] = _props[15:]

properties_count = len(properties)
values_count = len(values)
Expand Down

0 comments on commit 2e7dff0

Please sign in to comment.