Skip to content

Commit

Permalink
[mqtt.generic] Expose more advanced rollshutter config options (openh…
Browse files Browse the repository at this point in the history
…ab#16051)

That are used by the Home Assistant binding, but may be useful
for others.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
  • Loading branch information
ccutrer authored and austvik committed Mar 27, 2024
1 parent 9594a43 commit b8b3235
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,16 @@ public RollershutterValue(@Nullable String upCommandString, @Nullable String dow
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public static Value createValueState(ChannelConfig config, String channelTypeID)
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -79,23 +80,50 @@
<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>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b8b3235

Please sign in to comment.