Skip to content

Commit

Permalink
[miio] add support for chungmiplug 212a01 (openhab#9795)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
  • Loading branch information
marcelrv authored Jan 13, 2021
1 parent b759acf commit 8c4f714
Show file tree
Hide file tree
Showing 5 changed files with 335 additions and 2 deletions.
40 changes: 40 additions & 0 deletions bundles/org.openhab.binding.miio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
Expand Down Expand Up @@ -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) (<a name="chuangmi-plug-212a01">chuangmi.plug.212a01</a>) 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 (<a name="qmi-powerstrip-v1">qmi.powerstrip.v1</a>) Channels

| Channel | Type | Description | Comment |
Expand Down Expand Up @@ -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)" <status>
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ public static JsonElement yeelightSceneConversion(JsonElement intValue) {
}

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);
}

Expand All @@ -77,6 +82,8 @@ public static JsonElement execute(String transfortmation, JsonElement value) {
return secondsToHours(value);
case "/10":
return divideTen(value);
case "/100":
return divideHundred(value);
case "TANKLEVEL":
return tankLevel(value);
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 8c4f714

Please sign in to comment.