Send Json string to MQTT without transformation

I need to send a Json message to MQTT
I do not get the Json transformation to work, and I will be sending static commands so I do not really need the transformation.

My plan was to put the Json command this in a rule:

HP_Publish.sendCommand("{"power":"ON","mode":"FAN","temperature":24,"fan":"4","vane":"1","wideVane":"SWING"}")

There are to many " signes in that command, is there some way to solve that?

HP_Publish item is:

String HP_Publish							    "Heat Pump Publish"			{ mqtt=">[broker_no_Retain:home/heatpump/set:command:command:*:default]" }

Is it at all possible to use this code to send the MQTT Json?

Wrap the whole string in single quotes '

HP_Publish.sendCommand('"{"power":"ON","mode":"FAN","temperature":24,"fan":"4","vane":"1","wideVane":"SWING"}"')

Or escape the quotes with a backslash \

HP_Publish.sendCommand("{\"power\":\"ON\",\"mode\":\"FAN\",\"temperature\":24,\"fan\":\"4\",\"vane\":\"1\",\"wideVane\":\"SWING\"}")
1 Like