Skip to content

Support for Humidifier new model: zhimi.humidifier.cb1 #492

Closed
@antylama

Description

@antylama

Hi,

I got Smartmi Evaporative Humidifier, with new return model version:

WARNING:miio.discovery:Found unsupported device zhimi-humidifier-cb1_mibt13281121._miio._udp.local. at 192.168.1.10, please report to developers
Model: zhimi.humidifier.cb1
Hardware version: MTK7697
Firmware version: 1.6.5
Network: {'localIp': '192.168.1.10', 'mask': '255.255.255.0', 'gw': '192.168.1.1', 'gw_mac': 'mac'}
AP: {'rssi': -53, 'ssid': 'ssid', 'bssid': 'bssid'}

It's not really working on Mija Home App, so I grab the token, and run miiocli as "CA1". Everything working, except fetching status (temp_dec don't exists).

Fast path:

index 54b56f3..18a5a31 100644
--- a/miio/airhumidifier.py
+++ b/miio/airhumidifier.py
@@ -12,11 +12,11 @@ _LOGGER = logging.getLogger(__name__)
 
 MODEL_HUMIDIFIER_V1 = 'zhimi.humidifier.v1'
 MODEL_HUMIDIFIER_CA1 = 'zhimi.humidifier.ca1'
+MODEL_HUMIDIFIER_CB1 = 'zhimi.humidifier.cb1'
 
 AVAILABLE_PROPERTIES_COMMON = [
     'power',
     'mode',
-    'temp_dec',
     'humidity',
     'buzzer',
     'led_b',
@@ -27,8 +27,9 @@ AVAILABLE_PROPERTIES_COMMON = [
 ]
 
 AVAILABLE_PROPERTIES = {
-    MODEL_HUMIDIFIER_V1: AVAILABLE_PROPERTIES_COMMON + ['trans_level', 'button_pressed'],
-    MODEL_HUMIDIFIER_CA1: AVAILABLE_PROPERTIES_COMMON + ['speed', 'depth', 'dry'],
+    MODEL_HUMIDIFIER_V1: AVAILABLE_PROPERTIES_COMMON + ['temp_dec', 'trans_level', 'button_pressed'],
+    MODEL_HUMIDIFIER_CA1: AVAILABLE_PROPERTIES_COMMON + ['temp_dec', 'speed', 'depth', 'dry'],
+    MODEL_HUMIDIFIER_CB1: AVAILABLE_PROPERTIES_COMMON + ['temperature', 'speed', 'depth', 'dry']
 }
 
 
@@ -85,6 +86,8 @@ class AirHumidifierStatus:
     @property
     def temperature(self) -> Optional[float]:
         """Current temperature, if available."""
+        if self.data["temperature"] is not None:
+            return self.data["temperature"]
         if self.data["temp_dec"] is not None:
             return self.data["temp_dec"] / 10.0
         return None
@@ -285,8 +288,8 @@ class AirHumidifier(Device):
         # properties are divided into multiple requests
         _props_per_request = 15
 
-        # The  CA1 is limited to a single property per request
-        if self.model == MODEL_HUMIDIFIER_CA1:
+        # The CA1/CB1 are limited to a single property per request
+        if self.model != MODEL_HUMIDIFIER_V1:
             _props_per_request = 1
 
         _props = properties.copy()
@@ -335,10 +338,10 @@ class AirHumidifier(Device):
     )
     def set_led_brightness(self, brightness: LedBrightness):
         """Set led brightness."""
-        if self.model == MODEL_HUMIDIFIER_CA1:
-            return self.send("set_led_b", [str(brightness.value)])
+        if self.model == MODEL_HUMIDIFIER_V1:
+            return self.send("set_led_b", [brightness.value])
 
-        return self.send("set_led_b", [brightness.value])
+        return self.send("set_led_b", [str(brightness.value)])
 
     @command(
         click.argument("led", type=bool),
@@ -414,3 +417,9 @@ class AirHumidifierCA1(AirHumidifier):
                  debug: int = 0, lazy_discover: bool = True) -> None:
         super().__init__(ip, token, start_id, debug, lazy_discover,
                          model=MODEL_HUMIDIFIER_CA1)
+
+class AirHumidifierCB1(AirHumidifier):
+    def __init__(self, ip: str = None, token: str = None, start_id: int = 0,
+                 debug: int = 0, lazy_discover: bool = True) -> None:
+        super().__init__(ip, token, start_id, debug, lazy_discover,
+                         model=MODEL_HUMIDIFIER_CB1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions