]> git.basschouten.com Git - openhab-addons.git/commitdiff
[miio] add support for deerma Humidifier (#10181)
authorMarcel <marcel@verpaalen.com>
Thu, 25 Feb 2021 18:25:39 +0000 (19:25 +0100)
committerGitHub <noreply@github.com>
Thu, 25 Feb 2021 18:25:39 +0000 (10:25 -0800)
* [miio] deerma Humidifier

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
bundles/org.openhab.binding.miio/README.md
bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoDevices.java
bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/CommandParameterType.java
bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java
bundles/org.openhab.binding.miio/src/main/resources/database/deerma.humidifier.jsq1.json [new file with mode: 0644]
bundles/org.openhab.binding.miio/src/main/resources/database/deerma.humidifier.mjjsq.json [new file with mode: 0644]

index 806207bbf4f393bd241e94bea4329b81d869ecef..4a328b228d656556415e4605e537b7f73d6109da 100644 (file)
@@ -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     |
 |------------------------------|------------------|------------------------|-----------|------------|
@@ -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       |            |
@@ -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    |
@@ -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.
index b3c224629f294e8ac08b4480a46cd49380badd82..1125f9e5236dd94e4139a58dbe26f1eca1813336 100644 (file)
@@ -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),
index c2a26b77012d546c535ca3a733640ccebbdfcaf8..7a379a581dda9a84230247a25c9468885548def8 100644 (file)
@@ -27,6 +27,7 @@ public enum CommandParameterType {
     ONOFFPARA("onoffpara"),
     ONOFFBOOL("onoffbool"),
     ONOFFBOOLSTRING("onoffboolstring"),
+    ONOFFNUMBER("onoffnumber"),
     STRING("string"),
     CUSTOMSTRING("customstring"),
     NUMBER("number"),
index bb7731f477ef22c22bd775c8ca0765ef1e5d5a18..0f1d8ae748a7fa541af8eff27d41272390449fbe 100644 (file)
@@ -196,6 +196,8 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
                             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());
@@ -570,8 +572,13 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
                     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());
diff --git a/bundles/org.openhab.binding.miio/src/main/resources/database/deerma.humidifier.jsq1.json b/bundles/org.openhab.binding.miio/src/main/resources/database/deerma.humidifier.jsq1.json
new file mode 100644 (file)
index 0000000..2a8a2a5
--- /dev/null
@@ -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"
+                                       }
+                               ]
+                       }
+               ]
+       }
+}
diff --git a/bundles/org.openhab.binding.miio/src/main/resources/database/deerma.humidifier.mjjsq.json b/bundles/org.openhab.binding.miio/src/main/resources/database/deerma.humidifier.mjjsq.json
new file mode 100644 (file)
index 0000000..d3ce630
--- /dev/null
@@ -0,0 +1,146 @@
+{
+       "deviceMapping": {
+               "id": [
+                       "deerma.humidifier.mjjsq",
+                       "deerma.humidifier.jsq"
+               ],
+               "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": []
+                       }
+               ]
+       }
+}