Separate consumables into it's own feature
This commit is contained in:
parent
59c7dc8033
commit
26cbc26af1
|
|
@ -18,6 +18,7 @@ class RoboVacEntityFeature(IntEnum):
|
||||||
MAP = 512
|
MAP = 512
|
||||||
BOOST_IQ = 1024
|
BOOST_IQ = 1024
|
||||||
|
|
||||||
|
|
||||||
ROBOVAC_SERIES = {
|
ROBOVAC_SERIES = {
|
||||||
"C": [
|
"C": [
|
||||||
"T2103",
|
"T2103",
|
||||||
|
|
@ -28,6 +29,7 @@ ROBOVAC_SERIES = {
|
||||||
"T2123",
|
"T2123",
|
||||||
"T2128",
|
"T2128",
|
||||||
"T2130",
|
"T2130",
|
||||||
|
"T2132",
|
||||||
],
|
],
|
||||||
"G": [
|
"G": [
|
||||||
"T1250",
|
"T1250",
|
||||||
|
|
@ -37,37 +39,54 @@ ROBOVAC_SERIES = {
|
||||||
"T2253",
|
"T2253",
|
||||||
"T2150",
|
"T2150",
|
||||||
"T2255",
|
"T2255",
|
||||||
|
"T2256",
|
||||||
|
"T2257",
|
||||||
|
"T2258",
|
||||||
|
"T2259",
|
||||||
|
"T2270",
|
||||||
|
"T2272",
|
||||||
|
"T2273",
|
||||||
],
|
],
|
||||||
"L": ["T2182", "T2192"],
|
"L": ["T2181", "T2182", "T2190", "T2192", "T2193", "T2194"],
|
||||||
"X": ["T2261", "T2262", "T2320"],
|
"X": ["T2261", "T2262", "T2320"],
|
||||||
}
|
}
|
||||||
|
|
||||||
HAS_MAP_FEATURE = ["T2253", *ROBOVAC_SERIES["L"], *ROBOVAC_SERIES["X"]]
|
HAS_MAP_FEATURE = ["T2253", *ROBOVAC_SERIES["L"], *ROBOVAC_SERIES["X"]]
|
||||||
|
|
||||||
|
HAS_CONSUMABLES = [
|
||||||
|
"T1250",
|
||||||
|
"T2181",
|
||||||
|
"T2182",
|
||||||
|
"T2190",
|
||||||
|
"T2193",
|
||||||
|
"T2194",
|
||||||
|
"T2253",
|
||||||
|
"T2256",
|
||||||
|
"T2258",
|
||||||
|
"T2261",
|
||||||
|
"T2273",
|
||||||
|
"T2320",
|
||||||
|
]
|
||||||
|
|
||||||
ROBOVAC_SERIES_FEATURES = {
|
ROBOVAC_SERIES_FEATURES = {
|
||||||
"C": RoboVacEntityFeature.EDGE | RoboVacEntityFeature.SMALL_ROOM,
|
"C": RoboVacEntityFeature.EDGE | RoboVacEntityFeature.SMALL_ROOM,
|
||||||
"G": RoboVacEntityFeature.CLEANING_TIME
|
"G": RoboVacEntityFeature.CLEANING_TIME
|
||||||
| RoboVacEntityFeature.CLEANING_AREA
|
| RoboVacEntityFeature.CLEANING_AREA
|
||||||
| RoboVacEntityFeature.DO_NOT_DISTURB
|
| RoboVacEntityFeature.DO_NOT_DISTURB
|
||||||
| RoboVacEntityFeature.AUTO_RETURN
|
| RoboVacEntityFeature.AUTO_RETURN,
|
||||||
| RoboVacEntityFeature.CONSUMABLES,
|
|
||||||
"L": RoboVacEntityFeature.CLEANING_TIME
|
"L": RoboVacEntityFeature.CLEANING_TIME
|
||||||
| RoboVacEntityFeature.CLEANING_AREA
|
| RoboVacEntityFeature.CLEANING_AREA
|
||||||
| RoboVacEntityFeature.DO_NOT_DISTURB
|
| RoboVacEntityFeature.DO_NOT_DISTURB
|
||||||
| RoboVacEntityFeature.AUTO_RETURN
|
| RoboVacEntityFeature.AUTO_RETURN
|
||||||
| RoboVacEntityFeature.CONSUMABLES
|
|
||||||
| RoboVacEntityFeature.ROOM
|
| RoboVacEntityFeature.ROOM
|
||||||
| RoboVacEntityFeature.ZONE
|
| RoboVacEntityFeature.ZONE
|
||||||
| RoboVacEntityFeature.MAP
|
|
||||||
| RoboVacEntityFeature.BOOST_IQ,
|
| RoboVacEntityFeature.BOOST_IQ,
|
||||||
"X": RoboVacEntityFeature.CLEANING_TIME
|
"X": RoboVacEntityFeature.CLEANING_TIME
|
||||||
| RoboVacEntityFeature.CLEANING_AREA
|
| RoboVacEntityFeature.CLEANING_AREA
|
||||||
| RoboVacEntityFeature.DO_NOT_DISTURB
|
| RoboVacEntityFeature.DO_NOT_DISTURB
|
||||||
| RoboVacEntityFeature.AUTO_RETURN
|
| RoboVacEntityFeature.AUTO_RETURN
|
||||||
| RoboVacEntityFeature.CONSUMABLES
|
|
||||||
| RoboVacEntityFeature.ROOM
|
| RoboVacEntityFeature.ROOM
|
||||||
| RoboVacEntityFeature.ZONE
|
| RoboVacEntityFeature.ZONE
|
||||||
| RoboVacEntityFeature.MAP
|
|
||||||
| RoboVacEntityFeature.BOOST_IQ,
|
| RoboVacEntityFeature.BOOST_IQ,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +139,15 @@ class RoboVac(TuyaDevice):
|
||||||
return supportedFeatures
|
return supportedFeatures
|
||||||
|
|
||||||
def getRoboVacFeatures(self):
|
def getRoboVacFeatures(self):
|
||||||
return ROBOVAC_SERIES_FEATURES[self.getRoboVacSeries()]
|
supportedFeatures = ROBOVAC_SERIES_FEATURES[self.getRoboVacSeries()]
|
||||||
|
|
||||||
|
if self.model_code in HAS_MAP_FEATURE:
|
||||||
|
supportedFeatures |= RoboVacEntityFeature.MAP
|
||||||
|
|
||||||
|
if self.model_code in HAS_CONSUMABLES:
|
||||||
|
supportedFeatures |= RoboVacEntityFeature.CONSUMABLES
|
||||||
|
|
||||||
|
return supportedFeatures
|
||||||
|
|
||||||
def getRoboVacSeries(self):
|
def getRoboVacSeries(self):
|
||||||
for series, models in ROBOVAC_SERIES.items():
|
for series, models in ROBOVAC_SERIES.items():
|
||||||
|
|
|
||||||
|
|
@ -284,22 +284,17 @@ class RoboVacEntity(StateVacuumEntity):
|
||||||
self._attr_cleaning_time = self.tuyastatus.get(TUYA_CODES.CLEANING_TIME)
|
self._attr_cleaning_time = self.tuyastatus.get(TUYA_CODES.CLEANING_TIME)
|
||||||
self._attr_auto_return = self.tuyastatus.get(TUYA_CODES.AUTO_RETURN)
|
self._attr_auto_return = self.tuyastatus.get(TUYA_CODES.AUTO_RETURN)
|
||||||
self._attr_do_not_disturb = self.tuyastatus.get(TUYA_CODES.DO_NOT_DISTURB)
|
self._attr_do_not_disturb = self.tuyastatus.get(TUYA_CODES.DO_NOT_DISTURB)
|
||||||
if self.tuyastatus.get(TUYA_CODES.G_CONSUMABLES) is not None:
|
|
||||||
self._attr_consumables = ast.literal_eval(
|
|
||||||
base64.b64decode(self.tuyastatus.get(TUYA_CODES.G_CONSUMABLES)).decode(
|
|
||||||
"ascii"
|
|
||||||
)
|
|
||||||
)["consumable"]["duration"]
|
|
||||||
# For X8
|
|
||||||
self._attr_boost_iq = self.tuyastatus.get(TUYA_CODES.BOOST_IQ)
|
self._attr_boost_iq = self.tuyastatus.get(TUYA_CODES.BOOST_IQ)
|
||||||
# self.map_data = self.tuyastatus.get("121")
|
# self.map_data = self.tuyastatus.get("121")
|
||||||
# self.erro_msg? = self.tuyastatus.get("124")
|
# self.erro_msg? = self.tuyastatus.get("124")
|
||||||
if self.tuyastatus.get(TUYA_CODES.X_CONSUMABLES) is not None:
|
if self.robovac_supported & RoboVacEntityFeature.CONSUMABLES:
|
||||||
self._attr_consumables = ast.literal_eval(
|
robovac_series = self.vacuum.getRoboVacSeries()
|
||||||
base64.b64decode(self.tuyastatus.get(TUYA_CODES.X_CONSUMABLES)).decode(
|
if self.tuyastatus.get(TUYA_CODES["{}_CONSUMABLES".format(robovac_series)]) is not None:
|
||||||
"ascii"
|
self._attr_consumables = ast.literal_eval(
|
||||||
)
|
base64.b64decode(self.tuyastatus.get(TUYA_CODES["{}_CONSUMABLES".format(robovac_series)])).decode(
|
||||||
)["consumable"]["duration"]
|
"ascii"
|
||||||
|
)
|
||||||
|
)["consumable"]["duration"]
|
||||||
|
|
||||||
async def async_locate(self, **kwargs):
|
async def async_locate(self, **kwargs):
|
||||||
"""Locate the vacuum cleaner."""
|
"""Locate the vacuum cleaner."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue