[miio] support sending openclose commands (#11581)
* [miio] support sending openclose commands Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com> * [miio] fix contact sending Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com> * [miio] switch Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
parent
edafc1970b
commit
4d8c6b304b
|
@ -28,8 +28,9 @@ public enum CommandParameterType {
|
||||||
ONOFFBOOL("onoffbool"),
|
ONOFFBOOL("onoffbool"),
|
||||||
ONOFFBOOLSTRING("onoffboolstring"),
|
ONOFFBOOLSTRING("onoffboolstring"),
|
||||||
ONOFFNUMBER("onoffnumber"),
|
ONOFFNUMBER("onoffnumber"),
|
||||||
OPENCLOSENUMBER("openclosenumber"),
|
|
||||||
OPENCLOSE("openclose"),
|
OPENCLOSE("openclose"),
|
||||||
|
OPENCLOSENUMBER("openclosenumber"),
|
||||||
|
OPENCLOSESWITCH("opencloseswitch"),
|
||||||
STRING("string"),
|
STRING("string"),
|
||||||
CUSTOMSTRING("customstring"),
|
CUSTOMSTRING("customstring"),
|
||||||
NUMBER("number"),
|
NUMBER("number"),
|
||||||
|
|
|
@ -175,6 +175,30 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
|
||||||
command = new DecimalType(((QuantityType<?>) command).toBigDecimal());
|
command = new DecimalType(((QuantityType<?>) command).toBigDecimal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (paramType == CommandParameterType.OPENCLOSE) {
|
||||||
|
if (command instanceof OpenClosedType) {
|
||||||
|
value = new JsonPrimitive(command == OpenClosedType.OPEN ? "open" : "close");
|
||||||
|
} else {
|
||||||
|
value = new JsonPrimitive(("ON".contentEquals(command.toString().toUpperCase())
|
||||||
|
|| "1".contentEquals(command.toString())) ? "open" : "close");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (paramType == CommandParameterType.OPENCLOSENUMBER) {
|
||||||
|
if (command instanceof OpenClosedType) {
|
||||||
|
value = new JsonPrimitive(command == OpenClosedType.OPEN ? 1 : 0);
|
||||||
|
} else {
|
||||||
|
value = new JsonPrimitive(("ON".contentEquals(command.toString().toUpperCase())
|
||||||
|
|| "1".contentEquals(command.toString())) ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (paramType == CommandParameterType.OPENCLOSESWITCH) {
|
||||||
|
if (command instanceof OpenClosedType) {
|
||||||
|
value = new JsonPrimitive(command == OpenClosedType.OPEN ? "on" : "off");
|
||||||
|
} else {
|
||||||
|
value = new JsonPrimitive(("ON".contentEquals(command.toString().toUpperCase())
|
||||||
|
|| "1".contentEquals(command.toString())) ? "on" : "off");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (paramType == CommandParameterType.COLOR) {
|
if (paramType == CommandParameterType.COLOR) {
|
||||||
if (command instanceof HSBType) {
|
if (command instanceof HSBType) {
|
||||||
HSBType hsb = (HSBType) command;
|
HSBType hsb = (HSBType) command;
|
||||||
|
@ -630,8 +654,8 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
|
||||||
} else {
|
} else {
|
||||||
String strVal = val.getAsString().toLowerCase();
|
String strVal = val.getAsString().toLowerCase();
|
||||||
updateState(basicChannel.getChannel(),
|
updateState(basicChannel.getChannel(),
|
||||||
"on".equals(strVal) || "true".equals(strVal) || "1".equals(strVal) ? OpenClosedType.OPEN
|
"open".equals(strVal) || "on".equals(strVal) || "true".equals(strVal)
|
||||||
: OpenClosedType.CLOSED);
|
|| "1".equals(strVal) ? OpenClosedType.OPEN : OpenClosedType.CLOSED);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "color":
|
case "color":
|
||||||
|
@ -706,6 +730,7 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
|
||||||
switch (response.getCommand()) {
|
switch (response.getCommand()) {
|
||||||
case MIIO_INFO:
|
case MIIO_INFO:
|
||||||
break;
|
break;
|
||||||
|
case GET_DEVICE_PROPERTY_EXP:
|
||||||
case GET_VALUE:
|
case GET_VALUE:
|
||||||
case GET_PROPERTIES:
|
case GET_PROPERTIES:
|
||||||
case GET_PROPERTY:
|
case GET_PROPERTY:
|
||||||
|
|
Loading…
Reference in New Issue