dhewg / esphome-miot

ESPHome components for MIoT devices
Other
16 stars 8 forks source link

Added configuration file and references in the readme file for model: zhimi.airpurifier.mb4 (Mi Air Purifier 3C) #12

Closed kyutov closed 3 months ago

kyutov commented 3 months ago

Basically the configurations are almost identical as the configurations for zhimi.airp.mb4a. I have removed only the "Serial Number" text sensor (since it is missing in the MIoT Specification for zhimi.airpurifier.mb4 and it is not working for this model ) and I have changed the model and the references to the MIoT Specification.

dhewg commented 3 months ago

The serial is there, but hidden in SIID 1, see the json link on top of the spec page.

In fact the specs between the devices are identical, there's just some noise due to the different name:

--- 4a.json 2024-03-06 12:10:08.210192906 +0100
+++ 4.json  2024-03-06 12:10:03.974289716 +0100
@@ -12,7 +12,7 @@
                "description" : "Device Manufacturer",
                "format" : "string",
                "iid" : 1,
-               "type" : "urn:miot-spec-v2:property:manufacturer:00000001:zhimi-mb4a:1"
+               "type" : "urn:miot-spec-v2:property:manufacturer:00000001:zhimi-mb4:1"
             },
             {
                "access" : [
@@ -21,7 +21,7 @@
                "description" : "Device Model",
                "format" : "string",
                "iid" : 2,
-               "type" : "urn:miot-spec-v2:property:model:00000002:zhimi-mb4a:1"
+               "type" : "urn:miot-spec-v2:property:model:00000002:zhimi-mb4:1"
             },
             {
                "access" : [
@@ -30,7 +30,7 @@
                "description" : "Device Serial Number",
                "format" : "string",
                "iid" : 3,
-               "type" : "urn:miot-spec-v2:property:serial-number:00000003:zhimi-mb4a:1"
+               "type" : "urn:miot-spec-v2:property:serial-number:00000003:zhimi-mb4:1"
             },
             {
                "access" : [
@@ -39,10 +39,10 @@
                "description" : "Current Firmware Version",
                "format" : "string",
                "iid" : 4,
-               "type" : "urn:miot-spec-v2:property:firmware-revision:00000005:zhimi-mb4a:1"
+               "type" : "urn:miot-spec-v2:property:firmware-revision:00000005:zhimi-mb4:1"
             }
          ],
-         "type" : "urn:miot-spec-v2:service:device-information:00007801:zhimi-mb4a:1"
+         "type" : "urn:miot-spec-v2:service:device-information:00007801:zhimi-mb4:1"
       },
       {
          "description" : "Air Purifier",
@@ -57,7 +57,7 @@
                "description" : "Switch Status",
                "format" : "bool",
                "iid" : 1,
-               "type" : "urn:miot-spec-v2:property:on:00000006:zhimi-mb4a:1"
+               "type" : "urn:miot-spec-v2:property:on:00000006:zhimi-mb4:1"
             },
             {
                "access" : [
@@ -67,7 +67,7 @@
                "description" : "Device Fault",
                "format" : "string",
                "iid" : 2,
-               "type" : "urn:miot-spec-v2:property:fault:00000009:zhimi-mb4a:1",
+               "type" : "urn:miot-spec-v2:property:fault:00000009:zhimi-mb4:1",
                "unit" : "none"
             },
             {
@@ -79,7 +79,7 @@
                "description" : "Mode",
                "format" : "uint8",
                "iid" : 4,
-               "type" : "urn:miot-spec-v2:property:mode:00000008:zhimi-mb4a:1",
+               "type" : "urn:miot-spec-v2:property:mode:00000008:zhimi-mb4:1",
                "unit" : "none",
                "value-list" : [
                   {
@@ -97,7 +97,7 @@
                ]
             }
          ],
-         "type" : "urn:miot-spec-v2:service:air-purifier:00007811:zhimi-mb4a:1"
+         "type" : "urn:miot-spec-v2:service:air-purifier:00007811:zhimi-mb4:1"
       },
       {
          "description" : "Environment",
@@ -111,7 +111,7 @@
                "description" : "PM2.5 Density",
                "format" : "uint16",
                "iid" : 4,
-               "type" : "urn:miot-spec-v2:property:pm2.5-density:00000034:zhimi-mb4a:1",
+               "type" : "urn:miot-spec-v2:property:pm2.5-density:00000034:zhimi-mb4:1",
                "unit" : "none",
                "value-range" : [
                   0,
@@ -120,7 +120,7 @@
                ]
             }
          ],
-         "type" : "urn:miot-spec-v2:service:environment:0000780A:zhimi-mb4a:1"
+         "type" : "urn:miot-spec-v2:service:environment:0000780A:zhimi-mb4:1"
       },
       {
          "actions" : [
@@ -131,7 +131,7 @@
                   3
                ],
                "out" : [],
-               "type" : "urn:miot-spec-v2:action:reset-filter-life:00002803:zhimi-mb4a:1"
+               "type" : "urn:miot-spec-v2:action:reset-filter-life:00002803:zhimi-mb4:1"
             }
          ],
          "description" : "Filter",
@@ -145,7 +145,7 @@
                "description" : "Filter Life Level",
                "format" : "uint8",
                "iid" : 1,
-               "type" : "urn:miot-spec-v2:property:filter-life-level:0000001E:zhimi-mb4a:1",
+               "type" : "urn:miot-spec-v2:property:filter-life-level:0000001E:zhimi-mb4:1",
                "unit" : "percentage",
                "value-range" : [
                   0,
@@ -161,7 +161,7 @@
                "description" : "Filter Used Time",
                "format" : "uint16",
                "iid" : 3,
-               "type" : "urn:miot-spec-v2:property:filter-used-time:00000048:zhimi-mb4a:1",
+               "type" : "urn:miot-spec-v2:property:filter-used-time:00000048:zhimi-mb4:1",
                "unit" : "hours",
                "value-range" : [
                   0,
@@ -170,7 +170,7 @@
                ]
             }
          ],
-         "type" : "urn:miot-spec-v2:service:filter:0000780B:zhimi-mb4a:1"
+         "type" : "urn:miot-spec-v2:service:filter:0000780B:zhimi-mb4:1"
       },
       {
          "description" : "Alarm",
@@ -185,10 +185,10 @@
                "description" : "Alarm",
                "format" : "bool",
                "iid" : 1,
-               "type" : "urn:miot-spec-v2:property:alarm:00000012:zhimi-mb4a:1"
+               "type" : "urn:miot-spec-v2:property:alarm:00000012:zhimi-mb4:1"
             }
          ],
-         "type" : "urn:miot-spec-v2:service:alarm:00007804:zhimi-mb4a:1"
+         "type" : "urn:miot-spec-v2:service:alarm:00007804:zhimi-mb4:1"
       },
       {
          "description" : "Screen",
@@ -203,7 +203,7 @@
                "description" : "Brightness",
                "format" : "uint8",
                "iid" : 2,
-               "type" : "urn:miot-spec-v2:property:brightness:0000000D:zhimi-mb4a:1",
+               "type" : "urn:miot-spec-v2:property:brightness:0000000D:zhimi-mb4:1",
                "unit" : "none",
                "value-range" : [
                   0,
@@ -212,7 +212,7 @@
                ]
             }
          ],
-         "type" : "urn:miot-spec-v2:service:screen:00007806:zhimi-mb4a:1"
+         "type" : "urn:miot-spec-v2:service:screen:00007806:zhimi-mb4:1"
       },
       {
          "description" : "Physical Control Locked",
@@ -227,10 +227,10 @@
                "description" : "Physical Control Locked",
                "format" : "bool",
                "iid" : 1,
-               "type" : "urn:miot-spec-v2:property:physical-controls-locked:0000001D:zhimi-mb4a:1"
+               "type" : "urn:miot-spec-v2:property:physical-controls-locked:0000001D:zhimi-mb4:1"
             }
          ],
-         "type" : "urn:miot-spec-v2:service:physical-controls-locked:00007807:zhimi-mb4a:1"
+         "type" : "urn:miot-spec-v2:service:physical-controls-locked:00007807:zhimi-mb4:1"
       },
       {
          "description" : "custom-service",
@@ -239,37 +239,37 @@
                "arguments" : [],
                "description" : "fault-motor-stuck",
                "iid" : 1,
-               "type" : "urn:zhimi-spec:event:fault-motor-stuck:00005001:zhimi-mb4a:1"
+               "type" : "urn:zhimi-spec:event:fault-motor-stuck:00005001:zhimi-mb4:1"
             },
             {
                "arguments" : [],
                "description" : "childlock-trigger",
                "iid" : 2,
-               "type" : "urn:zhimi-spec:event:childlock-trigger:00005002:zhimi-mb4a:1"
+               "type" : "urn:zhimi-spec:event:childlock-trigger:00005002:zhimi-mb4:1"
             },
             {
                "arguments" : [],
                "description" : "door-opened",
                "iid" : 3,
-               "type" : "urn:zhimi-spec:event:door-opened:00005003:zhimi-mb4a:1"
+               "type" : "urn:zhimi-spec:event:door-opened:00005003:zhimi-mb4:1"
             },
             {
                "arguments" : [],
                "description" : "filter-exhausted",
                "iid" : 4,
-               "type" : "urn:zhimi-spec:event:filter-exhausted:00005004:zhimi-mb4a:1"
+               "type" : "urn:zhimi-spec:event:filter-exhausted:00005004:zhimi-mb4:1"
             },
             {
                "arguments" : [],
                "description" : "filter-reset",
                "iid" : 5,
-               "type" : "urn:zhimi-spec:event:filter-reset:00005005:zhimi-mb4a:1"
+               "type" : "urn:zhimi-spec:event:filter-reset:00005005:zhimi-mb4:1"
             },
             {
                "arguments" : [],
                "description" : "aqi-sensor-error",
                "iid" : 6,
-               "type" : "urn:zhimi-spec:event:aqi-sensor-error:00005006:zhimi-mb4a:1"
+               "type" : "urn:zhimi-spec:event:aqi-sensor-error:00005006:zhimi-mb4:1"
             }
          ],
          "iid" : 9,
@@ -282,7 +282,7 @@
                "description" : "moto-speed-rpm",
                "format" : "uint16",
                "iid" : 1,
-               "type" : "urn:zhimi-spec:property:moto-speed-rpm:00000001:zhimi-mb4a:1",
+               "type" : "urn:zhimi-spec:property:moto-speed-rpm:00000001:zhimi-mb4:1",
                "unit" : "none",
                "value-range" : [
                   0,
@@ -298,7 +298,7 @@
                "description" : "miio-lib-version",
                "format" : "string",
                "iid" : 2,
-               "type" : "urn:zhimi-spec:property:miio-lib-version:00000002:zhimi-mb4a:1",
+               "type" : "urn:zhimi-spec:property:miio-lib-version:00000002:zhimi-mb4:1",
                "unit" : "none"
             },
             {
@@ -310,7 +310,7 @@
                "description" : "",
                "format" : "uint16",
                "iid" : 3,
-               "type" : "urn:zhimi-spec:property:favorite-speed:00000003:zhimi-mb4a:1",
+               "type" : "urn:zhimi-spec:property:favorite-speed:00000003:zhimi-mb4:1",
                "unit" : "none",
                "value-range" : [
                   300,
@@ -327,7 +327,7 @@
                "description" : "",
                "format" : "int32",
                "iid" : 4,
-               "type" : "urn:zhimi-spec:property:aqi-updata-heartbeat:00000004:zhimi-mb4a:1",
+               "type" : "urn:zhimi-spec:property:aqi-updata-heartbeat:00000004:zhimi-mb4:1",
                "unit" : "seconds",
                "value-range" : [
                   0,
@@ -336,8 +336,8 @@
                ]
             }
          ],
-         "type" : "urn:zhimi-spec:service:custom-service:00007801:zhimi-mb4a:1"
+         "type" : "urn:zhimi-spec:service:custom-service:00007801:zhimi-mb4:1"
       }
    ],
-   "type" : "urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mb4a:1"
+   "type" : "urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mb4:1"
 }

On my 4lite, the ESP can't ask for the serial, but it's passed on by the MCU at specific times (like when net initially gets a cloud answer).

So I think we can use the same config? In that case, we could just extend the README and the config comment to mention both variants, so we only have to maintain one file

kyutov commented 3 months ago

Yes, I have noticed that the serial is hidden in the SIID 1 of the JSON, but my 3C has never managed to show this information, that's why I have removed the "Serial Number" text sensor.

As for the config - yes, the config file for zhimi.airp.mb4a can be used without a problem. If you prefer to use single file, we can just extend the README. Let me know if this is the case and I will close the PR.

dhewg commented 3 months ago

Yes, I have noticed that the serial is hidden in the SIID 1 of the JSON, but my 3C has never managed to show this information, that's why I have removed the "Serial Number" text sensor.

It may also be related to the MCU firmware? Anyway, as leaving it in doesn't harm I'd say let's use one config.

As for the config - yes, the config file for zhimi.airp.mb4a can be used without a problem. If you prefer to use single file, we can just extend the README. Let me know if this is the case and I will close the PR.

Yes, please add an addition comment line to the config to link to these specs and extend the README accordingly. And you could just reuse this PR for it ;)

dhewg commented 3 months ago

Sorry for the delay and thanks!