Skip to content

Commit

Permalink
STYJ02YM: Add support for manual movements.
Browse files Browse the repository at this point in the history
  • Loading branch information
rumpeltux committed Dec 5, 2019
1 parent 3fb7be4 commit 3120efa
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions miio/viomivacuum.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import click
import logging
import time

from collections import defaultdict
from datetime import timedelta
from enum import Enum

import click

from .click_common import EnumType, command, format_output
from .device import Device
from .utils import pretty_seconds
Expand Down Expand Up @@ -51,6 +52,15 @@ class ViomiCarpetTurbo(Enum):
Turbo = 2


class ViomiMovementDirection(Enum):
Forward = 1
Left = 2 # Rotate
Right = 3 # Rotate
Backward = 4
Stop = 5
# 10 is unknown


class ViomiVacuumStatus:
def __init__(self, data):
# ["run_state","mode","err_state","battary_life","box_type","mop_type","s_time","s_area",
Expand Down Expand Up @@ -221,6 +231,18 @@ def home(self):
"""Return to home."""
self.send("set_charge", [1])

@command(
click.argument("direction", type=EnumType(ViomiMovementDirection, False)),
click.option('--duration', type=float, default=.5, help='number of seconds to perform this movement'),
)
def move(self, direction, duration=.5):
"""Manual movement."""
start = time.time()
while time.time() - start < duration:
self.send("set_direction", [direction.value])
time.sleep(.1)
self.send("set_direction", [ViomiMovementDirection.Stop.value])

@command(click.argument("mode", type=EnumType(ViomiMopMode, False)))
def mop_mode(self, mode):
"""Set mopping mode."""
Expand Down

0 comments on commit 3120efa

Please sign in to comment.