From 28d8212a0176344f83916b123716076ada5a9a67 Mon Sep 17 00:00:00 2001 From: Austin Zielman Date: Sun, 30 Jun 2024 15:10:18 -0700 Subject: [PATCH] Some initial cleanup, new codes + support for mops --- custom_components/robovac/__init__.py | 2 +- custom_components/robovac/config_flow.py | 1 - custom_components/robovac/robovac.py | 8 +++++++- custom_components/robovac/tuyalocalapi.py | 2 +- custom_components/robovac/vacuum.py | 7 ++++++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/custom_components/robovac/__init__.py b/custom_components/robovac/__init__.py index a8b6742..af35c9d 100644 --- a/custom_components/robovac/__init__.py +++ b/custom_components/robovac/__init__.py @@ -34,7 +34,7 @@ async def async_setup(hass, entry) -> bool: async def update_device(device): entry = async_get_config_entry_for_device(hass, device["gwId"]) - if entry == None: + if entry is None: return if not entry.state.recoverable: diff --git a/custom_components/robovac/config_flow.py b/custom_components/robovac/config_flow.py index c99d3f6..b9cf40b 100644 --- a/custom_components/robovac/config_flow.py +++ b/custom_components/robovac/config_flow.py @@ -28,7 +28,6 @@ from homeassistant.core import callback from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError -from homeassistant.helpers.selector import selector from homeassistant.const import ( CONF_ACCESS_TOKEN, diff --git a/custom_components/robovac/robovac.py b/custom_components/robovac/robovac.py index 2070556..43579bd 100644 --- a/custom_components/robovac/robovac.py +++ b/custom_components/robovac/robovac.py @@ -17,6 +17,7 @@ class RoboVacEntityFeature(IntEnum): ZONE = 256 MAP = 512 BOOST_IQ = 1024 + MOP = 2048 ROBOVAC_SERIES = { @@ -89,7 +90,7 @@ ROBOVAC_SERIES_FEATURES = { | RoboVacEntityFeature.AUTO_RETURN | RoboVacEntityFeature.ROOM | RoboVacEntityFeature.ZONE - | RoboVacEntityFeature.BOOST_IQ, + | RoboVacEntityFeature.MOP, "X": RoboVacEntityFeature.CLEANING_TIME | RoboVacEntityFeature.CLEANING_AREA | RoboVacEntityFeature.DO_NOT_DISTURB @@ -107,6 +108,11 @@ ROBOVAC_SERIES_FAN_SPEEDS = { "X": ["Pure", "Standard", "Turbo", "Max"], } +ROBOVAC_MOP_SETTINGS = { + "R": ["low", "middle", "high"], +} + + SUPPORTED_ROBOVAC_MODELS = list( set([item for sublist in ROBOVAC_SERIES.values() for item in sublist]) diff --git a/custom_components/robovac/tuyalocalapi.py b/custom_components/robovac/tuyalocalapi.py index 772dc53..1f32906 100644 --- a/custom_components/robovac/tuyalocalapi.py +++ b/custom_components/robovac/tuyalocalapi.py @@ -580,7 +580,7 @@ class Message: if payload_data: try: payload_data = cipher.decrypt(command, payload_data) - except ValueError as e: + except ValueError: pass try: payload_text = payload_data.decode("utf8") diff --git a/custom_components/robovac/vacuum.py b/custom_components/robovac/vacuum.py index 48ffafa..f9ebd18 100644 --- a/custom_components/robovac/vacuum.py +++ b/custom_components/robovac/vacuum.py @@ -100,6 +100,11 @@ class TUYA_CODES(StrEnum): DO_NOT_DISTURB = "107" BOOST_IQ = "118" +class TUYA_CODES_V2(StrEnum): + BATTERY_LEVEL = "163" + VACUUM_MODE = "158" + MOP_MODE = "10" + TUYA_CONSUMABLES_CODES = ["142", "116"] @@ -332,7 +337,7 @@ class RoboVacEntity(StateVacuumEntity): self.tuyastatus = self.vacuum._dps # for 15C - self._attr_battery_level = self.tuyastatus.get(TUYA_CODES.BATTERY_LEVEL) + self._attr_battery_level = self.tuyastatus.get(TUYA_CODES.BATTERY_LEVEL) or self.tuyastatus.get(TUYA_CODES_V2.BATTERY_LEVEL) self.tuya_state = self.tuyastatus.get(TUYA_CODES.STATE) self.error_code = self.tuyastatus.get(TUYA_CODES.ERROR_CODE) self._attr_mode = self.tuyastatus.get(TUYA_CODES.MODE)