Read JSON from MQTT and send it back in a template help

Hi again

I am looking at this page: Centralite 3400-D control via MQTT | Zigbee2MQTT

It uses an example of receiving a published MQTT message in this format:

{
    "action": "arm_all_zones", // This is the example
    "action_code": "123", // The code being entered
    "action_zone": 0, // The zone being armed (always 0)
    "action_transaction": 99 // The transaction number
}

Then publishing a MQTT message in as a payload in this format:

{
    "arm_mode": {
        "transaction": 99, // Transaction number (this must be the same as the keypad request `action_transaction`)
        "mode": "arm_all_zones" // Mode (this must be the same as the keypad request `action`)
    }
}

So, I need to extract the “transaction” and the “mode” from the array and send it back in the requested format. I have been trying for hours, but I assume smarter people than me will have an elegant and simple solution.

Looking forward to any suggestions/solutions

Thanks

Hans

You could use a template node.

[{"id":"ec64c664c179673d","type":"inject","z":"f80b6c338afd5483","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"action\":\"arm_all_zones\",\"action_code\":\"123\",\"action_zone\":0,\"action_transaction\":99}","payloadType":"json","x":1010,"y":340,"wires":[["3b46ef7e08f1c8e1"]]},{"id":"ea79752275df8cba","type":"debug","z":"f80b6c338afd5483","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1430,"y":340,"wires":[]},{"id":"3b46ef7e08f1c8e1","type":"template","z":"f80b6c338afd5483","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n    \"arm_mode\": {\n        \"transaction\": {{payload.action_transaction}},\n        \"mode\": \"{{payload.action}}\"\n    }\n}","output":"str","x":1180,"y":340,"wires":[["ea79752275df8cba"]]}]

And it’s as simple as that… Thank you. I love this community