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

Reset consumable by name #115

Merged
merged 7 commits into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 3 additions & 3 deletions miio/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ def consumable_status(self) -> ConsumableStatus:
"""Return information about consumables."""
return ConsumableStatus(self.send("get_consumable")[0])

def consumable_reset(self):
def consumable_reset(self, name):
"""Reset consumable information."""
raise NotImplementedError("unknown parameters")
# self.send("reset_consumable", ["unknown"])
# name = ["main_brush_work_time", "side_brush_work_time", "sensor_dirty_time" or "filter_work_time"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (108 > 79 characters)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you create a Consumable enum, and use it instead of passing strings around. See https://github.com/rytilahti/python-miio/blob/master/miio/vacuum.py#L20 (and its use in https://github.com/rytilahti/python-miio/blob/master/miio/vacuum.py#L164) for example.

We do not need to follow their naming scheme either, I think it makes sense here to go for the same naming as in ConsumableStatus (https://github.com/rytilahti/python-miio/blob/master/miio/vacuumcontainers.py#L284).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (108 > 79 characters)

return self.send("reset_consumable", [name])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you happen to know if multiple consumables can be reseted at once?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I not tried this case on my robo.


def map(self):
"""Return map token."""
Expand Down
9 changes: 9 additions & 0 deletions miio/vacuum_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ def consumables(vac: miio.Vacuum):
click.echo("Sensor dirty: %s" % res.sensor_dirty)


@cli.command()
@click.argument('name', type=str, required=True)
@pass_dev
def reset_consumable(vac: miio.Vacuum, name):
"""Query and reset consumable."""
click.echo("Reset consumable %s" % name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Reseting consumable '%s'" would look here nicer.

vac.consumable_reset(name)


@cli.command()
@pass_dev
def start(vac: miio.Vacuum):
Expand Down