[miio] Support contact type in basic channel json (#11477)
Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
parent
8b1eabe166
commit
b73bf672ab
|
@ -52,6 +52,7 @@ import org.openhab.core.cache.ExpiringCache;
|
|||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.HSBType;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.library.types.OpenClosedType;
|
||||
import org.openhab.core.library.types.PercentType;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.types.StringType;
|
||||
|
@ -622,6 +623,17 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
|
|||
: OnOffType.OFF);
|
||||
}
|
||||
break;
|
||||
case "contact":
|
||||
if (val.getAsJsonPrimitive().isNumber()) {
|
||||
updateState(basicChannel.getChannel(),
|
||||
val.getAsInt() > 0 ? OpenClosedType.OPEN : OpenClosedType.CLOSED);
|
||||
} else {
|
||||
String strVal = val.getAsString().toLowerCase();
|
||||
updateState(basicChannel.getChannel(),
|
||||
"on".equals(strVal) || "true".equals(strVal) || "1".equals(strVal) ? OpenClosedType.OPEN
|
||||
: OpenClosedType.CLOSED);
|
||||
}
|
||||
break;
|
||||
case "color":
|
||||
if (val.isJsonPrimitive()
|
||||
&& (val.getAsJsonPrimitive().isNumber() || val.getAsString().matches("^[0-9]+$"))) {
|
||||
|
|
Loading…
Reference in New Issue