MQTT 2.4 - publish Json formatted "command" to Channel

A friend and myself are developing a IOT based Dog Feeder …

The feeder expects a JSON formatted string to be published on a specific MQTT channel to operate

Pretty much all i need is to send : {“volume”:“5”,“feeder”:“true,”} to the following channel GG-SmartHouse/DogFeeder/in

im already using Generic MQTT Things to receive on MQTT topics (OH2.4) … and have used the older format in OH2.3 for sending simple commands like ON/OFF to devices like lighbulbs etc …

I have no idea how to send a JSON formated command to a Generic MQTT Thing ???

its not really intuitive … i have created the thing via the paper UI as a “string” type , adding in the command topic as GG-SmartHouse/DogFeeder/in

i have created a “switch” item and linked it to the Thing . but im not sure how to format the JSON data into the ITEM

Switch DogFeederOperate “Dog Feeder” [ “Switchable” ] {channel=“mqtt:topic:57311b29:1”}

Any assistance appreciated please

Thx
Greg

Sounds like a job for an outbound transformation. In this case of ON -> fixed text, a MAP should do.

To elaborate just a bit on rossko57’s answer, you don’t put the transform on the Item. You put it on the Thing’s Channel. You may not even need the MAP transform if you want to send that command exactly as it is when the Switch receives ON. You can use a Custom On/Open value

Hi

Thx for the reply … stupid question but i dont see the “custom” field on my channel config ?

You may need to update to OH 2.5 M1 then. I forget what got added to the binding when. There are a bunch of known bugs in MQTT 2.4 though so an upgrade would be advised anyway.