Hi. Im trying to set different properties to a button. But I am completely stuck.
I have succeeded to change background color and icon depending if msg.payload is true or false but I also want to change the label from an other path in the payload but I can't figure how to get this work in one function node.
Hope you under stand what I mean. Hard to explain.
Path to label is "payload.batch.event[0].argument[1].$.value" and I have an example output in the flow
Best regards Niclas
[{"id":"7fc9db75.09d914","type":"function","z":"d62f0d9d.6268a","name":"","func":"msg.payload = msg.payload.batch.event[0].$.name\n//msg.payload = msg.payload.batch.event[0].argument[1].$.value\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":900,"y":1880,"wires":[["197dc0f3.f91fbf"]]},{"id":"197dc0f3.f91fbf","type":"change","z":"d62f0d9d.6268a","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"controller.door.motorlock.locked","fromt":"str","to":"false","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"controller.door.motorlock.unlocked","fromt":"str","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":1880,"wires":[["84f3d7c1.6b2868","5a9f44c6.c6395c"]]},{"id":"84f3d7c1.6b2868","type":"function","z":"d62f0d9d.6268a","name":"Gate","func":"if (msg.payload === \"true\")node.send({ui_control:{icon:\"fa-2x fa-lock\"},bgcolor:\"green\",color:\"black\",label : msg.label,payload:msg.payload});\nif (msg.payload === \"false\")node.send({ui_control:{icon:\"fa-2x fa-unlock\"},bgcolor:\"red\",color:\"black\",label : msg.label,payload:msg.payload});\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1310,"y":1880,"wires":[["9efa0135.8264a"]]},{"id":"9efa0135.8264a","type":"ui_button","z":"d62f0d9d.6268a","name":"button","group":"d1877cae.519f1","order":11,"width":6,"height":1,"passthru":false,"label":"{{msg.label}}","tooltip":"","color":"{{msg.color}}","bgcolor":"{{msg.bgcolor}}","icon":"{{msg.icon}}","payload":"pushed","payloadType":"str","topic":"","x":1430,"y":1880,"wires":[[]]},{"id":"d7843691.eb2e98","type":"template","z":"d62f0d9d.6268a","name":"","field":"payload","fieldType":"msg","format":"text","syntax":"plain","template":"{\"batch\":{\"$\":{\"name\":\"controller.door.motorlock.unlocked.batch\"},\"event\":[{\"$\":{\"id\":\"10367816\",\"name\":\"controller.door.motorlock.unlocked\",\"type\":\"controller\",\"timestamp\":\"1602530902000\",\"domain\":\"4\",\"domainName\":\"Great Security KBA Energi gatan 3\"},\"argument\":[{\"$\":{\"value\":\"LCU\",\"type\":\"controller\",\"id\":\"11\"}},{\"_\":\"\\r\\n\\r\\naddress=0\\r\\n\\r\\n\",\"$\":{\"value\":\"Garage\",\"type\":\"dac\",\"id\":\"19\",\"externalId\":\"ID:19_20181001_142049\"}},{\"$\":{\"value\":\"Köksentre\",\"type\":\"door\",\"id\":\"14\"}}]}]}}","output":"json","x":1180,"y":1840,"wires":[["7fc9db75.09d914"]]},{"id":"680b079a.e985d8","type":"inject","z":"d62f0d9d.6268a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":960,"y":1840,"wires":[["d7843691.eb2e98"]]},{"id":"d1877cae.519f1","type":"ui_group","z":"","name":"Motorlås","tab":"8ae3ce41.59647","order":1,"disp":true,"width":6,"collapse":false},{"id":"8ae3ce41.59647","type":"ui_tab","z":"","name":"Maria Åkerberg AB","icon":"dashboard","disabled":false,"hidden":false}]