[miio] add support for zhimi.humidifier.ca4 (Smartmi Evaporative Air Humidifier 2) (#9093)

* miio: add support for zhimi.humidifier.ca4

This change adds support for Xiaomi Smartmi Evaporation Air Humidifier 2.

The device uses MIOT protocol, exact spec is available at:

http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:humidifier:0000A00E:zhimi-ca4:2

Signed-off-by: Marek Skrobacki <skrobul@skrobul.com>
This commit is contained in:
Marek Skrobacki 2020-11-26 22:32:39 +00:00 committed by GitHub
parent aa72044554
commit 0a9ea9fd45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6873 additions and 6450 deletions

View File

@ -98,6 +98,7 @@ Currently the miio binding supports more than 210 different models.
| Mi Air Quality Monitor S1 | miio:basic | [cgllc.airmonitor.s1](#cgllc-airmonitor-s1) | Yes | |
| Mi Air Humidifier | miio:basic | [zhimi.humidifier.v1](#zhimi-humidifier-v1) | Yes | |
| Mi Air Humidifier | miio:basic | [zhimi.humidifier.ca1](#zhimi-humidifier-ca1) | Yes | |
| Mi Air Evaporative Humidifier 2 | miio:basic | [zhimi.humidifier.ca4](#zhimi-humidifier-ca4) | Yes | |
| Mi Air Humidifier 2 | miio:basic | [zhimi.humidifier.cb1](#zhimi-humidifier-cb1) | Yes | |
| Mija Smart humidifier | miio:basic | [deerma.humidifier.mjjsq](#deerma-humidifier-mjjsq) | Yes | |
| Mi Air Purifier v1 | miio:basic | [zhimi.airpurifier.v1](#zhimi-airpurifier-v1) | Yes | |
@ -499,6 +500,29 @@ e.g. `smarthome:send actionCommand 'upd_timer["1498595904821", "on"]'` would ena
| temperature | Number | Temperature | |
| childlock | Switch | Child Lock | |
### Mi Air Evaporative Humidifier 2 (<a name="zhimi-humidifier-ca4">zhimi.humidifier.ca4</a>) Channels
| Channel | Type | Description | Comment |
|------------------|---------|-------------------------------------|------------|
| power | Switch | Power | |
| mode | Number | Mode | |
| Fault | Number | Humidifier Device Fault | |
| humidity | Number | Humidity | |
| targetHumidity | Number | Target Humidity | |
| waterlevel | Number | Water Level | |
| bright | Number | LED Brightness | |
| buzzer | Switch | Buzzer Status | |
| dry | Switch | Dry | |
| usedhours | Number | Run Time | |
| powerhours | Number | Power Time | |
| targetmotorspeed | Number | Target Motor Speed | |
| actualmotorspeed | Number | Actual Motor Speed | |
| temperature | Number | Temperature | |
| childlock | Switch | Child Lock | |
| ButtonPressed | Number | Button Pressed | |
| clean | Switch | Clean Mode | |
| countryCode | Number | Country Code | |
### Mi Air Humidifier 2 (<a name="zhimi-humidifier-cb1">zhimi.humidifier.cb1</a>) Channels
| Channel | Type | Description | Comment |
@ -2613,11 +2637,16 @@ e.g. `smarthome:send actionCommand 'upd_timer["1498595904821", "on"]'` would ena
|------------------|---------|-------------------------------------|------------|
| power | Switch | Power | |
| brightness | Dimmer | Brightness | |
| ambientBrightness | Number | Ambient Brightness | |
| delayoff | Number | Shutdown Timer | |
| colorTemperature | Number | Color Temperature | |
| colorMode | Number | Color Mode | |
| name | String | Name | |
| ambientPower | Switch | Ambient Power | |
| ambientColor | Color | Ambient Color | |
| ambientColorTemperature | Number | Ambient Color Temperature | |
| customScene | String | Set Scene | |
| ambientColorMode | Number | Ambient Color Mode | |
| nightlightBrightness | Number | Nightlight Brightness | |
### Yeelight LED Ceiling Lamp v5 (<a name="yeelink-light-ceiling5">yeelink.light.ceiling5</a>) Channels
@ -2878,11 +2907,16 @@ e.g. `smarthome:send actionCommand 'upd_timer["1498595904821", "on"]'` would ena
|------------------|---------|-------------------------------------|------------|
| power | Switch | Power | |
| brightness | Dimmer | Brightness | |
| ambientBrightness | Number | Ambient Brightness | |
| delayoff | Number | Shutdown Timer | |
| colorTemperature | Number | Color Temperature | |
| colorMode | Number | Color Mode | |
| name | String | Name | |
| ambientPower | Switch | Ambient Power | |
| ambientColor | Color | Ambient Color | |
| ambientColorTemperature | Number | Ambient Color Temperature | |
| customScene | String | Set Scene | |
| ambientColorMode | Number | Ambient Color Mode | |
| nightlightBrightness | Number | Nightlight Brightness | |
### Yeelight LED Ceiling Ambi Lamp (<a name="yeelink-light-ceiling10-ambi">yeelink.light.ceiling10.ambi</a>) Channels
@ -3405,6 +3439,32 @@ Number temperature "Temperature" (G_humidifier) {channel="miio:basic:humidifier:
Switch childlock "Child Lock" (G_humidifier) {channel="miio:basic:humidifier:childlock"}
```
### Mi Air Evaporative Humidifier 2 (zhimi.humidifier.ca4) item file lines
note: Autogenerated example. Replace the id (humidifier) in the channel with your own. Replace `basic` with `generic` in the thing UID depending on how your thing was discovered.
```java
Group G_humidifier "Mi Air Evaporative Humidifier 2" <status>
Switch power "Power" (G_humidifier) {channel="miio:basic:humidifier:power"}
Number mode "Mode" (G_humidifier) {channel="miio:basic:humidifier:mode"}
Number Fault "Humidifier Device Fault" (G_humidifier) {channel="miio:basic:humidifier:Fault"}
Number humidity "Humidity" (G_humidifier) {channel="miio:basic:humidifier:humidity"}
Number targetHumidity "Target Humidity" (G_humidifier) {channel="miio:basic:humidifier:targetHumidity"}
Number waterlevel "Water Level" (G_humidifier) {channel="miio:basic:humidifier:waterlevel"}
Number bright "LED Brightness" (G_humidifier) {channel="miio:basic:humidifier:bright"}
Switch buzzer "Buzzer Status" (G_humidifier) {channel="miio:basic:humidifier:buzzer"}
Switch dry "Dry" (G_humidifier) {channel="miio:basic:humidifier:dry"}
Number usedhours "Run Time" (G_humidifier) {channel="miio:basic:humidifier:usedhours"}
Number powerhours "Power Time" (G_humidifier) {channel="miio:basic:humidifier:powerhours"}
Number targetmotorspeed "Target Motor Speed" (G_humidifier) {channel="miio:basic:humidifier:targetmotorspeed"}
Number actualmotorspeed "Actual Motor Speed" (G_humidifier) {channel="miio:basic:humidifier:actualmotorspeed"}
Number temperature "Temperature" (G_humidifier) {channel="miio:basic:humidifier:temperature"}
Switch childlock "Child Lock" (G_humidifier) {channel="miio:basic:humidifier:childlock"}
Number ButtonPressed "Button Pressed" (G_humidifier) {channel="miio:basic:humidifier:ButtonPressed"}
Switch clean "Clean Mode" (G_humidifier) {channel="miio:basic:humidifier:clean"}
Number countryCode "Country Code" (G_humidifier) {channel="miio:basic:humidifier:countryCode"}
```
### Mi Air Humidifier 2 (zhimi.humidifier.cb1) item file lines
note: Autogenerated example. Replace the id (humidifier) in the channel with your own. Replace `basic` with `generic` in the thing UID depending on how your thing was discovered.
@ -5902,11 +5962,16 @@ note: Autogenerated example. Replace the id (ceiling4) in the channel with your
Group G_ceiling4 "Yeelight LED Ceiling Lamp v4" <status>
Switch power "Power" (G_ceiling4) {channel="miio:basic:ceiling4:power"}
Dimmer brightness "Brightness" (G_ceiling4) {channel="miio:basic:ceiling4:brightness"}
Number ambientBrightness "Ambient Brightness" (G_ceiling4) {channel="miio:basic:ceiling4:ambientBrightness"}
Number delayoff "Shutdown Timer" (G_ceiling4) {channel="miio:basic:ceiling4:delayoff"}
Number colorTemperature "Color Temperature" (G_ceiling4) {channel="miio:basic:ceiling4:colorTemperature"}
Number colorMode "Color Mode" (G_ceiling4) {channel="miio:basic:ceiling4:colorMode"}
String name "Name" (G_ceiling4) {channel="miio:basic:ceiling4:name"}
Switch ambientPower "Ambient Power" (G_ceiling4) {channel="miio:basic:ceiling4:ambientPower"}
Color ambientColor "Ambient Color" (G_ceiling4) {channel="miio:basic:ceiling4:ambientColor"}
Number ambientColorTemperature "Ambient Color Temperature" (G_ceiling4) {channel="miio:basic:ceiling4:ambientColorTemperature"}
String customScene "Set Scene" (G_ceiling4) {channel="miio:basic:ceiling4:customScene"}
Number ambientColorMode "Ambient Color Mode" (G_ceiling4) {channel="miio:basic:ceiling4:ambientColorMode"}
Number nightlightBrightness "Nightlight Brightness" (G_ceiling4) {channel="miio:basic:ceiling4:nightlightBrightness"}
```
@ -6227,11 +6292,16 @@ note: Autogenerated example. Replace the id (ceiling4) in the channel with your
Group G_ceiling4 "Yeelight LED Ceiling Ambi Lamp" <status>
Switch power "Power" (G_ceiling4) {channel="miio:basic:ceiling4:power"}
Dimmer brightness "Brightness" (G_ceiling4) {channel="miio:basic:ceiling4:brightness"}
Number ambientBrightness "Ambient Brightness" (G_ceiling4) {channel="miio:basic:ceiling4:ambientBrightness"}
Number delayoff "Shutdown Timer" (G_ceiling4) {channel="miio:basic:ceiling4:delayoff"}
Number colorTemperature "Color Temperature" (G_ceiling4) {channel="miio:basic:ceiling4:colorTemperature"}
Number colorMode "Color Mode" (G_ceiling4) {channel="miio:basic:ceiling4:colorMode"}
String name "Name" (G_ceiling4) {channel="miio:basic:ceiling4:name"}
Switch ambientPower "Ambient Power" (G_ceiling4) {channel="miio:basic:ceiling4:ambientPower"}
Color ambientColor "Ambient Color" (G_ceiling4) {channel="miio:basic:ceiling4:ambientColor"}
Number ambientColorTemperature "Ambient Color Temperature" (G_ceiling4) {channel="miio:basic:ceiling4:ambientColorTemperature"}
String customScene "Set Scene" (G_ceiling4) {channel="miio:basic:ceiling4:customScene"}
Number ambientColorMode "Ambient Color Mode" (G_ceiling4) {channel="miio:basic:ceiling4:ambientColorMode"}
Number nightlightBrightness "Nightlight Brightness" (G_ceiling4) {channel="miio:basic:ceiling4:nightlightBrightness"}
```

View File

@ -34,6 +34,7 @@ public enum MiIoDevices {
AIRMONITOR_S1("cgllc.airmonitor.s1", "Mi Air Quality Monitor S1", THING_TYPE_BASIC),
AIR_HUMIDIFIER_V1("zhimi.humidifier.v1", "Mi Air Humidifier", THING_TYPE_BASIC),
AIR_HUMIDIFIER_CA1("zhimi.humidifier.ca1", "Mi Air Humidifier", THING_TYPE_BASIC),
AIR_HUMIDIFIER_CA4("zhimi.humidifier.ca4", "Mi Air Evaporative Humidifier 2", THING_TYPE_BASIC),
AIR_HUMIDIFIER_CB1("zhimi.humidifier.cb1", "Mi Air Humidifier 2", THING_TYPE_BASIC),
AIR_HUMIDIFIER_MJJSQ("deerma.humidifier.mjjsq", "Mija Smart humidifier", THING_TYPE_BASIC),
AIR_PURIFIER1("zhimi.airpurifier.v1", "Mi Air Purifier v1", THING_TYPE_BASIC),

View File

@ -59,6 +59,16 @@ public class Conversions {
return new JsonPrimitive(value);
}
public static JsonElement tankLevel(JsonElement value12) {
// 127 without water tank. 120 = 100% water
if (value12.getAsInt() == 127) {
return new JsonPrimitive(-1);
} else {
double value = value12.getAsDouble();
return new JsonPrimitive(value / 1.2);
}
}
public static JsonElement execute(String transfortmation, JsonElement value) {
switch (transfortmation.toUpperCase()) {
case "YEELIGHTSCENEID":
@ -67,6 +77,8 @@ public class Conversions {
return secondsToHours(value);
case "/10":
return divideTen(value);
case "TANKLEVEL":
return tankLevel(value);
default:
LOGGER.debug("Transformation {} not found. Returning '{}'", transfortmation, value.toString());
return value;

View File

@ -111,6 +111,10 @@
<item-type>Switch</item-type>
<label>Eyecare Mode On/Off</label>
</channel-type>
<channel-type id="clean">
<item-type>Switch</item-type>
<label>Cleaning On/Off</label>
</channel-type>
<channel-type id="mode">
<item-type>String</item-type>
<label>Mode</label>
@ -220,7 +224,7 @@
<channel-type id="humidity">
<item-type>Number</item-type>
<label>Humidity</label>
<state pattern="%.1f" readOnly="true"/>
<state pattern="%.1f %%" readOnly="true"/>
</channel-type>
<channel-type id="pm25">
<item-type>Number</item-type>
@ -266,14 +270,19 @@
<state pattern="%.0f" readOnly="true"/>
</channel-type>
<channel-type id="usedhours">
<item-type>Number</item-type>
<item-type>Number:Time</item-type>
<label>Run Time</label>
<state pattern="%.0f" readOnly="true"/>
<state pattern="%.0f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="powerhours">
<item-type>Number:Time</item-type>
<label>Powered On Time</label>
<state pattern="%.0f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="motorspeed">
<item-type>Number</item-type>
<label>Motor Speed</label>
<state pattern="%.0f" readOnly="true"/>
<state pattern="%.0f rpm" readOnly="true"/>
</channel-type>
<channel-type id="filterlive">
<item-type>Number</item-type>
@ -304,6 +313,11 @@
<item-type>Number</item-type>
<label>Trans Level</label>
</channel-type>
<channel-type id="waterlevel">
<item-type>Number</item-type>
<label>Water Level</label>
<state pattern="%.0f %%"/>
</channel-type>
<channel-type id="dry">
<item-type>Switch</item-type>
<label>Dry</label>
@ -748,4 +762,57 @@
</options>
</state>
</channel-type>
<channel-type id="humidifierOperationMode">
<item-type>Number</item-type>
<label>Operation Mode</label>
<state>
<options>
<option value="0">Auto</option>
<option value="1">Low</option>
<option value="2">Medium</option>
<option value="3">High</option>
</options>
</state>
</channel-type>
<channel-type id="humidifierLedBrightness">
<item-type>Number</item-type>
<label>LED Brightness</label>
<state>
<options>
<option value="0">Off</option>
<option value="1">Dim</option>
<option value="2">Bright</option>
</options>
</state>
</channel-type>
<channel-type id="humidifierLastPressedButton">
<item-type>Number</item-type>
<label>Last Pressed Button</label>
<state>
<options>
<option value="0">No</option>
<option value="1">LED</option>
<option value="2">Power</option>
</options>
</state>
</channel-type>
<channel-type id="countryCode">
<item-type>Number</item-type>
<label>Country</label>
<state>
<options>
<option value="0">Unlocked</option>
<option value="1">US</option>
<option value="82">KR</option>
<option value="44">EU</option>
<option value="81">JP</option>
<option value="7">RU</option>
<option value="86">CN</option>
<option value="852">HK</option>
<option value="886">TW</option>
<option value="33">FR</option>
</options>
</state>
</channel-type>
</thing:thing-descriptions>

View File

@ -0,0 +1,273 @@
{
"deviceMapping": {
"id": [
"zhimi.humidifier.ca4"
],
"propertyMethod": "get_properties",
"maxProperties": 2,
"channels": [
{
"property": "power",
"siid": 2,
"piid": 1,
"friendlyName": "Power",
"channel": "power",
"channelType": "power",
"type": "Switch",
"refresh": true,
"actions": [
{
"command": "set_properties",
"parameterType": "ONOFFBOOL"
}
]
},
{
"property": "mode",
"siid": 2,
"piid": 5,
"friendlyName": "Mode",
"channel": "mode",
"channelType": "humidifierOperationMode",
"type": "Number",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "set_properties",
"parameterType": "NUMBER"
}
]
},
{
"property": "fault",
"siid": 2,
"piid": 2,
"friendlyName": "Humidifier Device Fault",
"channel": "Fault",
"channelType": "miot_uint8",
"type": "Number",
"refresh": true,
"actions": []
},
{
"property": "humidity",
"siid": 3,
"piid": 9,
"friendlyName": "Humidity",
"channel": "humidity",
"channelType": "humidity",
"type": "Number",
"refresh": true,
"ChannelGroup": "Status",
"actions": []
},
{
"property": "target_humidity",
"siid": 2,
"piid": 6,
"friendlyName": "Target Humidity",
"channel": "targetHumidity",
"channelType": "humidity",
"type": "Number",
"refresh": true,
"ChannelGroup": "Status",
"actions": [
{
"command": "set_properties",
"parameterType": "NUMBER"
}
]
},
{
"property": "water_level",
"siid": 2,
"piid": 7,
"friendlyName": "Water Level",
"channel": "waterlevel",
"channelType": "waterlevel",
"type": "Number",
"refresh": true,
"ChannelGroup": "Status",
"transformation": "tankLevel",
"actions": []
},
{
"property": "led_brightness",
"siid": 5,
"piid": 2,
"friendlyName": "LED Brightness",
"channel": "bright",
"channelType": "humidifierLedBrightness",
"type": "Number",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "set_properties",
"parameterType": "NUMBER"
}
]
},
{
"property": "buzzer",
"siid": 4,
"piid": 1,
"friendlyName": "Buzzer Status",
"channel": "buzzer",
"channelType": "buzzer",
"type": "Switch",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "set_properties",
"parameterType": "ONOFFBOOL"
}
]
},
{
"property": "dry",
"siid": 2,
"piid": 8,
"friendlyName": "Dry",
"channel": "dry",
"channelType": "dry",
"type": "Switch",
"refresh": true,
"ChannelGroup": "Status",
"actions": [
{
"command": "set_properties",
"parameterType": "ONOFFBOOL"
}
]
},
{
"property": "use_time",
"siid": 2,
"piid": 9,
"friendlyName": "Run Time",
"channel": "usedhours",
"channelType": "usedhours",
"type": "Number:Time",
"refresh": true,
"transformation": "SecondsToHours",
"ChannelGroup": "Status",
"unit": "hours",
"actions": []
},
{
"property": "power_time",
"siid": 7,
"piid": 3,
"friendlyName": "Power Time",
"channel": "powerhours",
"channelType": "powerhours",
"type": "Number:Time",
"refresh": true,
"transformation": "SecondsToHours",
"ChannelGroup": "Status",
"unit": "hours",
"actions": []
},
{
"property": "speed_level",
"siid": 2,
"piid": 11,
"friendlyName": "Target Motor Speed",
"channel": "targetmotorspeed",
"channelType": "motorspeed",
"type": "Number",
"refresh": true,
"ChannelGroup": "Status",
"actions": []
},
{
"property": "actual_speed",
"siid": 7,
"piid": 1,
"friendlyName": "Actual Motor Speed",
"channel": "actualmotorspeed",
"channelType": "motorspeed",
"type": "Number",
"refresh": true,
"ChannelGroup": "Status",
"actions": []
},
{
"property": "temp_dec",
"siid": 3,
"piid": 7,
"friendlyName": "Temperature",
"channel": "temperature",
"channelType": "temperatureC",
"type": "Number:Temperature",
"refresh": true,
"ChannelGroup": "Status",
"actions": []
},
{
"property": "child_lock",
"siid": 6,
"piid": 1,
"friendlyName": "Child Lock",
"channel": "childlock",
"channelType": "childlock",
"type": "Switch",
"refresh": true,
"ChannelGroup": "Status",
"actions": [
{
"command": "set_properties",
"parameterType": "ONOFFBOOL"
}
]
},
{
"property": "button_pressed",
"siid": 2,
"piid": 10,
"friendlyName": "Button Pressed",
"channel": "ButtonPressed",
"channelType": "humidifierLastPressedButton",
"type": "Number",
"refresh": true,
"actions": []
},
{
"property": "clean",
"siid": 7,
"piid": 5,
"friendlyName": "Clean Mode",
"channel": "clean",
"channelType": "clean",
"type": "Switch",
"refresh": true,
"actions": [
{
"command": "set_properties",
"parameterType": "ONOFFBOOL"
}
]
},
{
"property": "country_code",
"siid": 7,
"piid": 4,
"friendlyName": "Country Code",
"channel": "countryCode",
"channelType": "countryCode",
"type": "Number",
"refresh": true,
"ChannelGroup": "Status",
"actions": [
{
"command": "set_properties",
"parameterType": "NUMBER"
}
]
}
]
}
}