Note, in the first half of 2023, this rule template will be rewritten to only support JS Scripting.
This is one of three rules used to create an MQTT Even Bus. The other rules are MQTT Online Status and MQTT Event Bus Subscribe.This rule is responsible for parsing the messages received on an event bus and commanding or updating Items as necessary. See MQTT 2.5+ Event Bus for details on how to set up and configure an MQTT Even Bus.
Warning, to avoid infinite loops, do not publish and subscribe the same event on the same Items.
openHAB instance | Publishes | Subscribes |
---|---|---|
Linked to device | updates | commands |
Remote | commands | updates |
The rule has the following parameters:
Parameter | Purpose |
---|---|
MQTT Broker Thing | Select the MQTT Broker Thing to publish to. |
openHAB instance name | The name of this openHAB instance, will be used as the root of the topic events are published to. |
Command Group | The Group whose member’s commands are published to the event bus. |
Update Group | The Group who memember’s updates are published to the event bus. |
Language: Nashorn JavaScript
Dependencies:
- MQTT Binding installed
- MQTT Broker Thing created and configured
- A Group containing those Items who should have their commands published.
- A Group containing those Items who should have their updates published.
- In OH 4 the Nashorn add-on needs to be separately installed or change the script type to
application/javascript;version=ECMAScript-2021
.
Changelog
Version 0.3
- adjusted for breaking change, will no longer work for versions of OH prior to December 15th
Version 0.2
- Made compatible with Nashorn and JSScripting
Note: will remove support for Nashorn sometime after OH 3.2 release.
Version 0.1
- initial release