Skip to content

Commit

Permalink
Added additional OperatingModes and FaultStatuses for dreamevacuum (#…
Browse files Browse the repository at this point in the history
…1090)

* Added additional OperatingMode and DeviceStatus codes

* Applied requested fixes to the commit

* TODO comment is back

* Sleeping status code submission

* Space

* Update miio/dreamevacuum_miot.py

* Use parent's get_properties_from_mapping and fix linting

Co-authored-by: Teemu R <tpr@iki.fi>
  • Loading branch information
StarterCraft and rytilahti committed Jul 8, 2021
1 parent 83cd097 commit 61ca4a1
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions miio/dreamevacuum_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ class CleaningMode(Enum):

class OperatingMode(Enum):
Unknown = -1
Paused = 1
Cleaning = 2
GoCharging = 3
Paused = 14
Charging = 6
ManualCleaning = 13
Sleeping = 14
ManualPaused = 17
ZonedCleaning = 19


class FaultStatus(Enum):
Expand All @@ -74,6 +79,7 @@ class DeviceStatus(Enum):
Error = 4
GoCharging = 5
Charging = 6
ManualSweeping = 13


class DreameVacuumStatus(DeviceStatusContainer):
Expand Down Expand Up @@ -222,7 +228,7 @@ def status(self) -> DreameVacuumStatus:
return DreameVacuumStatus(
{
prop["did"]: prop["value"] if prop["code"] == 0 else None
for prop in self.get_properties_for_mapping()
for prop in self.get_properties_for_mapping(max_properties=10)
}
)

Expand Down Expand Up @@ -274,19 +280,3 @@ def reset_filter_life(self) -> None:
def reset_sidebrush_life(self) -> None:
"""Reset side brush life."""
return self.send_action(28, 1)

def get_properties_for_mapping(self, *, max_properties=15) -> list:
"""Retrieve raw properties based on mapping.
Method was copied from the base class to change the value of max_properties to
10. This change is needed to avoid "Checksum error" messages from the device.
# TODO: miotdevice class should have a possibility to define its max_properties value
"""

# We send property key in "did" because it's sent back via response and we can identify the property.
properties = [{"did": k, **v} for k, v in self.mapping.items()]

return self.get_properties(
properties, property_getter="get_properties", max_properties=10
)

0 comments on commit 61ca4a1

Please sign in to comment.