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

Add support for a few more commands of the STYJ02YM #581

Merged
merged 3 commits into from
Nov 27, 2019
Merged
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
52 changes: 51 additions & 1 deletion miio/viomivacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import click

from .click_common import command, format_output
from .click_common import EnumType, command, format_output
from .device import Device
from .utils import pretty_seconds
from .vacuumcontainers import DNDStatus

_LOGGER = logging.getLogger(__name__)

Expand All @@ -28,6 +29,16 @@ class ViomiVacuumState(Enum):
Docked = 5


class ViomiLanguage(Enum):
CN = 1 # Chinese (default)
EN = 2 # English


class ViomiLedState(Enum):
Off = 0
On = 1


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 @@ -175,3 +186,42 @@ def set_fan_speed(self, speed: str):
def home(self):
"""Return to home."""
self.send("set_charge", [1])

@command()
def dnd_status(self):
"""Returns do-not-disturb status."""
status = self.send("get_notdisturb")
return DNDStatus(dict(
enabled=status[0],
start_hour=status[1], start_minute=status[2],
end_hour=status[3], end_minute=status[4]))

@command(
click.option("--disable", is_flag=True),
click.argument("start_hr", type=int),
click.argument("start_min", type=int),
click.argument("end_hr", type=int),
click.argument("end_min", type=int),
)
def set_dnd(self, disable: bool, start_hr: int, start_min: int, end_hr: int, end_min: int):
"""Set do-not-disturb.

:param int start_hr: Start hour
:param int start_min: Start minute
:param int end_hr: End hour
:param int end_min: End minute"""
return self.send("set_notdisturb", [0 if disable else 1, start_hr, start_min, end_hr, end_min])

@command(
click.argument('language', type=EnumType(ViomiLanguage, False))
)
def set_language(self, language: ViomiLanguage):
"""Set the device's audio language."""
return self.send("set_language", [language.value])

@command(
click.argument('state', type=EnumType(ViomiLedState, False))
)
def led(self, state: ViomiLedState):
"""Switch the button leds on or off."""
return self.send("set_light", [state.value])