[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

File diff suppressed because it is too large Load Diff

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"
}
]
}
]
}
}