Send a : in a MQTT Command

Hi i need to send a Colon as in the command like :
Switch ED001 {mqtt=">[openhab:mytopic/test:command:ON:{out12:1}],>[openhab:mytopic/test:command:OFF:{out12:0}]"}
but openhab interperates this wrong. is there a way around this?
Thanks Chris.

That ought to be possible with the transformation parameter at the end of the outbound binding string:

transformation : Rule defining how to create the message content. Transformations are defined in the format of TRANSFORMATION_NAME(transformation_function). Allowed values are ‘default’ or any of the transformers provided in the org.openhab.core.transform bundle. Custom transformations can be contributed directly to the transform bundle by making the Transformation available through Declarative Services. Any other value than the above types will be interpreted as static text, in which case this text is used as the message content. |

Another approach is to write a rule and use the MQTT publish action when a command is sent to the item.

thanks for quick response, but i’m pretty new to this, and don’t really understand. Where i have ‘{out12:x}’ i replace this with something that runs something else ?. i thought of running node red and using it to convert a valid text to what i need, but dont really want any more than nessescery running on my open hab raspberry. plus i really want to get to grips with openhab now i have got this far. i have run node red before its ok, but not as stable as openhab.

If you made a file like transform/


and changed your binding config to:

Switch ED001 { mqtt=">[openhab:mytopic/test:command:*:MAP(]" }

I believe (haven’t tried it) that the ON command will be mapped to {out12:1} which will be used as the message to publish to mytopic/test.

1 Like

i have to go out but will try later
many thanks

it worked !! thank you so much

1 Like

I’ve a similar situation and I’ve tried the solution but am not having such good luck.

If my Tasmota device reports power1 “OFF” I need to flip it to reporting “ON”.

FYI - I need to do the same flipping of the on/off when issuing commands to the device. I have this part working.
The reason for this is my relays are energised with a 0 on the GPIO.

Anyway I have the sending command working and I’'m trying to flip the incoming message using the same technique described earlier in this thread.
My line in my item file looks like this:

Switch GSonoff0104 "Front Lamp" <light> (LR,gLight) ["Lighting"] { mqtt=">[mosquitto:cmnd/GSONOFF01/POWER4:command:OFF:ON],>[mosquitto:cmnd/GSONOFF01/POWER4:command:ON:OFF], <[mosquitto:stat/GSONOFF01/POWER4:state:MAP(]"}

and I’ve placed a file named in /srv/openhab2-conf/transform directory which contains:


If I change the state of the device via Openhab all is fine. If it changes on the device I get this error in the openhab log and the state is not updated

2018-12-09 23:32:00.285 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type MAP
2018-12-09 23:32:00.291 [WARN ] [] - given new state is NULL, couldn't post update for 'GSonoff0104'

Do I need to do something more to get MAP working?

I had not installed the MAP transform. Doh!
So I’m going to hide under the desk now!