diff --git a/bundles/org.openhab.binding.miio/README.md b/bundles/org.openhab.binding.miio/README.md index 648b7049a..f50bbc3cb 100644 --- a/bundles/org.openhab.binding.miio/README.md +++ b/bundles/org.openhab.binding.miio/README.md @@ -309,6 +309,7 @@ Currently the miio binding supports more than 250 different models. | Mi Smart Plug WiFi | miio:basic | [chuangmi.plug.hmi205](#chuangmi-plug-hmi205) | Yes | | | Mi Smart Plug (WiFi) | miio:basic | [chuangmi.plug.hmi206](#chuangmi-plug-hmi206) | Yes | | | Mi Smart Wi-Fi Plug (Bluetooth Gateway) | miio:basic | [chuangmi.plug.hmi208](#chuangmi-plug-hmi208) | Yes | | +| Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway) | miio:basic | [chuangmi.plug.212a01](#chuangmi-plug-212a01) | Yes | Experimental support. Please report back if all channels are functional. Preferably share the debug log of property refresh and command responses | | CHINGMI Smart Power Strip v1 | miio:basic | [qmi.powerstrip.v1](#qmi-powerstrip-v1) | Yes | | | Mi Smart Power Strip | miio:basic | [zimi.powerstrip.v2](#zimi-powerstrip-v2) | Yes | | | Soocare Electric Toothbrush | miio:unsupported | soocare.toothbrush.x3 | No | | @@ -2258,6 +2259,24 @@ e.g. `openhab:send actionCommand 'upd_timer["1498595904821", "on"]'` would enabl | temperature | Number:Temperature | Temperature | | | led | Switch | Wifi LED | | +### Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway) (chuangmi.plug.212a01) Channels + +| Channel | Type | Description | Comment | +|------------------|---------|-------------------------------------|------------| +| on | Switch | Power | | +| temperature | Number:Temperature | Temperature | | +| working-time | Number:Duration | Working Time | | +| on1 | Switch | Indicator Light - Switch Status | | +| power-consumption | Number:Energy | Daily Power Consumption | | +| electric-current | Number:Current | Power Consumption - Electric Current | | +| voltage | Number:ElectricPotential | Power Consumption - Voltage | | +| electric-power | Number:Power | Current Power Consumption - Electric Power | | +| on-duration | Number:Duration | Imilab Timer - On Duration | | +| off-duration | Number:Duration | Imilab Timer - Off Duration | | +| countdown | Number:Time | Imilab Timer - Countdown | | +| task-switch | Switch | Imilab Timer - Task Switch | | +| countdown-info | Switch | Imilab Timer - Countdown Info | | + ### CHINGMI Smart Power Strip v1 (qmi.powerstrip.v1) Channels | Channel | Type | Description | Comment | @@ -6293,6 +6312,27 @@ Number:Temperature temperature "Temperature" (G_plug) {channel="miio:basic:plug: Switch led "Wifi LED" (G_plug) {channel="miio:basic:plug:led"} ``` +### Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway) (chuangmi.plug.212a01) item file lines + +note: Autogenerated example. Replace the id (plug) in the channel with your own. Replace `basic` with `generic` in the thing UID depending on how your thing was discovered. + +```java +Group G_plug "Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway)" +Switch on "Power" (G_plug) {channel="miio:basic:plug:on"} +Number:Temperature temperature "Temperature" (G_plug) {channel="miio:basic:plug:temperature"} +Number:Duration working-time "Working Time" (G_plug) {channel="miio:basic:plug:working-time"} +Switch on1 "Indicator Light - Switch Status" (G_plug) {channel="miio:basic:plug:on1"} +Number:Energy power-consumption "Daily Power Consumption" (G_plug) {channel="miio:basic:plug:power-consumption"} +Number:Current electric-current "Power Consumption - Electric Current" (G_plug) {channel="miio:basic:plug:electric-current"} +Number:ElectricPotential voltage "Power Consumption - Voltage" (G_plug) {channel="miio:basic:plug:voltage"} +Number:Power electric-power "Current Power Consumption - Electric Power" (G_plug) {channel="miio:basic:plug:electric-power"} +Number:Duration on-duration "Imilab Timer - On Duration" (G_plug) {channel="miio:basic:plug:on-duration"} +Number:Duration off-duration "Imilab Timer - Off Duration" (G_plug) {channel="miio:basic:plug:off-duration"} +Number:Time countdown "Imilab Timer - Countdown" (G_plug) {channel="miio:basic:plug:countdown"} +Switch task-switch "Imilab Timer - Task Switch" (G_plug) {channel="miio:basic:plug:task-switch"} +Switch countdown-info "Imilab Timer - Countdown Info" (G_plug) {channel="miio:basic:plug:countdown-info"} +``` + ### CHINGMI Smart Power Strip v1 (qmi.powerstrip.v1) item file lines note: Autogenerated example. Replace the id (powerstrip) 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 eb6452c47..92238a9c6 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 @@ -165,6 +165,8 @@ public enum MiIoDevices { CHUANGMI_PLUG_HMI205("chuangmi.plug.hmi205", "Mi Smart Plug WiFi", THING_TYPE_BASIC), CHUANGMI_PLUG_HMI206("chuangmi.plug.hmi206", "Mi Smart Plug (WiFi)", THING_TYPE_BASIC), CHUANGMI_PLUG_HMI208("chuangmi.plug.hmi208", "Mi Smart Wi-Fi Plug (Bluetooth Gateway)", THING_TYPE_BASIC), + CHUANGMI_PLUG_212A01("chuangmi.plug.212a01", "Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway)", + THING_TYPE_BASIC), QMI_POWERSTRIP_V1("qmi.powerstrip.v1", "CHINGMI Smart Power Strip v1", THING_TYPE_BASIC), ZIMI_POWERSTRIP_V2("zimi.powerstrip.v2", "Mi Smart Power Strip", THING_TYPE_BASIC), SOOCARE_TOOTHBRUSH_X3("soocare.toothbrush.x3", "Soocare Electric Toothbrush", THING_TYPE_UNSUPPORTED), diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoQuantiyTypes.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoQuantiyTypes.java index 27c15859c..693b8e324 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoQuantiyTypes.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoQuantiyTypes.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.miio.internal; +import static org.openhab.core.library.unit.MetricPrefix.MILLI; + import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -43,12 +45,13 @@ public enum MiIoQuantiyTypes { HOUR(Units.HOUR, "hours"), DAY(Units.DAY, "days"), AMPERE(Units.AMPERE), + MILLI_AMPERE(MILLI(Units.AMPERE), "mA"), VOLT(Units.VOLT), WATT(Units.WATT), LITRE(Units.LITRE, "liter"), LUX(Units.LUX), RADIANS(Units.RADIAN, "radians"), - KILOWATT_HOUR(Units.KILOWATT_HOUR, "kwh"), + KILOWATT_HOUR(Units.KILOWATT_HOUR, "kwh", "kWH"), SQUARE_METRE(SIUnits.SQUARE_METRE, "square_meter", "squaremeter"), PERCENT(Units.PERCENT), KGM3(Units.KILOGRAM_PER_CUBICMETRE, "kilogram_per_cubicmeter"), diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/Conversions.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/Conversions.java index 84f4ab3c5..cc45d72e0 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/Conversions.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/Conversions.java @@ -55,7 +55,12 @@ public class Conversions { } public static JsonElement divideTen(JsonElement value10) { - double value = value10.getAsDouble() / 10; + double value = value10.getAsDouble() / 10.0; + return new JsonPrimitive(value); + } + + public static JsonElement divideHundred(JsonElement value10) { + double value = value10.getAsDouble() / 100.0; return new JsonPrimitive(value); } @@ -77,6 +82,8 @@ public class Conversions { return secondsToHours(value); case "/10": return divideTen(value); + case "/100": + return divideHundred(value); case "TANKLEVEL": return tankLevel(value); default: diff --git a/bundles/org.openhab.binding.miio/src/main/resources/database/chuangmi.plug.212a01-miot.json b/bundles/org.openhab.binding.miio/src/main/resources/database/chuangmi.plug.212a01-miot.json new file mode 100644 index 000000000..61b9dec71 --- /dev/null +++ b/bundles/org.openhab.binding.miio/src/main/resources/database/chuangmi.plug.212a01-miot.json @@ -0,0 +1,281 @@ +{ + "deviceMapping": { + "id": [ + "chuangmi.plug.212a01" + ], + "propertyMethod": "get_properties", + "maxProperties": 1, + "channels": [ + { + "property": "on", + "siid": 2, + "piid": 1, + "friendlyName": "Power", + "channel": "on", + "type": "Switch", + "refresh": true, + "actions": [ + { + "command": "set_properties", + "parameterType": "ONOFFBOOL" + } + ], + "category": "switch", + "tags": [ + "Switch" + ] + }, + { + "property": "temperature", + "siid": 2, + "piid": 6, + "friendlyName": "Temperature", + "channel": "temperature", + "type": "Number:Temperature", + "unit": "celsius", + "stateDescription": { + "minimum": 0, + "maximum": 255, + "step": 1, + "pattern": "%.0f %unit%", + "readOnly": true + }, + "refresh": true, + "actions": [], + "category": "temperature", + "tags": [ + "Measurement", + "Temperature" + ] + }, + { + "property": "working-time", + "siid": 2, + "piid": 7, + "friendlyName": "Working Time", + "channel": "working-time", + "type": "Number:Duration", + "unit": "minutes", + "stateDescription": { + "minimum": 0, + "maximum": 300, + "step": 1, + "pattern": "%.0f %unit%", + "readOnly": true + }, + "refresh": true, + "actions": [] + }, + { + "property": "on1", + "siid": 3, + "piid": 1, + "friendlyName": "Indicator Light - Switch Status", + "channel": "on1", + "type": "Switch", + "refresh": true, + "actions": [ + { + "command": "set_properties", + "parameterType": "ONOFFBOOL" + } + ], + "category": "switch", + "tags": [ + "Switch" + ] + }, + { + "property": "power-consumption", + "siid": 5, + "piid": 1, + "friendlyName": "Daily Power Consumption", + "channel": "power-consumption", + "type": "Number:Energy", + "unit": "kWH", + "stateDescription": { + "minimum": 0, + "maximum": 6.5535E+7, + "step": 1, + "pattern": "%.2f %unit%", + "readOnly": true + }, + "refresh": true, + "transformation": "/100", + "actions": [], + "category": "energy", + "tags": [ + "Measurement", + "Energy" + ] + }, + { + "property": "electric-current", + "siid": 5, + "piid": 2, + "friendlyName": "Power Consumption - Electric Current", + "channel": "electric-current", + "type": "Number:Current", + "unit": "mA", + "stateDescription": { + "minimum": 0, + "maximum": 65535, + "step": 1, + "pattern": "%.1f %unit%", + "readOnly": true + }, + "refresh": true, + "actions": [], + "category": "energy", + "tags": [ + "Measurement", + "Current" + ] + }, + { + "property": "voltage", + "siid": 5, + "piid": 3, + "friendlyName": "Power Consumption - Voltage", + "channel": "voltage", + "type": "Number:ElectricPotential", + "unit": "volt", + "stateDescription": { + "minimum": 0, + "maximum": 65535, + "step": 1, + "pattern": "%.1f %unit%", + "readOnly": true + }, + "refresh": true, + "actions": [], + "category": "energy", + "tags": [ + "Measurement", + "Voltage" + ] + }, + { + "property": "electric-power", + "siid": 5, + "piid": 6, + "friendlyName": "Current Power Consumption - Electric Power", + "channel": "electric-power", + "type": "Number:Power", + "unit": "watt", + "stateDescription": { + "minimum": 0, + "maximum": 6553500, + "step": 1, + "pattern": "%.0f %unit%", + "readOnly": true + }, + "refresh": true, + "actions": [], + "category": "energy", + "tags": [ + "Measurement", + "Power" + ] + }, + { + "property": "on-duration", + "siid": 4, + "piid": 1, + "friendlyName": "Imilab Timer - On Duration", + "channel": "on-duration", + "type": "Number:Duration", + "unit": "seconds", + "stateDescription": { + "minimum": 0, + "maximum": 86500, + "step": 1, + "pattern": "%.0f %unit%" + }, + "refresh": true, + "actions": [ + { + "command": "set_properties", + "parameterType": "STRING" + } + ], + "category": "time" + }, + { + "property": "off-duration", + "siid": 4, + "piid": 2, + "friendlyName": "Imilab Timer - Off Duration", + "channel": "off-duration", + "type": "Number:Duration", + "unit": "seconds", + "stateDescription": { + "minimum": 0, + "maximum": 86500, + "step": 1, + "pattern": "%.0f %unit%" + }, + "refresh": true, + "actions": [ + { + "command": "set_properties", + "parameterType": "STRING" + } + ], + "category": "time" + }, + { + "property": "countdown", + "siid": 4, + "piid": 3, + "friendlyName": "Imilab Timer - Countdown", + "channel": "countdown", + "type": "Number:Time", + "unit": "seconds", + "stateDescription": { + "minimum": 0, + "maximum": 86500, + "step": 1, + "pattern": "%.0f %unit%" + }, + "refresh": true, + "actions": [ + { + "command": "set_properties", + "parameterType": "STRING" + } + ], + "category": "time" + }, + { + "property": "task-switch", + "siid": 4, + "piid": 4, + "friendlyName": "Imilab Timer - Task Switch", + "channel": "task-switch", + "type": "Switch", + "refresh": true, + "actions": [ + { + "command": "set_properties", + "parameterType": "ONOFFBOOL" + } + ] + }, + { + "property": "countdown-info", + "siid": 4, + "piid": 5, + "friendlyName": "Imilab Timer - Countdown Info", + "channel": "countdown-info", + "type": "Switch", + "stateDescription": { + "readOnly": true + }, + "refresh": true, + "actions": [] + } + ], + "experimental": true + } +}