Skip to content

Commit

Permalink
[mqtt.generic] add trigger channel type (openhab#6902)
Browse files Browse the repository at this point in the history
* add possibility to make generic string/number channels triggers
* witespace
* make trigger an own channel type
* improve description
* good point
* review

Signed-off-by: Jochen Klein <git@jochen.susca.de>
  • Loading branch information
jochen314 authored and andrewfg committed Aug 31, 2020
1 parent da6b7ee commit eb5d005
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ public class MqttBindingConstants {
public static final String LOCATION = "location";
public static final String DATETIME = "datetime";
public static final String ROLLERSHUTTER = "rollershutter";
public static final String TRIGGER = "trigger";
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public static Value createValueState(ChannelConfig config, String channelTypeID)
case MqttBindingConstants.ROLLERSHUTTER:
value = new RollershutterValue(config.on, config.off, config.stop);
break;
case MqttBindingConstants.TRIGGER:
config.trigger = true;
value = new TextValue();
break;
default:
throw new IllegalArgumentException("ChannelTypeUID not recognised: " + channelTypeID);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<config-description:config-descriptions
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:config-description="https://openhab.org/schemas/config-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0 https://openhab.org/schemas/config-description-1.0.0.xsd">

<config-description uri="thing-type:mqtt:trigger_channel">
<parameter-group name="transformations">
<label>Transform Values</label>
<description>These configuration parameters allow you to alter before a received value is used in the trigger.</description>
<advanced>true</advanced>
</parameter-group>

<parameter name="stateTopic" type="text" required="true">
<label>MQTT Trigger Topic</label>
<description>An MQTT topic that this thing will subscribe to, to receive the trigger</description>
</parameter>
<parameter name="transformationPattern" type="text" groupName="transformations">
<label>Incoming Value Transformations</label>
<description><![CDATA[
Applies transformations to an incoming MQTT topic value.
This can be used to map the events sent by the device to common values for all devices using,
e.g. the MAP transformation.
You can chain transformations by separating them with the intersection character ∩.
]]></description>
<advanced>true</advanced>
</parameter>
</config-description>
</config-description:config-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,11 @@
<config-description-ref uri="thing-type:mqtt:color_channel"></config-description-ref>
</channel-type>

<channel-type id="trigger">
<item-type>Trigger</item-type>
<label>Trigger</label>
<description></description>
<config-description-ref uri="thing-type:mqtt:trigger_channel"></config-description-ref>
</channel-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

<thing-type id="topic"
extensible="string,number,dimmer,switch,contact,colorRGB,colorHSB,datetime,image,location,rollershutter">
extensible="string,number,dimmer,switch,contact,colorRGB,colorHSB,datetime,image,location,rollershutter,trigger">
<supported-bridge-type-refs>
<bridge-type-ref id="broker"/>
<bridge-type-ref id="systemBroker"/>
Expand Down

0 comments on commit eb5d005

Please sign in to comment.