Skip to content

Commit

Permalink
Use "get_properties" instead of "get_prop" for miot devices (#745)
Browse files Browse the repository at this point in the history
This regression was caused by clean-up done in #657

Fixes #730
  • Loading branch information
rytilahti authored Jul 2, 2020
1 parent 1bb5113 commit 02e574d
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 02e574d

Please sign in to comment.