[miio] add support for chungmiplug 212a01 (#9795)

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
Marcel
2021-01-13 20:52:24 +01:00
committed by GitHub
parent 4e73b05ff0
commit cdbf10efdb
5 changed files with 335 additions and 2 deletions

View File

@@ -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),

View File

@@ -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"),

View File

@@ -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:

View File

@@ -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
}
}