Skip to content

Commit

Permalink
Add parameters to no-go zone, fix type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Feb 2, 2019
1 parent 296e394 commit 2e20422
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions miio/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,40 +218,55 @@ def persist_map(self, version):
raise VacuumException("Unknown map version: %s" % version)

@command(
click.argument("id", type=int),
click.argument("x1", type=int),
click.argument("y1", type=int),
click.argument("x2", type=int),
click.argument("y2", type=int),
)
def create_software_barrier(self, id, x1, y1, x2, y2):
def create_software_barrier(self, x1, y1, x2, y2):
"""Create software barrier (gen2 only?).
NOTE: Multiple nogo zones and barriers could be added by passing
a list of them to save_map.
Requires new fw version.
3.3.9_001633+?
"""
return self.send("save_map", [id, x1, y1, x2, y2])[0] == "ok"
# First parameter indicates the type, 1 = barrier
payload = [1, x1, y1, x2, y2]
return self.send("save_map", payload)[0] == "ok"

@command(
click.argument("id", type=int),
click.argument("x1")
click.argument("x1", type=int),
click.argument("y1", type=int),
click.argument("x2", type=int),
click.argument("y2", type=int),
click.argument("x3", type=int),
click.argument("y3", type=int),
click.argument("x4", type=int),
click.argument("y4", type=int),
)
def create_nogo_zone(self, id, x1, y1, x2, y2, x3, y3, x4, y4):
def create_nogo_zone(self, x1, y1, x2, y2, x3, y3, x4, y4):
"""Create a rectangular no-go zone (gen2 only?).
NOTE: Multiple nogo zones and barriers could be added by passing
a list of them to save_map.
Requires new fw version.
3.3.9_001633+?
"""
return self.send("save_map",
[id, x1, y1, x2, y2, x3, y3, x4, y4])[0] == "ok"
# First parameter indicates the type, 0 = zone
payload = [0, x1, y1, x2, y2, x3, y3, x4, y4]
return self.send("save_map", payload)[0] == "ok"

@command(
click.argument("enable", type=bool)
)
def set_lab_mode(self, enable):
"""Set the lab mode?
def enable_lab_mode(self, enable):
"""Enable persistent maps and software barriers.
No clue what does this oo and which fw is required."""
This is required to use create_nogo_zone and create_software_barrier
commands."""
return self.send("set_lab_status", int(enable))['ok']

@command()
Expand Down

0 comments on commit 2e20422

Please sign in to comment.