Skip to content

Commit

Permalink
Merge 599b345 into 1bb5113
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Jul 2, 2020
2 parents 1bb5113 + 599b345 commit ab6b009
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions miio/device.py
Expand Up @@ -212,7 +212,9 @@ def configure_wifi(self, ssid, password, uid=0, extra_params=None):

return self.send("miIO.config_router", params)[0]

def get_properties(self, properties, *, max_properties=None):
def get_properties(
self, properties, *, property_getter="get_prop", max_properties=None
):
"""Request properties in slices based on given max_properties.
This is necessary as some devices have limitation on how many
Expand All @@ -227,7 +229,7 @@ def get_properties(self, properties, *, max_properties=None):
_props = properties.copy()
values = []
while _props:
values.extend(self.send("get_prop", _props[:max_properties]))
values.extend(self.send(property_getter, _props[:max_properties]))
if max_properties is None:
break

Expand Down
4 changes: 3 additions & 1 deletion miio/miot_device.py
Expand Up @@ -26,7 +26,9 @@ def get_properties_for_mapping(self) -> list:
# We send property key in "did" because it's sent back via response and we can identify the property.
properties = [{"did": k, **v} for k, v in self.mapping.items()]

return self.get_properties(properties, max_properties=15)
return self.get_properties(
properties, property_getter="get_properties", max_properties=15
)

def set_property(self, property_key: str, value):
"""Sets property value."""
Expand Down

0 comments on commit ab6b009

Please sign in to comment.