MQTT 2 CommandTopic configuration

Hi,

actually i try to define a MQTT Thing through config files. Incoming Updates are working finde, but at some Points i need to set States vie MQTT.

The config looks like:

Type number : goeCharger_Ampere “goe Ampere Soll” [ stateTopic=“go-eCharger/000xxx/status”, commandTopic=“go-eCharger/000xxx/cmd/req”, transformationPattern=“JSONPATH:$.amp”]

but I have to set a prefix for the Outgoing Messages: “amp=”. Where should this be defined?

Please help.

Thanks & Greetings

vlamers

You want this: https://www.openhab.org/addons/bindings/mqtt.generic/#format-before-publish.

The correct key to be used in a textual config file can be seen here: https://www.openhab.org/addons/bindings/mqtt.generic/#channel-configuration

As you can see it helps a lot by studying the binding documentation :slight_smile:

1 Like

:man_facepalming:t2: i searched for hours but didnt find this documentation.
Thanks for your help and sorry for the question!

Unfortunately my mqtt command is still not working.
My MQTT Thing looks like:

Type number : goeCharger_Ampere "goe Ampere Soll" [ stateTopic="go-eCharger/000xxx/status", commandTopic="go-eCharger/000xxx/cmd/req", formatBeforePublish="amp=%s", transformationPattern="JSONPATH:$.amp"]

And the MQTT Command has to look like:

mosquitto_pub -h localhost -p 1883 -u xxx-P yyy-t 'go-eCharger/000xxx/cmd/req' -m amp=16

Where is my fault?

Thx!

I got it running with mqtt, but setup wit PaperUI. Did you check with an mqtt client what openhab finally posts on this channel?