diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/CommandParameterType.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/CommandParameterType.java index d448011d8af72..b5e638be042f0 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/CommandParameterType.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/CommandParameterType.java @@ -28,8 +28,9 @@ public enum CommandParameterType { ONOFFBOOL("onoffbool"), ONOFFBOOLSTRING("onoffboolstring"), ONOFFNUMBER("onoffnumber"), - OPENCLOSENUMBER("openclosenumber"), OPENCLOSE("openclose"), + OPENCLOSENUMBER("openclosenumber"), + OPENCLOSESWITCH("opencloseswitch"), STRING("string"), CUSTOMSTRING("customstring"), NUMBER("number"), diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java index c6c7c5905723f..19f7e3382aabc 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java @@ -175,6 +175,30 @@ public void handleCommand(ChannelUID channelUID, Command receivedCommand) { 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 (command instanceof HSBType) { HSBType hsb = (HSBType) command; @@ -630,8 +654,8 @@ private void updateChannel(@Nullable MiIoBasicChannel basicChannel, String param } else { String strVal = val.getAsString().toLowerCase(); updateState(basicChannel.getChannel(), - "on".equals(strVal) || "true".equals(strVal) || "1".equals(strVal) ? OpenClosedType.OPEN - : OpenClosedType.CLOSED); + "open".equals(strVal) || "on".equals(strVal) || "true".equals(strVal) + || "1".equals(strVal) ? OpenClosedType.OPEN : OpenClosedType.CLOSED); } break; case "color": @@ -706,6 +730,7 @@ public void onMessageReceived(MiIoSendCommand response) { switch (response.getCommand()) { case MIIO_INFO: break; + case GET_DEVICE_PROPERTY_EXP: case GET_VALUE: case GET_PROPERTIES: case GET_PROPERTY: