MQTT use with REGEX?

Hello Guys…
I’m starting to use MQTT, but would like an advice how to get on with it…
Is it correct that the REGEX should be used to filter the MQTT command to something like “ON” or “OFF”…

I’m a bit confused how to update the item from the mqtt? Do i need a rule or can it be done directly? I mean i receive a long string when something is published - but how do i check that i only update this one item and only when a specific mqtt item is posted?

Not necessarily.

Yes you will need a regex for this or if the string is JSON format then you can use the jsonpath transform

What do you mean?

What string do you receive?
Which bit of the “long” string are you interested in?
On what topic?
What item are you using?
Which bit of the “long” string are you interested in?

It’s for receiving status on my alarm system…
I could get following Topic:


and this message:
“update_time”: 1540234594756,
“status”: “closed”

Where i wanna see the zone number and from that check the “closed” from status and upddate an item to that state…

Meaning i wanna check this:
Zone1 status “open” or “closed” and put that into a switch item :slight_smile:

You need the MQTT binding (Of course)
And the JSONPATH transform installed

String myItem { mqtt="<[mybroker:/SPC/Zone1:state:JSONPATH($.status)]" }
Switch mySwitch


rule "Zone Switch"
    item myString changed
    if (myString.state == "open") mySwitch.postUpdate(ON)
    else if (myString == "closed") mySwitch.postUpdate(OFF)

Okay then I understand… so basically the string item could be used for controlling things… no need to put it in another item?