miio icon indicating copy to clipboard operation
miio copied to clipboard

Support for Humidifier new model: zhimi.humidifier.cb1

Open antylama opened this issue 5 years ago • 8 comments

Hi,

I posted this on wrong place. It's about python-miio, but in node miio cb1 isn't supported too.

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 for python-miio:

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)

antylama avatar Apr 02 '19 23:04 antylama

Were you able to connect it to your local WiFi network, and communicate with it afterwards? I also have CB1, and I am not able to pair it with Mi Home app. I wanted to at least access to readings using my local network, but after "configure_wifi" command I am not able to speak with humidifier anymore (token rolled?)

wbidus avatar Apr 05 '19 20:04 wbidus

At the moment if you want to get the token you have to use modified Mi Home app https://uploadfiles.io/5dnfi (be carefully it's not my mod, i have used it with backup phone and fake account). After that just change temp_dec to temperature !

cHunter789 avatar Apr 06 '19 20:04 cHunter789

it's my mod, kinda pitty they sell devices without support ;) btw: it's US model so there's also fahrenheit temperature supported by firmware.

public static final String MODEL = "zhimi.humidifier.cb1"; public static final String PROP_FAH = "fahrenheit";

in case you want to add support for ca2 model the only difference to ca1 is... yeah temperature prop. 3 models, 3 different prop names ;)

public static final String MODEL = "zhimi.humidifier.ca2"; public static final String PROP_TEMPERATURE = "temp";

rezmus avatar Apr 08 '19 22:04 rezmus

My ca1 model almost works in Mi Home app on iPad (3 gen), works means: 1. detected and configure in manual mode (region: china), 2. only on/off device works, nothing else (error: 7, falling init device).

In the same time, on the same account android version of Mi Home (standard version, and beta on Android Pie), don't even display ca1 on list ;-).

Probably iPad version of app, just don't test version model, and this is why something is "working". I got token from iPad. Token from device not connected to wifi (accessed by device AP), isn't the same, but working in AP-mode.

antylama avatar Apr 09 '19 07:04 antylama

ca1 is chinese version and should be fully supported by both ipad and android mi home, however cb1 (us version) is still missing on any region.

rezmus avatar Apr 09 '19 07:04 rezmus

Still no adding of CB1 version to miio? I'm trying to add it via 'zhimi.humidifier.cb1' model in Home Assistance - no luck.

koznov avatar Oct 15 '19 20:10 koznov

Cb1 works on US region

AZheleznov avatar Dec 12 '19 21:12 AZheleznov

Please support zhimi.humidifier.cb2, too

gyulkiller avatar Nov 04 '20 01:11 gyulkiller