]> git.basschouten.com Git - openhab-addons.git/commitdiff
[mqtt.generic] Expose more advanced rollshutter config options (#16051)
authorCody Cutrer <cody@cutrer.us>
Sun, 14 Jan 2024 20:38:48 +0000 (13:38 -0700)
committerGitHub <noreply@github.com>
Sun, 14 Jan 2024 20:38:48 +0000 (21:38 +0100)
That are used by the Home Assistant binding, but may be useful
for others.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/ChannelConfig.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/RollershutterValue.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/ValueFactory.java
bundles/org.openhab.binding.mqtt.generic/src/main/resources/OH-INF/config/rollershutter-channel-config.xml
bundles/org.openhab.binding.mqtt.generic/src/main/resources/OH-INF/i18n/mqtt.properties

index 05b932220fbd76ca0a28ebc8e485e93dd517d22a..0b2cb3f548676be1b10e8ff1f75672c6dc229e1b 100644 (file)
@@ -57,7 +57,11 @@ public class ChannelConfig {
     public @Nullable String on;
     public @Nullable String off;
     public @Nullable String stop;
+    public @Nullable String onState;
+    public @Nullable String offState;
 
     public int onBrightness = 10;
     public String colorMode = ColorMode.HSB.toString();
+    public boolean invert = false;
+    public boolean transformExtentsToString = false;
 }
index fbd2ba64ddbbe0697ebab5bf6d6c3e9747c5daaa..f1f34e82867c9deafe99879270242ee13805160d 100644 (file)
@@ -71,8 +71,16 @@ public class RollershutterValue extends Value {
         this.upCommandString = upCommandString;
         this.downCommandString = downCommandString;
         this.stopCommandString = stopCommandString;
-        this.upStateString = upStateString;
-        this.downStateString = downStateString;
+        if (upStateString == null) {
+            this.upStateString = upCommandString;
+        } else {
+            this.upStateString = upStateString;
+        }
+        if (downStateString == null) {
+            this.downStateString = downCommandString;
+        } else {
+            this.downStateString = downStateString;
+        }
         this.inverted = inverted;
         this.transformExtentsToString = transformExtentsToString;
     }
index a189c297662addf2c3e77a0da69afc1a9bfe36bd..f4295b9862a1cf87c39697e86a11667362839a1f 100644 (file)
@@ -76,7 +76,8 @@ public class ValueFactory {
                 value = new OpenCloseValue(config.on, config.off);
                 break;
             case MqttBindingConstants.ROLLERSHUTTER:
-                value = new RollershutterValue(config.on, config.off, config.stop);
+                value = new RollershutterValue(config.on, config.off, config.stop, config.onState, config.offState,
+                        config.invert, config.transformExtentsToString);
                 break;
             case MqttBindingConstants.TRIGGER:
                 config.trigger = true;
index a081caa4e55fb8309e0896bc0abc58a3beae016e..bde8aa507b265869dee732c6c189be1647f42586 100644 (file)
@@ -19,7 +19,8 @@
                </parameter>
                <parameter name="commandTopic" type="text">
                        <label>MQTT Command Topic</label>
-                       <description>An MQTT topic that this thing will send a command to. If not set, this will be a read-only switch.</description>
+                       <description>An MQTT topic that this thing will send a command to. If not set, this will be a read-only
+                               rollershutter.</description>
                </parameter>
                <parameter name="transformationPattern" type="text" groupName="transformations">
                        <label>Incoming Value Transformations</label>
                        <advanced>true</advanced>
                </parameter>
                <parameter name="on" type="text">
-                       <label>Up Value</label>
-                       <description>A string (like "OPEN") that is recognised as UP state. You can use this parameter for a second keyword,
-                               next to UP.</description>
+                       <label>Up Command Value</label>
+                       <description>A string (like "OPEN") that is sent when commanding the rollershutter to open. If not provided, 0 (or
+                               100, if inverted) will be sent instead.</description>
                        <advanced>true</advanced>
                </parameter>
                <parameter name="off" type="text">
-                       <label>Down Value</label>
-                       <description>A string (like "CLOSE") that is recognised as DOWN state. You can use this parameter for a second
-                               keyword, next to DOWN.</description>
+                       <label>Down Command Value</label>
+                       <description>A string (like "CLOSE") that is sent when commanding the rollershutter to close. If not provided, 100
+                               (or 0, if inverted) will be sent instead.</description>
                        <advanced>true</advanced>
                </parameter>
                <parameter name="stop" type="text">
-                       <label>Stop Value</label>
-                       <description>A string (like "STOP") that is recognised as stop state. Will set the rollershutter state to undefined,
-                               because the current position is unknown at that point.</description>
+                       <label>Stop Command</label>
+                       <description>A string (like "STOP") that is sent when commanding the rollershutter to stop.</description>
                        <default>STOP</default>
                        <advanced>true</advanced>
                </parameter>
+               <parameter name="onState" type="text">
+                       <label>Up State Value</label>
+                       <description>A string (like "OPENED") that is recognised as UP state. You can use this parameter for a second
+                               keyword, next to UP. Defaults to the Up Command Value.</description>
+                       <advanced>true</advanced>
+               </parameter>
+               <parameter name="offState" type="text">
+                       <label>Down State Value</label>
+                       <description>A string (like "CLOSED") that is recognised as DOWN state. You can use this parameter for a second
+                               keyword, next to DOWN. Defaults to the Down Command Value.</description>
+                       <advanced>true</advanced>
+               </parameter>
+               <parameter name="invert" type="boolean">
+                       <label>Invert</label>
+                       <description>Enable if your device uses 100 as UP and 0 as DOWN, instead of the normal openHAB convention of 0 as UP
+                               and 100 as DOWN.</description>
+                       <default>false</default>
+                       <advanced>true</advanced>
+               </parameter>
+               <parameter name="transformExtentsToString" type="boolean">
+                       <label>Transform Commands at Extents to String</label>
+                       <description>If a command is 0 or 100, send that as UP or DOWN commands instead. Useful if your device doesn't
+                               support going to a specific position - only opening or closing, but you have front ends (say HomeKit) or rules that
+                               will only send percentage commands instead of UP/DOWN.
+                       </description>
+                       <default>false</default>
+                       <advanced>true</advanced>
+               </parameter>
        </config-description>
 </config-description:config-descriptions>
index f02c9b5dc50dd9d354616d953db7ae53f63583e0..80fd9264a2336f31acdc1a899aa060a1e2f4104c 100644 (file)
@@ -128,15 +128,21 @@ thing-type.config.mqtt.number_channel.transformationPatternOut.description = App
 thing-type.config.mqtt.number_channel.unit.label = Unit Of Measurement
 thing-type.config.mqtt.number_channel.unit.description = Unit of measurement (optional). The unit is used for representing the value in the GUI as well as for converting incoming values (like from '°F' to '°C'). Examples: "°C", "°F"
 thing-type.config.mqtt.rollershutter_channel.commandTopic.label = MQTT Command Topic
-thing-type.config.mqtt.rollershutter_channel.commandTopic.description = An MQTT topic that this thing will send a command to. If not set, this will be a read-only switch.
+thing-type.config.mqtt.rollershutter_channel.commandTopic.description = An MQTT topic that this thing will send a command to. If not set, this will be a read-only rollershutter.
 thing-type.config.mqtt.rollershutter_channel.formatBeforePublish.label = Outgoing Value Format
 thing-type.config.mqtt.rollershutter_channel.formatBeforePublish.description = Format a value before it is published to the MQTT broker. The default is to just pass the channel/item state. If you want to apply a prefix, say "MYCOLOR,", you would use "MYCOLOR,%s". If you want to adjust the precision of a number to for example 4 digits, you would use "%.4f".
 thing-type.config.mqtt.rollershutter_channel.group.transformations.label = Transform Values
 thing-type.config.mqtt.rollershutter_channel.group.transformations.description = These configuration parameters allow you to alter a value before it is published to MQTT or before a received value is assigned to an item.
-thing-type.config.mqtt.rollershutter_channel.off.label = Down Value
-thing-type.config.mqtt.rollershutter_channel.off.description = A string (like "CLOSE") that is recognised as DOWN state. You can use this parameter for a second keyword, next to DOWN.
-thing-type.config.mqtt.rollershutter_channel.on.label = Up Value
-thing-type.config.mqtt.rollershutter_channel.on.description = A string (like "OPEN") that is recognised as UP state. You can use this parameter for a second keyword, next to UP.
+thing-type.config.mqtt.rollershutter_channel.invert.label = Invert
+thing-type.config.mqtt.rollershutter_channel.invert.description = Enable if your device uses 100 as UP and 0 as DOWN, instead of the normal openHAB convention of 0 as UP and 100 as DOWN.
+thing-type.config.mqtt.rollershutter_channel.off.label = Down Command Value
+thing-type.config.mqtt.rollershutter_channel.off.description = A string (like "CLOSE") that is sent when commanding the rollershutter to close. If not provided, 100 (or 0, if inverted) will be sent instead.
+thing-type.config.mqtt.rollershutter_channel.offState.label = Down State Value
+thing-type.config.mqtt.rollershutter_channel.offState.description = A string (like "CLOSED") that is recognised as DOWN state. You can use this parameter for a second keyword, next to DOWN. Defaults to the Down Command Value.
+thing-type.config.mqtt.rollershutter_channel.on.label = Up Command Value
+thing-type.config.mqtt.rollershutter_channel.on.description = A string (like "OPEN") that is sent when commanding the rollershutter to open. If not provided, 0 (or 100, if inverted) will be sent instead.
+thing-type.config.mqtt.rollershutter_channel.onState.label = Up State Value
+thing-type.config.mqtt.rollershutter_channel.onState.description = A string (like "OPENED") that is recognised as UP state. You can use this parameter for a second keyword, next to UP. Defaults to the Up Command Value.
 thing-type.config.mqtt.rollershutter_channel.postCommand.label = Is Command
 thing-type.config.mqtt.rollershutter_channel.postCommand.description = If the received MQTT value should not only update the state of linked items, but command them, enable this option.
 thing-type.config.mqtt.rollershutter_channel.qos.label = QoS
@@ -148,8 +154,10 @@ thing-type.config.mqtt.rollershutter_channel.retained.label = Retained
 thing-type.config.mqtt.rollershutter_channel.retained.description = The value will be published to the command topic as retained message. A retained value stays on the broker and can even be seen by MQTT clients that are subscribing at a later point in time.
 thing-type.config.mqtt.rollershutter_channel.stateTopic.label = MQTT State Topic
 thing-type.config.mqtt.rollershutter_channel.stateTopic.description = An MQTT topic that this thing will subscribe to, to receive the state. This can be left empty, the channel will be state-less command-only channel.
-thing-type.config.mqtt.rollershutter_channel.stop.label = Stop Value
-thing-type.config.mqtt.rollershutter_channel.stop.description = A string (like "STOP") that is recognised as stop state. Will set the rollershutter state to undefined, because the current position is unknown at that point.
+thing-type.config.mqtt.rollershutter_channel.stop.label = Stop Command
+thing-type.config.mqtt.rollershutter_channel.stop.description = A string (like "STOP") that is sent when commanding the rollershutter to stop.
+thing-type.config.mqtt.rollershutter_channel.transformExtentsToString.label = Transform Commands at Extents to String
+thing-type.config.mqtt.rollershutter_channel.transformExtentsToString.description = If a command is 0 or 100, send that as UP or DOWN commands instead. Useful if your device doesn't support going to a specific position - only opening or closing, but you have front ends (say HomeKit) or rules that will only send percentage commands instead of UP/DOWN.
 thing-type.config.mqtt.rollershutter_channel.transformationPattern.label = Incoming Value Transformations
 thing-type.config.mqtt.rollershutter_channel.transformationPattern.description = Applies transformations to an incoming MQTT topic value. A transformation example for a received JSON would be "JSONPATH:$.device.status.temperature" for a json {device: {status: { temperature: 23.2 }}}. You can chain transformations by separating them with the intersection character ∩.
 thing-type.config.mqtt.rollershutter_channel.transformationPatternOut.label = Outgoing Value Transformation