Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "get_properties" instead of "get_prop" for miot devices #745

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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