Skip to content

Commit

Permalink
[miio] add support for deerma Humidifier (openhab#10181)
Browse files Browse the repository at this point in the history
* [miio] deerma Humidifier

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
  • Loading branch information
marcelrv authored Feb 25, 2021
1 parent aa70862 commit 01818f2
Show file tree
Hide file tree
Showing 6 changed files with 402 additions and 3 deletions.
87 changes: 86 additions & 1 deletion bundles/org.openhab.binding.miio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ This will change the communication method and the Mi IO binding can communicate

# Mi IO Devices

Currently the miio binding supports more than 260 different models.
Currently the miio binding supports more than 270 different models.

| Device | ThingType | Device Model | Supported | Remark |
|------------------------------|------------------|------------------------|-----------|------------|
Expand All @@ -197,6 +197,8 @@ Currently the miio binding supports more than 260 different models.
| Mi IH Pressure Rice Cooker | miio:unsupported | chunmi.cooker.press1 | No | |
| Mi IH Pressure Rice Cooker | miio:unsupported | chunmi.cooker.press2 | No | |
| Gosund Smart Plug | miio:basic | [cuco.plug.cp1](#cuco-plug-cp1) | Yes | |
| Mi Smart Antibacterial Humidifier | miio:basic | [deerma.humidifier.jsq](#deerma-humidifier-jsq) | Yes | |
| Mi S Smart humidifer | miio:basic | [deerma.humidifier.jsq1](#deerma-humidifier-jsq1) | Yes | |
| Mi Smart Humidifier | miio:basic | [deerma.humidifier.mjjsq](#deerma-humidifier-mjjsq) | Yes | |
| Mi Fresh Air Ventilator A1-150 | miio:basic | [dmaker.airfresh.a1](#dmaker-airfresh-a1) | Yes | |
| Mi Fresh Air Ventilator | miio:basic | [dmaker.airfresh.t2017](#dmaker-airfresh-t2017) | Yes | |
Expand Down Expand Up @@ -610,6 +612,43 @@ e.g. `openhab:send actionCommand 'upd_timer["1498595904821", "on"]'` would enabl
| SerialNumber | String | Device Information-Device Serial Number | |
| On | Switch | Switch-Switch Status | |

### Mi Smart Antibacterial Humidifier (<a name="deerma-humidifier-jsq">deerma.humidifier.jsq</a>) Channels

| Channel | Type | Description | Comment |
|----------------------|----------------------|------------------------------------------|------------|
| power | Switch | Power | |
| mode | Number | Mode | |
| humidity | Number:Dimensionless | Humidity | |
| humidity_set | Number:Dimensionless | Humidity Setting | |
| led | Switch | LED indicator Light | |
| sound | Switch | Notification Sounds | |
| watertankstatus | Number | Watertank Status | |

### Mi S Smart humidifer (<a name="deerma-humidifier-jsq1">deerma.humidifier.jsq1</a>) Channels

| Channel | Type | Description | Comment |
|----------------------|----------------------|------------------------------------------|------------|
| power | Switch | Power | |
| mode | Number | Mode | |
| humidity | Number:Dimensionless | Humidity | |
| humidity_set | Number:Dimensionless | Humidity Setting | |
| led | Switch | LED indicator Light | |
| sound | Switch | Notification Sounds | |
| watertankstatus | Number | Watertank Status | |
| wet_and_protect | Switch | Wet and Protect | |

### Mi Smart Humidifier (<a name="deerma-humidifier-mjjsq">deerma.humidifier.mjjsq</a>) Channels

| Channel | Type | Description | Comment |
|----------------------|----------------------|------------------------------------------|------------|
| power | Switch | Power | |
| mode | Number | Mode | |
| humidity | Number:Dimensionless | Humidity | |
| humidity_set | Number:Dimensionless | Humidity Setting | |
| led | Switch | LED indicator Light | |
| sound | Switch | Notification Sounds | |
| watertankstatus | Number | Watertank Status | |

### Mi Fresh Air Ventilator A1-150 (<a name="dmaker-airfresh-a1">dmaker.airfresh.a1</a>) Channels

| Channel | Type | Description | Comment |
Expand Down Expand Up @@ -4722,6 +4761,52 @@ String SerialNumber "Device Information-Device Serial Number" (G_plug) {channel=
Switch On "Switch-Switch Status" (G_plug) {channel="miio:basic:plug:On"}
```

### Mi Smart Antibacterial Humidifier (deerma.humidifier.jsq) 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.

```
Group G_humidifier "Mi Smart Antibacterial Humidifier" <status>
Switch power "Power" (G_humidifier) {channel="miio:basic:humidifier:power"}
Number mode "Mode" (G_humidifier) {channel="miio:basic:humidifier:mode"}
Number:Dimensionless humidity "Humidity" (G_humidifier) {channel="miio:basic:humidifier:humidity"}
Number:Dimensionless humidity_set "Humidity Setting" (G_humidifier) {channel="miio:basic:humidifier:humidity_set"}
Switch led "LED indicator Light" (G_humidifier) {channel="miio:basic:humidifier:led"}
Switch sound "Notification Sounds" (G_humidifier) {channel="miio:basic:humidifier:sound"}
Number watertankstatus "Watertank Status" (G_humidifier) {channel="miio:basic:humidifier:watertankstatus"}
```

### Mi S Smart humidifer (deerma.humidifier.jsq1) 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.

```
Group G_humidifier "Mi S Smart humidifer " <status>
Switch power "Power" (G_humidifier) {channel="miio:basic:humidifier:power"}
Number mode "Mode" (G_humidifier) {channel="miio:basic:humidifier:mode"}
Number:Dimensionless humidity "Humidity" (G_humidifier) {channel="miio:basic:humidifier:humidity"}
Number:Dimensionless humidity_set "Humidity Setting" (G_humidifier) {channel="miio:basic:humidifier:humidity_set"}
Switch led "LED indicator Light" (G_humidifier) {channel="miio:basic:humidifier:led"}
Switch sound "Notification Sounds" (G_humidifier) {channel="miio:basic:humidifier:sound"}
Number watertankstatus "Watertank Status" (G_humidifier) {channel="miio:basic:humidifier:watertankstatus"}
Switch wet_and_protect "Wet and Protect" (G_humidifier) {channel="miio:basic:humidifier:wet_and_protect"}
```

### Mi Smart Humidifier (deerma.humidifier.mjjsq) 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.

```
Group G_humidifier "Mi Smart Humidifier" <status>
Switch power "Power" (G_humidifier) {channel="miio:basic:humidifier:power"}
Number mode "Mode" (G_humidifier) {channel="miio:basic:humidifier:mode"}
Number:Dimensionless humidity "Humidity" (G_humidifier) {channel="miio:basic:humidifier:humidity"}
Number:Dimensionless humidity_set "Humidity Setting" (G_humidifier) {channel="miio:basic:humidifier:humidity_set"}
Switch led "LED indicator Light" (G_humidifier) {channel="miio:basic:humidifier:led"}
Switch sound "Notification Sounds" (G_humidifier) {channel="miio:basic:humidifier:sound"}
Number watertankstatus "Watertank Status" (G_humidifier) {channel="miio:basic:humidifier:watertankstatus"}
```

### Mi Fresh Air Ventilator A1-150 (dmaker.airfresh.a1) item file lines

note: Autogenerated example. Replace the id (airfresh) in the channel with your own. Replace `basic` with `generic` in the thing UID depending on how your thing was discovered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public enum MiIoDevices {
CHUNMI_COOKER_PRESS1("chunmi.cooker.press1", "Mi IH Pressure Rice Cooker", THING_TYPE_UNSUPPORTED),
CHUNMI_COOKER_PRESS2("chunmi.cooker.press2", "Mi IH Pressure Rice Cooker", THING_TYPE_UNSUPPORTED),
CUCO_PLUG_CP1("cuco.plug.cp1", "Gosund Smart Plug", THING_TYPE_BASIC),
DEERMA_HUMIDIFIER_JSQ("deerma.humidifier.jsq", "Mi Smart Antibacterial Humidifier", THING_TYPE_BASIC),
DEERMA_HUMIDIFIER_JSQ1("deerma.humidifier.jsq1", "Mi S Smart humidifer ", THING_TYPE_BASIC),
DEERMA_HUMIDIFIER_MJJSQ("deerma.humidifier.mjjsq", "Mi Smart Humidifier", THING_TYPE_BASIC),
DMAKER_AIRFRESH_A1("dmaker.airfresh.a1", "Mi Fresh Air Ventilator A1-150", THING_TYPE_BASIC),
DMAKER_AIRFRESH_T2017("dmaker.airfresh.t2017", "Mi Fresh Air Ventilator", THING_TYPE_BASIC),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum CommandParameterType {
ONOFFPARA("onoffpara"),
ONOFFBOOL("onoffbool"),
ONOFFBOOLSTRING("onoffboolstring"),
ONOFFNUMBER("onoffnumber"),
STRING("string"),
CUSTOMSTRING("customstring"),
NUMBER("number"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public void handleCommand(ChannelUID channelUID, Command receivedCommand) {
value = new JsonPrimitive(boolCommand);
} else if (paramType == CommandParameterType.ONOFFBOOLSTRING) {
value = new JsonPrimitive(command == OnOffType.ON ? "true" : "false");
} else if (paramType == CommandParameterType.ONOFFNUMBER) {
value = new JsonPrimitive(command == OnOffType.ON ? 1 : 0);
}
} else if (command instanceof DecimalType) {
value = new JsonPrimitive(((DecimalType) command).toBigDecimal());
Expand Down Expand Up @@ -570,8 +572,13 @@ private void updateChannel(@Nullable MiIoBasicChannel basicChannel, String param
updateState(basicChannel.getChannel(), new StringType(val.getAsString()));
break;
case "switch":
updateState(basicChannel.getChannel(), val.getAsString().toLowerCase().equals("on")
|| val.getAsString().toLowerCase().equals("true") ? OnOffType.ON : OnOffType.OFF);
if (val.getAsJsonPrimitive().isNumber()) {
updateState(basicChannel.getChannel(), val.getAsInt() > 0 ? OnOffType.ON : OnOffType.OFF);
} else {
String strVal = val.getAsString().toLowerCase();
updateState(basicChannel.getChannel(),
strVal.equals("on") || strVal.equals("true") ? OnOffType.ON : OnOffType.OFF);
}
break;
case "color":
Color rgb = new Color(val.getAsInt());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"deviceMapping": {
"id": [
"deerma.humidifier.jsq1"
],
"maxProperties": 1,
"channels": [
{
"property": "OnOff_State",
"friendlyName": "Power",
"channel": "power",
"type": "Switch",
"refresh": true,
"actions": [
{
"command": "Set_OnOff",
"parameterType": "ONOFFNUMBER"
}
],
"category": "switch",
"tags": [
"Switch"
]
},
{
"property": "Humidifier_Gear",
"friendlyName": "Mode",
"channel": "mode",
"type": "Number",
"stateDescription": {
"options": [
{
"value": "1",
"label": "Low"
},
{
"value": "2",
"label": "Medium"
},
{
"value": "3",
"label": "High"
},
{
"value": "4",
"label": "Humidity "
}
]
},
"refresh": true,
"actions": [
{
"command": "Set_HumidifierGears",
"parameterType": "NUMBER"
}
]
},
{
"property": "Humidity_Value",
"friendlyName": "Humidity",
"channel": "humidity",
"type": "Number:Dimensionless",
"unit": "PERCENT",
"stateDescription": {
"minimum": 0,
"maximum": 100,
"step": 1,
"pattern": "%.0f %unit%",
"readOnly": true
},
"refresh": true,
"actions": [],
"category": "humidity",
"tags": [
"Measurement",
"Humidity"
]
},
{
"property": "HumiSet_Value",
"friendlyName": "Humidity Setting",
"channel": "humidity_set",
"type": "Number:Dimensionless",
"unit": "PERCENT",
"stateDescription": {
"minimum": 0,
"maximum": 100,
"step": 1,
"pattern": "%.0f %unit%",
"readOnly": false
},
"refresh": true,
"actions": [
{
"command": "Set_HumiValue",
"parameterType": "NUMBER"
}
],
"category": "humidity",
"tags": [
"SetPoint",
"Humidity"
]
},
{
"property": "Led_State",
"friendlyName": "LED indicator Light",
"channel": "led",
"type": "Switch",
"refresh": true,
"actions": [
{
"command": "SetLedState",
"parameterType": "ONOFFNUMBER"
}
]
},
{
"property": "TipSound_State",
"friendlyName": "Notification Sounds",
"channel": "sound",
"type": "Switch",
"refresh": true,
"actions": [
{
"command": "SetTipSound_Status",
"parameterType": "ONOFFNUMBER"
}
]
},
{
"property": "watertankstatus",
"friendlyName": "Watertank Status",
"channel": "watertankstatus",
"type": "Number",
"stateDescription": {
"pattern": "%.0f",
"readOnly": true
},
"refresh": true,
"actions": []
},
{
"property": "wet_and_protect",
"friendlyName": "Wet and Protect",
"channel": "wet_and_protect",
"type": "Switch",
"refresh": true,
"actions": [
{
"command": "Set_wet_and_protect",
"parameterType": "ONOFFNUMBER"
}
]
}
]
}
}
Loading

0 comments on commit 01818f2

Please sign in to comment.