JSONPatch and MAP in same Items

Hey!

I am trying to create buttons that control KNX devices. I use Node-Red to communicate with KNX Gateway. The messages come in Json format and are sent to MQTT.

Example of Json Structure:
Capture

The example below works but since I send the entire Json object in a message, I have to use MAP and JSONPATCH in the same Item. Is that even possible?

Switch KNX1140KanalC { mqtt="<[MqttNodeRED:knx-out/KanalBONOFF:state:MAP(onoff.map)],>[MqttNodeRED:knx-out/KanalBONOFF:command:ON:true],>[MqttNodeRED:knx-out/KanalBONOFF:command:OFF:false]" }

onoff.map

1=ON
0=OFF

Anyone who has any idea?

Mvh Rob

You can use only one transform per mqtt config (i.e one per [ ]). It is not clear from your description if that is what you are asking. If you want to use both JSONPath and MAP on the same mqtt config (e.g your incoming config that already has the MAP transform) the answer is no, you cannot use them both.

You can, however, use the JS transform to extract the value from the JSON and convert it to ON/OFF in JavaScript.

Thanks for the reply.

The example works but the “state” line does not work.
How do I get that button’s status updated automatically using MQTT?

Switch KNX1140  "KNX/MQTT Button C"	{ mqtt=">[MqttNodeRED:smedsbo-in/KNX1140KanalC:command:ON:true], 
											>[MqttNodeRED:smedsbo-in/KNX1140KanalC:command:OFF:false], 
											<[MqttNodeRED:smedsbo-out/KNX1140:state:JSONPATH(KanalC.ONOFF.value)]"}   //not working. sends from Node-RED

That is like saying “My car is stopped. How do I make it go?” To have any hope of helping you need to provide A LOT more information.

  • what have you done so far to identify the problem?
  • have you confirmed that messages are in fact being published to smedsbo-out/KNX1140?
  • have you looked in the logs for errors?
  • have you done anything to verify that the JSONPATH is working?

You need to narrow down the problem to one specific component in this long chain of subsystems. Then you can begin figuring out what specifically is wrong and how to fix it.