Mqtt outgoing transformation

Hi i having problems with outgoing mqtt transformation

(Status/Set needs "amp=6" to set 6 amps.) Type string : Udenfor_0sal_forhave_goecharger_amp       "Ampere value for the PWM signaling"        [stateTopic="go-eCharger/014181/status", commandTopic="go-eCharger/014181/cmd/req", transformationPattern="JSONPATH:$.amp"]

Example from my things file, i get a 6 as status, but i need to sent a amp=6 to change the settings

i have 15-20 things that need this type of transformation.

Any ideas to fix this

Thanks Mads

You’ve looked at formatBeforePublish= parameter? MQTT Things and Channels - Bindings | openHAB

Yes i have looked at this, but cant figure out how to

I use this in other things on=“ON”, off=“OFF” this works perfectly

I tried to use 6=“amp=6”, 7=“amp=7” without luck

Thanks Mads

Make sure your Item and Channel are Number type, then use:

formatBeforePublish="amp=%d"

or

formatBeforePublish="amp=%.0f"
2 Likes

this fixed my problem

Make sure your Item and Channel are Number type, then use:

formatBeforePublish="amp=%d"

New things line looks like this

Type number : Udenfor_0sal_forhave_goecharger_amp		"Ampere value for the PWM signaling"	    [stateTopic="go-eCharger/014181/status", transformationPattern="JSONPATH:$.amp", commandTopic="go-eCharger/014181/cmd/req", formatBeforePublish="amp=%d"]

Thanks Mads