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 dreame.vacuum.ma1808 and dreame.vacuum.mb1808 #1774

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 8 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
28 changes: 26 additions & 2 deletions miio/integrations/dreame/vacuum/dreamevacuum_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@


DREAME_1C = "dreame.vacuum.mc1808"
DREAME_1C_A = "dreame.vacuum.ma1808"
DREAME_1C_B = "dreame.vacuum.mb1808"
DREAME_F9 = "dreame.vacuum.p2008"
DREAME_D9 = "dreame.vacuum.p2009"
DREAME_Z10_PRO = "dreame.vacuum.p2028"
Expand Down Expand Up @@ -48,6 +50,7 @@
"total_clean_time": {"siid": 18, "piid": 13},
"total_clean_times": {"siid": 18, "piid": 14},
"total_clean_area": {"siid": 18, "piid": 15},
"water_flow": {"siid": 18, "piid": 20},
"life_sieve": {"siid": 19, "piid": 1},
"life_brush_side": {"siid": 19, "piid": 2},
"life_brush_main": {"siid": 19, "piid": 3},
Expand Down Expand Up @@ -166,6 +169,8 @@

MIOT_MAPPING: Dict[str, MiotMapping] = {
DREAME_1C: _DREAME_1C_MAPPING,
DREAME_1C_A: _DREAME_1C_MAPPING,
DREAME_1C_B: _DREAME_1C_MAPPING,
DREAME_F9: _DREAME_F9_MAPPING,
DREAME_D9: _DREAME_F9_MAPPING,
DREAME_Z10_PRO: _DREAME_F9_MAPPING,
Expand Down Expand Up @@ -249,7 +254,7 @@ def _enum_as_dict(cls):

def _get_cleaning_mode_enum_class(model):
"""Return cleaning mode enum class for model if found or None."""
if model == DREAME_1C:
if model in (DREAME_1C, DREAME_1C_A, DREAME_1C_B):
return CleaningModeDreame1C
elif model in (
DREAME_F9,
Expand Down Expand Up @@ -508,7 +513,9 @@ def status(self) -> DreameVacuumStatus:

return DreameVacuumStatus(
{
prop["did"]: prop["value"] if prop["code"] == 0 else None
prop["did"]: prop["value"]
if prop["code"] == 0 and "value" in prop
else None
for prop in self.get_properties_for_mapping(max_properties=10)
},
self.model,
Expand All @@ -520,6 +527,9 @@ def status(self) -> DreameVacuumStatus:
MANUAL_DISTANCE_MAX = 300
MANUAL_DISTANCE_MIN = -300

VOLUME_MIN = 0
VOLUME_MAX = 100

@command()
def start(self) -> None:
"""Start cleaning."""
Expand Down Expand Up @@ -588,6 +598,20 @@ def set_fan_speed(self, speed: int):
click.echo(f"Setting fanspeed to {fanspeed.name}")
return self.set_property("cleaning_mode", fanspeed.value)

@command(click.argument("volume", type=int))
def set_volume(self, volume: int):
"""Set volume.

:param int volume: Volume to set
"""
if volume < self.VOLUME_MIN or volume > self.VOLUME_MAX:
raise ValueError(
"Given volume is invalid, should be [%s, %s], was: %s"
% (self.VOLUME_MIN, self.VOLUME_MAX, volume)
)
click.echo(f"Setting volume to {volume}")
return self.set_property("volume", volume)

@command()
def fan_speed_presets(self) -> Dict[str, int]:
"""Return available fan speed presets."""
Expand Down