Skip to content

Commit

Permalink
Expose mop_type, fix error string handling and fix water_grade. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed May 24, 2020
1 parent 5f8dce9 commit cb0e9e5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions miio/viomivacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import defaultdict
from datetime import timedelta
from enum import Enum
from typing import Dict
from typing import Dict, Optional

import click

Expand Down Expand Up @@ -126,15 +126,22 @@ def mode(self):
"""
return ViomiMode(self.data["mode"])

@property
def mop_type(self):
"""Unknown mop_type values."""
return self.data["mop_type"]

@property
def error_code(self) -> int:
"""Error code from vacuum."""

return self.data["error_state"]
return self.data["err_state"]

@property
def error(self) -> str:
def error(self) -> Optional[str]:
"""String presentation for the error code."""
if self.error_code is None:
return None

return ERROR_CODES.get(self.error_code, f"Unknown error {self.error_code}")

Expand Down Expand Up @@ -207,7 +214,7 @@ class ViomiVacuum(Device):
"Mop type: {result.mop_type}\n"
"Clean time: {result.clean_time}\n"
"Clean area: {result.clean_area}\n"
"Water level: {result.water_level}\n"
"Water grade: {result.water_grade}\n"
"Remember map: {result.remember_map}\n"
"Has map: {result.has_map}\n"
"Has new map: {result.has_new_map}\n"
Expand Down

0 comments on commit cb0e9e5

Please sign in to comment.