From 74800bd782a78f71accbbe17e633826c9d22e3e5 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 14 Sep 2021 16:57:57 +0200 Subject: [PATCH] [miio] add support for Smartmi Fresh Air System (zhimi.airfresh.va4&va2) (#11164) * [miio] add support for Smartmi Fresh Air System (zhimi.airfresh.va4&va2) Add support for * Smartmi Fresh Air System (zhimi.airfresh.va4) * Smartmi Fresh Air System (zhimi.airfresh.va2) Signed-off-by: Marcel Verpaalen * [miio] fix 2 commands and add some formatting Signed-off-by: Marcel Verpaalen * [miio] fix copy paste error Signed-off-by: Marcel Verpaalen * [miio] airfresh channelnames Signed-off-by: Marcel Verpaalen * [miio] merge & count devices Signed-off-by: Marcel Verpaalen --- bundles/org.openhab.binding.miio/README.md | 84 ++++++ .../binding/miio/internal/MiIoDevices.java | 2 + .../database/zhimi.airfresh.va4.json | 268 ++++++++++++++++++ 3 files changed, 354 insertions(+) create mode 100644 bundles/org.openhab.binding.miio/src/main/resources/database/zhimi.airfresh.va4.json diff --git a/bundles/org.openhab.binding.miio/README.md b/bundles/org.openhab.binding.miio/README.md index 8662022cbc9c5..038c6d2abc10f 100644 --- a/bundles/org.openhab.binding.miio/README.md +++ b/bundles/org.openhab.binding.miio/README.md @@ -460,6 +460,8 @@ Currently the miio binding supports more than 300 different models. | Mi Water Purifier v2 | miio:basic | [yunmi.waterpurifier.v2](#yunmi-waterpurifier-v2) | Yes | Experimental support. Please report back if all channels are functional. Preferably share the debug log of property refresh and command responses | | Mi Water Purifier (Under sink) v3 | miio:basic | [yunmi.waterpurifier.v3](#yunmi-waterpurifier-v3) | Yes | Experimental support. Please report back if all channels are functional. Preferably share the debug log of property refresh and command responses | | Mi Water Purifier v4 | miio:basic | [yunmi.waterpurifier.v4](#yunmi-waterpurifier-v4) | Yes | Experimental support. Please report back if all channels are functional. Preferably share the debug log of property refresh and command responses | +| Smartmi Ventilation System | miio:basic | [zhimi.airfresh.va2](#zhimi-airfresh-va2) | Yes | | +| Smartmi Fresh Air System (Heating) | miio:basic | [zhimi.airfresh.va4](#zhimi-airfresh-va4) | Yes | | | Mi PM2.5 Air Quality Monitor | miio:basic | [zhimi.airmonitor.v1](#zhimi-airmonitor-v1) | Yes | | | Mi Air Purifier 2 (mini) | miio:basic | [zhimi.airpurifier.m1](#zhimi-airpurifier-m1) | Yes | | | Mi Air Purifier 2 | miio:basic | [zhimi.airpurifier.m2](#zhimi-airpurifier-m2) | Yes | | @@ -4232,6 +4234,44 @@ Note, not all the values need to be in the json file, e.g. a subset of the param | tds_out_avg | Number | Average TDS out | | | lightMode | Number | Light Mode | Value mapping `["0"="Simple Mode","1"="Special Mode"]` | +### Smartmi Ventilation System (zhimi.airfresh.va2) Channels + +| Channel | Type | Description | Comment | +|----------------------|----------------------|------------------------------------------|------------| +| power | Switch | Power | | +| heater | Switch | Heater | | +| mode | String | Mode | Value mapping `["interval"="Interval","silent"="Night","low"="1","middle"="2","strong"="3","auto"="Auto"]` | +| humidity | Number:Dimensionless | Humidity | | +| co2 | Number:Dimensionless | CO2 | | +| childLock | Switch | Child Lock | | +| buzzer | Switch | Buzzer | | +| aqi | Number | Air Quality Index | | +| averageaqi | Number | Average Air Quality Index | | +| filterhours | Number:Time | Filter Hours used | | +| usedhours | Number:Time | Run Time | | +| motorspeed | Number | Motor Speed | | +| led_level | Number | Led - Brightness | Value mapping `["0"="High","1"="Low","2"="Idle"]` | +| temperature | Number:Temperature | Temperature | | + +### Smartmi Fresh Air System (Heating) (zhimi.airfresh.va4) Channels + +| Channel | Type | Description | Comment | +|----------------------|----------------------|------------------------------------------|------------| +| power | Switch | Power | | +| heater | Switch | Heater | | +| mode | String | Mode | Value mapping `["interval"="Interval","silent"="Night","low"="1","middle"="2","strong"="3","auto"="Auto"]` | +| humidity | Number:Dimensionless | Humidity | | +| co2 | Number:Dimensionless | CO2 | | +| childLock | Switch | Child Lock | | +| buzzer | Switch | Buzzer | | +| aqi | Number | Air Quality Index | | +| averageaqi | Number | Average Air Quality Index | | +| filterhours | Number:Time | Filter Hours used | | +| usedhours | Number:Time | Run Time | | +| motorspeed | Number | Motor Speed | | +| led_level | Number | Led - Brightness | Value mapping `["0"="High","1"="Low","2"="Idle"]` | +| temperature | Number:Temperature | Temperature | | + ### Mi PM2.5 Air Quality Monitor (zhimi.airmonitor.v1) Channels | Channel | Type | Description | Comment | @@ -9567,6 +9607,50 @@ Number tds_out_avg "Average TDS out" (G_waterpurifier) {channel="miio:basic:wate Number lightMode "Light Mode" (G_waterpurifier) {channel="miio:basic:waterpurifier:lightMode"} ``` +### Smartmi Ventilation System (zhimi.airfresh.va2) 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. + +``` +Group G_airfresh "Smartmi Ventilation System" +Switch power "Power" (G_airfresh) {channel="miio:basic:airfresh:power"} +Switch heater "Heater" (G_airfresh) {channel="miio:basic:airfresh:heater"} +String mode "Mode" (G_airfresh) {channel="miio:basic:airfresh:mode"} +Number:Dimensionless humidity "Humidity" (G_airfresh) {channel="miio:basic:airfresh:humidity"} +Number:Dimensionless co2 "CO2" (G_airfresh) {channel="miio:basic:airfresh:co2"} +Switch childLock "Child Lock" (G_airfresh) {channel="miio:basic:airfresh:childLock"} +Switch buzzer "Buzzer" (G_airfresh) {channel="miio:basic:airfresh:buzzer"} +Number aqi "Air Quality Index" (G_airfresh) {channel="miio:basic:airfresh:aqi"} +Number averageaqi "Average Air Quality Index" (G_airfresh) {channel="miio:basic:airfresh:averageaqi"} +Number:Time filterhours "Filter Hours used" (G_airfresh) {channel="miio:basic:airfresh:filterhours"} +Number:Time usedhours "Run Time" (G_airfresh) {channel="miio:basic:airfresh:usedhours"} +Number motorspeed "Motor Speed" (G_airfresh) {channel="miio:basic:airfresh:motorspeed"} +Number led_level "Led - Brightness" (G_airfresh) {channel="miio:basic:airfresh:led_level"} +Number:Temperature temperature "Temperature" (G_airfresh) {channel="miio:basic:airfresh:temperature"} +``` + +### Smartmi Fresh Air System (Heating) (zhimi.airfresh.va4) 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. + +``` +Group G_airfresh "Smartmi Fresh Air System (Heating)" +Switch power "Power" (G_airfresh) {channel="miio:basic:airfresh:power"} +Switch heater "Heater" (G_airfresh) {channel="miio:basic:airfresh:heater"} +String mode "Mode" (G_airfresh) {channel="miio:basic:airfresh:mode"} +Number:Dimensionless humidity "Humidity" (G_airfresh) {channel="miio:basic:airfresh:humidity"} +Number:Dimensionless co2 "CO2" (G_airfresh) {channel="miio:basic:airfresh:co2"} +Switch childLock "Child Lock" (G_airfresh) {channel="miio:basic:airfresh:childLock"} +Switch buzzer "Buzzer" (G_airfresh) {channel="miio:basic:airfresh:buzzer"} +Number aqi "Air Quality Index" (G_airfresh) {channel="miio:basic:airfresh:aqi"} +Number averageaqi "Average Air Quality Index" (G_airfresh) {channel="miio:basic:airfresh:averageaqi"} +Number:Time filterhours "Filter Hours used" (G_airfresh) {channel="miio:basic:airfresh:filterhours"} +Number:Time usedhours "Run Time" (G_airfresh) {channel="miio:basic:airfresh:usedhours"} +Number motorspeed "Motor Speed" (G_airfresh) {channel="miio:basic:airfresh:motorspeed"} +Number led_level "Led - Brightness" (G_airfresh) {channel="miio:basic:airfresh:led_level"} +Number:Temperature temperature "Temperature" (G_airfresh) {channel="miio:basic:airfresh:temperature"} +``` + ### Mi PM2.5 Air Quality Monitor (zhimi.airmonitor.v1) item file lines note: Autogenerated example. Replace the id (airmonitor) in the channel with your own. Replace `basic` with `generic` in the thing UID depending on how your thing was discovered. diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoDevices.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoDevices.java index f40350b3a0b37..b9d5ddab06730 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoDevices.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoDevices.java @@ -342,6 +342,8 @@ public enum MiIoDevices { YUNMI_WATERPURIFIER_V2("yunmi.waterpurifier.v2", "Mi Water Purifier v2", THING_TYPE_BASIC), YUNMI_WATERPURIFIER_V3("yunmi.waterpurifier.v3", "Mi Water Purifier (Under sink) v3", THING_TYPE_BASIC), YUNMI_WATERPURIFIER_V4("yunmi.waterpurifier.v4", "Mi Water Purifier v4", THING_TYPE_BASIC), + ZHIMI_AIRFRESH_VA2("zhimi.airfresh.va2", "Smartmi Ventilation System", THING_TYPE_BASIC), + ZHIMI_AIRFRESH_VA4("zhimi.airfresh.va4", "Smartmi Fresh Air System (Heating)", THING_TYPE_BASIC), ZHIMI_AIRMONITOR_V1("zhimi.airmonitor.v1", "Mi PM2.5 Air Quality Monitor", THING_TYPE_BASIC), ZHIMI_AIRPURIFIER_M1("zhimi.airpurifier.m1", "Mi Air Purifier 2 (mini)", THING_TYPE_BASIC), ZHIMI_AIRPURIFIER_M2("zhimi.airpurifier.m2", "Mi Air Purifier 2", THING_TYPE_BASIC), diff --git a/bundles/org.openhab.binding.miio/src/main/resources/database/zhimi.airfresh.va4.json b/bundles/org.openhab.binding.miio/src/main/resources/database/zhimi.airfresh.va4.json new file mode 100644 index 0000000000000..e888cb91537aa --- /dev/null +++ b/bundles/org.openhab.binding.miio/src/main/resources/database/zhimi.airfresh.va4.json @@ -0,0 +1,268 @@ +{ + "deviceMapping": { + "id": [ + "zhimi.airfresh.va2", + "zhimi.airfresh.va4" + ], + "propertyMethod": "get_prop", + "maxProperties": 2, + "channels": [ + { + "property": "power", + "friendlyName": "Power", + "channel": "power", + "type": "Switch", + "refresh": true, + "actions": [ + { + "command": "set_power", + "parameterType": "ONOFF" + } + ], + "category": "switch", + "tags": [ + "Switch" + ] + }, + { + "property": "ptc_state", + "friendlyName": "Heater", + "channel": "heater", + "type": "Switch", + "refresh": true, + "actions": [ + { + "command": "set_ptc_state", + "parameterType": "ONOFF" + } + ] + }, + { + "property": "mode", + "friendlyName": "Mode", + "channel": "mode", + "type": "String", + "stateDescription": { + "options": [ + { + "value": "interval", + "label": "Interval" + }, + { + "value": "silent", + "label": "Night" + }, + { + "value": "low", + "label": "1" + }, + { + "value": "middle", + "label": "2" + }, + { + "value": "strong", + "label": "3" + }, + { + "value": "auto", + "label": "Auto" + } + ] + }, + "refresh": true, + "actions": [ + { + "command": "set_mode", + "parameterType": "STRING" + } + ], + "tags": [ + "Control" + ], + "readmeComment": "Value mapping `[\"interval\"\u003d\"Interval\",\"silent\"\u003d\"Night\",\"low\"\u003d\"1\",\"middle\"\u003d\"2\",\"strong\"\u003d\"3\",\"auto\"\u003d\"Auto\"]`" + }, + { + "property": "humidity", + "friendlyName": "Humidity", + "channel": "humidity", + "type": "Number:Dimensionless", + "unit": "PERCENT", + "refresh": true, + "ChannelGroup": "Status", + "actions": [], + "category": "humidity", + "tags": [ + "Measurement", + "Humidity" + ] + }, + { + "property": "co2", + "friendlyName": "CO2", + "channel": "co2", + "type": "Number:Dimensionless", + "unit": "ppm", + "stateDescription": { + "minimum": 0, + "maximum": 5000, + "step": 1, + "pattern": "%.0f %unit%", + "readOnly": true + }, + "refresh": true, + "ChannelGroup": "Status", + "actions": [], + "category": "co2", + "tags": [ + "Measurement", + "CO2" + ] + }, + { + "property": "child_lock", + "friendlyName": "Child Lock", + "channel": "childLock", + "type": "Switch", + "refresh": true, + "actions": [ + { + "command": "set_child_lock", + "parameterType": "ONOFFBOOL" + } + ] + }, + { + "property": "buzzer", + "friendlyName": "Buzzer", + "channel": "buzzer", + "type": "Switch", + "refresh": true, + "ChannelGroup": "actions", + "actions": [ + { + "command": "set_buzzer", + "parameterType": "ONOFF" + } + ] + }, + { + "property": "aqi", + "friendlyName": "Air Quality Index", + "channel": "aqi", + "type": "Number", + "stateDescription": { + "pattern": "%.0f", + "readOnly": true + }, + "refresh": true, + "ChannelGroup": "Status", + "actions": [], + "tags": [ + "Measurement" + ] + }, + { + "property": "average_aqi", + "friendlyName": "Average Air Quality Index", + "channel": "averageaqi", + "type": "Number", + "stateDescription": { + "pattern": "%.0f", + "readOnly": true + }, + "refresh": true, + "ChannelGroup": "Status", + "actions": [], + "tags": [ + "Measurement" + ] + }, + { + "property": "f1_hour_used", + "friendlyName": "Filter Hours used", + "channel": "filterhours", + "type": "Number:Time", + "unit": "hours", + "refresh": true, + "ChannelGroup": "Status", + "actions": [], + "category": "time" + }, + { + "property": "use_time", + "friendlyName": "Run Time", + "channel": "usedhours", + "type": "Number:Time", + "unit": "hours", + "refresh": true, + "transformation": "SecondsToHours", + "ChannelGroup": "Status", + "actions": [], + "category": "time" + }, + { + "property": "motor1_speed", + "friendlyName": "Motor Speed", + "channel": "motorspeed", + "type": "Number", + "stateDescription": { + "pattern": "%.0f rpm", + "readOnly": true + }, + "refresh": true, + "ChannelGroup": "Status", + "actions": [] + }, + { + "property": "led_level", + "friendlyName": "Led - Brightness", + "channel": "led_level", + "type": "Number", + "stateDescription": { + "options": [ + { + "value": "0", + "label": "High" + }, + { + "value": "1", + "label": "Low" + }, + { + "value": "2", + "label": "Idle" + } + ] + }, + "refresh": true, + "actions": [ + { + "command": "set_led_level", + "parameterType": "NUMBER" + } + ], + "readmeComment": "Value mapping `[\"0\"\u003d\"High\",\"1\"\u003d\"Low\",\"2\"\u003d\"Idle\"]`" + }, + { + "property": "temp_dec", + "friendlyName": "Temperature", + "channel": "temperature", + "type": "Number:Temperature", + "unit": "CELSIUS", + "stateDescription": { + "pattern": "%.1f %unit%", + "readOnly": true + }, + "refresh": true, + "ChannelGroup": "Status", + "actions": [], + "category": "temperature", + "tags": [ + "Measurement", + "Temperature" + ] + } + ] + } +}