Catch mqtt topic via rules

Hi all!

Can I track mqtt topic in rules ?
For example: if in topic /aaa have message then do something (replace text item on received message)
AndI need in .rules only, not in .items because I need change received message and then output on any item.

1 Like

You can’t
You need to use the mqtt binding with an item to received messages
But you can do what I think you want

Have an item to receive the messages:

String MQTTreceivedMessage { mqtt="<[broker:topic:state:default]" }

Then in a rule:

rule "MQTT received"
when
    Item MQTTReceivedMessage changed
then
    val receivedString = MQTTReceivedMessage.state.toString
    // Do what you want
end

Thx for info. I know this method, but want without use temp item.
But I can make this item invisible…
Ok, thx.