10.09.2024, 14:12
MQTT client app is now published in LM app store.
The app will run on all controllers, none LM too.
The first step is to establish communication with the Broker. Under the gear icon the MQTT configuration can be set. After saving the dot in the top right corner will highlight if communication was established or not. Green means connected, red the opposite.
There are also connection logs and help with a link to this thread.
Add topic
Common options
Out (to MQTT) options
In (from MQTT) options
Boolean to string conversion (applies only to 1-bit objects)
JSON value path example
MQTT payload is the following JSON, battery level % needs to be obtained.
The root object contains an object named battery which has a percent value. The resulting JSON value path is battery.percent
Arrays are also supported with indexes starting from 1 because the JSON payload is converted to Lua.
No write is performed if the payload is not a valid JSON or the path cannot be found.
Scripts
In MQTT there is no definition of how the data is structured. To overcome this problem each topic has a script attached to convert the data to a correct format if needed. Script example and more info on how the conversion works is defined in this guide. Script errors can be viewed in the LM Error log. Each script has its own global environment, meaning that global variable values are kept between each execution but these variables are not shared between scripts.
Please report any issues or questions here.
The app will run on all controllers, none LM too.
The first step is to establish communication with the Broker. Under the gear icon the MQTT configuration can be set. After saving the dot in the top right corner will highlight if communication was established or not. Green means connected, red the opposite.
There are also connection logs and help with a link to this thread.
Add topic
Common options
- Direction - defines the communication direction, it can be in Both, In (From MQTT) and Out (To MQTT)
- Topic name is what the name defines.
- Mapped object is the object from which the value will be read/written. This option is not needed if Direction is In (From MQTT) as the payload can contain several values.
Out (to MQTT) options
- Publish QoS - Quality of Service level when publishing data to MQTT. Use QoS 0 when using a local broker on the same LM. More info here.
- Retain message tells broker to keep the last value. Any new client subscribing to the topic will receive the last value, otherwise will need to wait for a change. More info here.
- Publish current value when connected to broker - when enabled the current object value is published when a connection to the broker is established.
In (from MQTT) options
- Publish QoS - Quality of Service level when subscribing to data to MQTT. Use QoS 0 when using a local broker on the same LM.
- Send delta - minimum value difference to trigger group
- Throttle time (seconds) - set a minimum time between MQTT messages. A timer is started when a message is received. Any new messages are ignored until the time expires.
- Write to bus - defines where to write values to KNX/TP or not.
- JSON value path - extracts value from a JSON payload, see example below.
Boolean to string conversion (applies only to 1-bit objects)
- Converts 1-bit object value to a string when publishing to MQTT and a string payload to 1-bit when a message is received from MQTT. Values received from MQTT that do not match either ON or OFF string are ignored.
JSON value path example
MQTT payload is the following JSON, battery level % needs to be obtained.
Code:
{
"id": "0",
"battery": {
"V": 2.99,
"percent": 93
}
}
The root object contains an object named battery which has a percent value. The resulting JSON value path is battery.percent
Arrays are also supported with indexes starting from 1 because the JSON payload is converted to Lua.
No write is performed if the payload is not a valid JSON or the path cannot be found.
Scripts
In MQTT there is no definition of how the data is structured. To overcome this problem each topic has a script attached to convert the data to a correct format if needed. Script example and more info on how the conversion works is defined in this guide. Script errors can be viewed in the LM Error log. Each script has its own global environment, meaning that global variable values are kept between each execution but these variables are not shared between scripts.
Please report any issues or questions here.
------------------------------
Ctrl+F5
Ctrl+F5