MQTT binding parameters question

I would like clarification on the parameters used in MQTT binding statement.
First, TYPE is either ‘command’ or ‘status’. What is the difference? I have tried both with different results, but I don’t understand how to specify them correctly.
Second, how does one use TRANSFORMATION? What does ‘default’ do?

Here is an example of an ‘item’ statement I use:

Switch gardenMotion “GardenMotion [MAP(gardenMotion.map):%d]” (all) {mqtt="<[mysensor:MyMQTT/3/1/V_TRIPPED:command:default"}

Thanks

In openHAB there two commands for updating an item: postUpdate and sendCommand. When you use postUpdate the item’s state will change but additional processing does not take place to propagate the change (e.g. if you postUpdate on a Switch and have a rule that triggers on “received command” that rule will not trigger). sendCommand on-the-other-hand will do this extra processing and event generation.

Typically for Switches, Contacts, Dimmers, etc use command and Text or DateTime items use postUpdate.

The transformation lets you convert the message that come in on the MQTT topic into a format that oepnHAB is better able to understand. For example, you might transform the message “active” to “ON” using a MAP, or extract one part of a long message using a regular expression.

The default transformation basically just passes the message through to the item’s state without any changes.

So in your item, when it receives a message will set gardenMotion’s state using sendCommand without changing the message in any way. Because gardenMotion is a switch, I would assume that the messages received are “ON” and “OFF” or “1” and “0”. Otherwise you probably need to add a MAP transform in place of “default” to convert the message to something openHAB understands as a Switch’s state.

4 Likes