# Flow for mqtt and domotic

**URL:** <https://discourse.nodered.org/t/flow-for-mqtt-and-domotic/14505>\
**Category:** General\
**Created:** [19 August 2019 20:53 UTC](https://discourse.nodered.org/t/flow-for-mqtt-and-domotic/14505 "2019-08-19T20:53:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pvanklink](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@pvanklink](https://discourse.nodered.org/u/pvanklink)\
**Post date:** [19 August 2019 20:53 UTC](https://discourse.nodered.org/t/flow-for-mqtt-and-domotic/14505/1 "2019-08-19T20:53:27Z")

</div>

Hi, i like to pass complex IFTTT body content like this:  
[{"obj":"lantaarn1","act":"On"},{"obj":"lantaarn2","act":"On"}]  
in a variable (msg.payload.value = "compex received ifttt body"

as it is from IFTTT to MQTTT/domoticz and add two lines like this to the message with a function:  
msg.command = "setuservariable";  
msg.payload.idx = 12;

to this message so that domoticz puts this data in a uservariable ..see explanation in the function. I cant get this to work...

{  
"command":"setuservariable",   
"idx":"12",   
"Value":"[{"obj":"lantaarn","act":"Off"}]" \<original content as it is from iftt in var Value  
}

[{"id":"612f3ecd.84333","type":"tab","label":"test new uservar waaren","disabled":false,"info":""},{"id":"ca7a476f.2487f8","type":"mqtt out","z":"612f3ecd.84333","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"21fd69bf.668b46","x":910,"y":480,"wires":},{"id":"3a92b3cd.9606ec","type":"debug","z":"612f3ecd.84333","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":890,"y":420,"wires":},{"id":"2d6074a9.a954ac","type":"inject","z":"612f3ecd.84333","name":"nr1\_payload","topic":"","payload":"[{"obj":"lantaarn1","act":"On"},{"obj":"lantaarn2","act":"On"}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":420,"wires":[["2db3bdb1.8b92e2"]],"info":"[{"obj":"lantaarn","act":"On"}]\n\n\n"},{"id":"2db3bdb1.8b92e2","type":"function","z":"612f3ecd.84333","name":"make mqttt domoticz message","func":"msg.command = "setuservariable";\nmsg.payload.idx = 12;\n\n// here the complete message payload from nr1 must be part of ms.payload.value like this:\n// msg.payload.value = "[{"obj":"lantaarn","act":"On"},{"obj":"lantaarn","act":"On"}]"\n// the payload only has to contain: command="setuservariable", idx=12 and value="original payload content" \n// all the other content may be deleted\n\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":420,"wires":[["ca7a476f.2487f8","3a92b3cd.9606ec"]]},{"id":"21fd69bf.668b46","type":"mqtt-broker","z":"","name":"mqttdomoticz","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

when this content is pasted in a uservar, my script in domoticz can read this json format and execute all devices...
