This library adds a block to perform MQTT actions. You need the MQTT binding installed and a configured broker Thing.
Blocks
This block will publish the provided message on the provided topic via the specified broker, which you can select in a popup by clicking inside the thing block. Only choose a MQTT broker when picking the thing.
You can optionally retain the message on the broker.
Changelog
Version 0.1
- initial release
Resources
uid: mqtt
tags: []
props:
parameters: []
parameterGroups: []
component: BlockLibrary
config:
name: MQTT
slots:
blocks:
- component: BlockType
config:
type: publish
message0: Publish MQTT message %1 on topic %2 via broker %3 %4 retain
lastDummyAlign0: right
args0:
- type: input_value
name: MESSAGE
align: right
- type: input_value
name: TOPIC
align: right
- type: input_value
name: BROKER
align: right
- type: field_checkbox
name: RETAIN
align: right
previousStatement: ""
nextStatement: ""
inputsInline: false
colour: 0
tooltip: ""
helpUrl: ""
slots:
code:
- component: BlockCodeTemplate
config:
template: >
{{utility:things}}.getActions('mqtt', {{input:BROKER}}).publishMQTT({{input:TOPIC}}, {{input:MESSAGE}}, '{{field:RETAIN}}' === 'TRUE');
toolbox:
- component: PresetInput
config:
name: MESSAGE
type: text
shadow: true
fields:
TEXT: message
- component: PresetInput
config:
name: TOPIC
type: text
shadow: true
fields:
TEXT: topic
- component: PresetInput
config:
name: BROKER
type: oh_thing
shadow: true
utilities:
- component: UtilityJavaType
config:
name: things
javaClass: org.openhab.core.model.script.actions.Things