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 092d723211..8177083bb2 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 inverted = Boolean.FALSE; public String range = ""; public String irCode = ""; public int irSendDelay = 300; 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 5d4f39bfc4..4b85eb13d4 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 @@ -172,7 +172,11 @@ private void processChannelStatus(Integer dp, Object value) { return; } else if (Double.class.isAssignableFrom(value.getClass()) && CHANNEL_TYPE_UID_DIMMER.equals(channelTypeUID)) { - updateState(channelId, ConversionUtil.brightnessDecode((double) value, 0, configuration.max)); + double brightness = (double) value; + if (configuration.inverted) { + brightness = configuration.max - brightness; + } + updateState(channelId, ConversionUtil.brightnessDecode(brightness, 0, configuration.max)); return; } else if (Double.class.isAssignableFrom(value.getClass()) && CHANNEL_TYPE_UID_NUMBER.equals(channelTypeUID)) { @@ -300,6 +304,9 @@ public void handleCommand(ChannelUID channelUID, Command command) { } else if (CHANNEL_TYPE_UID_DIMMER.equals(channelTypeUID)) { if (command instanceof PercentType) { int value = ConversionUtil.brightnessEncode((PercentType) command, 0, configuration.max); + if (configuration.inverted) { + value = configuration.max - value; + } if (value >= configuration.min) { commandRequest.put(configuration.dp, value); } 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 d295cb733b..e0f5ac681c 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 @@ -149,6 +149,11 @@ + + + false + true +