From fb3191b2ad3f931845df950f497e5c10d31f015d Mon Sep 17 00:00:00 2001 From: Teemu R Date: Wed, 5 Jan 2022 00:24:05 +0100 Subject: [PATCH] Add more supported models (#1275) * airpurifier_miot: add zhimi.airp.mb4a * Add roborock t6 (roborock.vacuum.t6) * Add viomi.vacuum.v10 to viomi * Add Roborock T7 (roborock.vacuum.a11) --- miio/airpurifier_miot.py | 7 +++++- miio/integrations/vacuum/roborock/vacuum.py | 23 +++++++++++++++++-- miio/integrations/vacuum/viomi/viomivacuum.py | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/miio/airpurifier_miot.py b/miio/airpurifier_miot.py index f59374b12..9a2e41bdb 100644 --- a/miio/airpurifier_miot.py +++ b/miio/airpurifier_miot.py @@ -16,6 +16,11 @@ "zhimi.airpurifier.vb2", # airpurifier proh ] +SUPPORTED_MODELS_MB4 = [ + "zhimi.airpurifier.mb4", # airpurifier 3c + "zhimi.airp.mb4a", # airpurifier 3c +] + _LOGGER = logging.getLogger(__name__) _MAPPING = { # Air Purifier (siid=2) @@ -468,7 +473,7 @@ class AirPurifierMB4(BasicAirPurifierMiot): """Main class representing the air purifier which uses MIoT protocol.""" mapping = _MODEL_AIRPURIFIER_MB4 - _supported_models = ["zhimi.airpurifier.mb4"] # airpurifier 3c + _supported_models = SUPPORTED_MODELS_MB4 @command( default_output=format_output( diff --git a/miio/integrations/vacuum/roborock/vacuum.py b/miio/integrations/vacuum/roborock/vacuum.py index c9ad390ab..7e04ca45d 100644 --- a/miio/integrations/vacuum/roborock/vacuum.py +++ b/miio/integrations/vacuum/roborock/vacuum.py @@ -137,7 +137,9 @@ class CarpetCleaningMode(enum.Enum): ROCKROBO_S5 = "roborock.vacuum.s5" ROCKROBO_S5_MAX = "roborock.vacuum.s5e" ROCKROBO_S6 = "roborock.vacuum.s6" +ROCKROBO_T6 = "roborock.vacuum.t6" # cn s6 ROCKROBO_S6_PURE = "roborock.vacuum.a08" +ROCKROBO_T7 = "roborock.vacuum.a11" # cn s7 ROCKROBO_T7S = "roborock.vacuum.a14" ROCKROBO_S7 = "roborock.vacuum.a15" ROCKROBO_S6_MAXV = "roborock.vacuum.a10" @@ -151,7 +153,9 @@ class CarpetCleaningMode(enum.Enum): ROCKROBO_S5, ROCKROBO_S5_MAX, ROCKROBO_S6, + ROCKROBO_T6, ROCKROBO_S6_PURE, + ROCKROBO_T7, ROCKROBO_T7S, ROCKROBO_S7, ROCKROBO_S6_MAXV, @@ -172,7 +176,7 @@ def __init__( start_id: int = 0, debug: int = 0, *, - model=None + model=None, ): super().__init__(ip, token, start_id, debug, model=model) self.manual_seqnum = -1 @@ -223,12 +227,27 @@ def _fetch_info(self) -> DeviceInfo: return info except (TypeError, DeviceInfoUnavailableException): # cloud-blocked gen1 vacuums will not return proper payloads + def create_dummy_mac(addr): + """Returns a dummy mac for a given IP address. + + This squats the FF:FF: OUI for a dummy mac presentation to + allow presenting a unique identifier for homeassistant. + """ + from ipaddress import ip_address + + ip_to_mac = ":".join( + [f"{hex(x).replace('0x', ''):0>2}" for x in ip_address(addr).packed] + ) + return f"FF:FF:{ip_to_mac}" + dummy_v1 = DeviceInfo( { "model": ROCKROBO_V1, "token": self.token, "netif": {"localIp": self.ip}, - "fw_ver": "1.0_dummy", + "mac": create_dummy_mac(self.ip), + "fw_ver": "1.0_nocloud", + "hw_ver": "1st gen non-cloud hw", } ) diff --git a/miio/integrations/vacuum/viomi/viomivacuum.py b/miio/integrations/vacuum/viomi/viomivacuum.py index c7bc2899c..a81506617 100644 --- a/miio/integrations/vacuum/viomi/viomivacuum.py +++ b/miio/integrations/vacuum/viomi/viomivacuum.py @@ -62,7 +62,7 @@ _LOGGER = logging.getLogger(__name__) -SUPPORTED_MODELS = ["viomi.vacuum.v7", "viomi.vacuum.v8"] +SUPPORTED_MODELS = ["viomi.vacuum.v7", "viomi.vacuum.v8", "viomi.vacuum.v10"] ERROR_CODES = { 0: "Sleeping and not charging",