This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

MQTT Client app - Beta testing
#1
We are inviting everyone to join beta testing for our new MQTT client app.

https://dl.openrb.com/pkg/mqtt-client-20240926.ipk

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.



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
Reply


Messages In This Thread
MQTT Client app - Beta testing - by Daniel - 10.09.2024, 14:12
RE: MQTT Client app - Beta testing - by myg - 23.09.2024, 08:58
RE: MQTT Client app - Beta testing - by myg - 23.09.2024, 09:50
RE: MQTT Client app - Beta testing - by admin - 23.09.2024, 10:04
RE: MQTT Client app - Beta testing - by myg - 23.09.2024, 10:41
RE: MQTT Client app - Beta testing - by myg - 23.09.2024, 12:50

Forum Jump: