diff --git a/bundles/org.smarthomej.binding.tuya/src/main/java/org/smarthomej/binding/tuya/internal/config/ChannelConfiguration.java b/bundles/org.smarthomej.binding.tuya/src/main/java/org/smarthomej/binding/tuya/internal/config/ChannelConfiguration.java index 38d4e9ef42..5b216403e7 100644 --- a/bundles/org.smarthomej.binding.tuya/src/main/java/org/smarthomej/binding/tuya/internal/config/ChannelConfiguration.java +++ b/bundles/org.smarthomej.binding.tuya/src/main/java/org/smarthomej/binding/tuya/internal/config/ChannelConfiguration.java @@ -25,6 +25,7 @@ public class ChannelConfiguration { public int dp2 = 0; public int min = Integer.MIN_VALUE; public int max = Integer.MAX_VALUE; + public boolean sendAsString = false; public boolean reversed = false; public String range = ""; public String irCode = ""; diff --git a/bundles/org.smarthomej.binding.tuya/src/main/java/org/smarthomej/binding/tuya/internal/handler/TuyaDeviceHandler.java b/bundles/org.smarthomej.binding.tuya/src/main/java/org/smarthomej/binding/tuya/internal/handler/TuyaDeviceHandler.java index 781f8c7bca..89581d79fe 100644 --- a/bundles/org.smarthomej.binding.tuya/src/main/java/org/smarthomej/binding/tuya/internal/handler/TuyaDeviceHandler.java +++ b/bundles/org.smarthomej.binding.tuya/src/main/java/org/smarthomej/binding/tuya/internal/handler/TuyaDeviceHandler.java @@ -148,7 +148,6 @@ public void processDeviceStatus(Map deviceStatus) { private void processChannelStatus(Integer dp, Object value) { String channelId = dpToChannelId.get(dp); if (channelId != null) { - ChannelConfiguration configuration = channelIdToConfiguration.get(channelId); ChannelTypeUID channelTypeUID = channelIdToChannelTypeUID.get(channelId); @@ -180,6 +179,8 @@ private void processChannelStatus(Integer dp, Object value) { && CHANNEL_TYPE_UID_NUMBER.equals(channelTypeUID)) { updateState(channelId, new DecimalType((double) value)); return; + } else if (value instanceof String string && CHANNEL_TYPE_UID_NUMBER.equals(channelTypeUID)) { + updateState(channelId, new DecimalType(string)); } else if (Boolean.class.isAssignableFrom(value.getClass()) && CHANNEL_TYPE_UID_SWITCH.equals(channelTypeUID)) { updateState(channelId, OnOffType.from((boolean) value)); @@ -324,12 +325,12 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } } else if (CHANNEL_TYPE_UID_STRING.equals(channelTypeUID)) { - if (command instanceof StringType) { - commandRequest.put(configuration.dp, command.toString()); - } + commandRequest.put(configuration.dp, command.toString()); } else if (CHANNEL_TYPE_UID_NUMBER.equals(channelTypeUID)) { - if (command instanceof DecimalType) { - commandRequest.put(configuration.dp, ((DecimalType) command).intValue()); + if (command instanceof DecimalType decimalType) { + commandRequest.put(configuration.dp, + configuration.sendAsString ? String.format("%d", decimalType.intValue()) + : decimalType.intValue()); } } else if (CHANNEL_TYPE_UID_SWITCH.equals(channelTypeUID)) { if (command instanceof OnOffType) { diff --git a/bundles/org.smarthomej.binding.tuya/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.smarthomej.binding.tuya/src/main/resources/OH-INF/thing/thing-types.xml index 37de3165e3..2e0d67244c 100644 --- a/bundles/org.smarthomej.binding.tuya/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.smarthomej.binding.tuya/src/main/resources/OH-INF/thing/thing-types.xml @@ -68,6 +68,7 @@ + password @@ -174,6 +175,12 @@ + + + Send the value as string instead of number. + false + true +