Automate Dashboard node cloning

I've setup this group of nodes/flows to process MQTT and Dashboard payloads for smart sockets running Tasmota. Now I'd like to clone the group for each different socket without having to edit all the nodes. I've tried to minimize the amount of editing needed (only the 3 nodes named 'edit') but at this time each dashboard node also has to be assigned to a group manually (at least I don't know how else to do it) and if I want to add items to the Vehicle dropdown then I have to do that for each socket. Any suggestions on how to streamline this more? If I use a subflow, I'm not sure how to handle the dashboard nodes. I originally did not plan for the dashboard nodes but added them as a way to learn how they work so I'm quite tempted to remove them, that would basically solve my inquiry.

[{"id":"813f8d9f.d31db","type":"group","z":"96854d35.bb36c8","name":"socket1_s31","style":{"label":true,"fill":"#d1d1d1","fill-opacity":"0.4","color":"#777777"},"nodes":["45cb8e67.ae3fe","158c9222.222efe","3b0dc497.2f73dc","cbd80cf5.16be5","bc6fc937.665438","5e630025.2b4b","93deb01f.b51cc8","8bc57644.9cd0d8","d8a7034c.b319a","12cc054c.f8e293","a5bbe8ba.d069b8","cf2e0286.06ca7","e315fd4b.4689b","9a203dad.aad0d8","239faf83.9411f","ecd07b47.083fc","5564577d.7b5a28","26a2695a.0eba46","3be5881f.2d8ed8","b1524a36.c69548","c1f666fc.6f158","92b85c69.1d51","5250c78f.fcaf48"],"x":14,"y":19,"w":792,"h":402},{"id":"45cb8e67.ae3fe","type":"bigtimer","z":"96854d35.bb36c8","g":"813f8d9f.d31db","outtopic":"power1","outpayload1":"ON","outpayload2":"OFF","name":"timer","comment":"comment","lat":"49.3171","lon":"-98.0585","starttime":"360","endtime":"840","startoff":"0","endoff":"0","startoff2":"","endoff2":"","offs":0,"outtext1":"ON","outtext2":"OFF","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":"","month7":"","day8":"","month8":"","day9":"","month9":"","day10":"","month10":"","day11":"","month11":"","day12":"","month12":"","d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xday7":"","xmonth7":"","xday8":"","xmonth8":"","xday9":"","xmonth9":"","xday10":"","xmonth10":"","xday11":"","xmonth11":"","xday12":"","xmonth12":"","xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"randon1":false,"randoff1":false,"randon2":false,"randoff2":false,"repeat":true,"atstart":false,"odd":false,"even":false,"x":370,"y":360,"wires":[["e315fd4b.4689b"],["93deb01f.b51cc8","92b85c69.1d51"],["158c9222.222efe"]],"outputLabels":["mqtt","","text"]},{"id":"158c9222.222efe","type":"ui_switch","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"","label":"State","tooltip":"","group":"4887617d.2cc85","order":4,"width":2,"height":1,"passthru":false,"decouple":"true","topic":"manual","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":530,"y":380,"wires":[["e315fd4b.4689b"]]},{"id":"3b0dc497.2f73dc","type":"ui_switch","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"","label":"Auto","tooltip":"","group":"4887617d.2cc85","order":6,"width":2,"height":1,"passthru":false,"decouple":"true","topic":"auto","topicType":"str","style":"","onvalue":"AUTO","onvalueType":"str","onicon":"","oncolor":"","offvalue":"MANUAL","offvalueType":"str","officon":"","offcolor":"","animate":true,"className":"","x":370,"y":200,"wires":[["e315fd4b.4689b"]]},{"id":"cbd80cf5.16be5","type":"mqtt in","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"edit","topic":"farm/sockets/socket1/+","qos":"1","datatype":"auto","broker":"74795e65.53b29","nl":false,"rap":false,"x":90,"y":60,"wires":[["d8a7034c.b319a","bc6fc937.665438","5564577d.7b5a28"]]},{"id":"bc6fc937.665438","type":"function","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"filter LWT - build Telegram msg","func":"// farm/sockets/[name]/LWT\n//   0     1      2     3\n\nvar topicSplit = msg.topic.split('/');\nif (topicSplit[topicSplit.length - 1] != \"LWT\") // -1 for last item in topic array\n    return null;\n\nvar newMsg = {\n    payload:\n    {\n//      chatId: 584467902,  // direct chat with Matt\n        chatId: -236996790, // \"Farm Test\" group\n        type: \"message\",\n        content: topicSplit[topicSplit.length - 2] + \": \" + msg.payload,\n    }\n}\n\nmsg.name = topicSplit[topicSplit.length - 2];\n\nreturn [newMsg, msg];","outputs":2,"noerr":0,"initialize":"","finalize":"","x":190,"y":120,"wires":[["5e630025.2b4b"],["8bc57644.9cd0d8","ecd07b47.083fc"]],"inputLabels":["[ON:OFF]"],"outputLabels":["telegram object",""]},{"id":"5e630025.2b4b","type":"telegram sender","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"esp8266test","bot":"3439faa0.e89296","haserroroutput":false,"outputs":1,"x":410,"y":100,"wires":[[]]},{"id":"93deb01f.b51cc8","type":"ui_text","z":"96854d35.bb36c8","g":"813f8d9f.d31db","group":"4887617d.2cc85","order":11,"width":4,"height":1,"name":"status msg","label":"","format":"{{msg.extState}}","layout":"row-right","x":710,"y":360,"wires":[]},{"id":"8bc57644.9cd0d8","type":"ui_text","z":"96854d35.bb36c8","g":"813f8d9f.d31db","group":"4887617d.2cc85","order":3,"width":3,"height":1,"name":"","label":"Status:","format":"{{msg.payload}}","layout":"row-right","x":559,"y":108,"wires":[]},{"id":"d8a7034c.b319a","type":"function","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"Tasmota to lowercase/retain","func":"// farm/sockets/[name]/[sub topic]\n//   0     1      2        3\n\nmsg.origTopic = msg.topic;\nvar topicSplit = msg.topic.split('/');\n//node.warn(topicSplit.length - 1);\n\n// analyze sub topic\n//  if any uppercase chars change to lowercase and pub with retain\n//  otherwise do nothing to prevent re-pub loops\n\nvar charArray = topicSplit[topicSplit.length - 1].split(\"\");\nfor(var i=0; i < charArray.length; i++){\n    if( charArray[i] >= 'A' && charArray[i] <= 'Z'){\n        topicSplit[topicSplit.length - 1] = topicSplit[topicSplit.length - 1].toLowerCase();\n        msg.topic = topicSplit.join('/');\n        msg.retain = true;\n        return msg;\n    }\n}\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":60,"wires":[["12cc054c.f8e293"]]},{"id":"12cc054c.f8e293","type":"mqtt out","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"","topic":"","qos":"1","retain":"true","broker":"74795e65.53b29","x":690,"y":60,"wires":[]},{"id":"a5bbe8ba.d069b8","type":"function","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"parse inputs","func":"// farm/sockets/[name]/cmd2/[cmd2 topics]\n//  0      1      2     3         4\n\n//msg.origTopic = msg.topic;\nvar topicSplit = msg.topic.split('/');\n//node.warn(topicSplit.length - 1);\n\nif (topicSplit[topicSplit.length - 1] == \"ontime\"){\n    //msg.payload = parseInt(msg.payload);\n    return [null, msg, null, null, {payload: \"on_override \" + msg.payload + \":00\"}];\n} else if (topicSplit[topicSplit.length - 1] == \"manual\"){\n    return [null, null, null, null, msg];\n} else if (topicSplit[topicSplit.length - 1] == \"auto\"){\n    return [msg, null, null, null, msg];\n} else if (topicSplit[topicSplit.length - 1] == \"offtime\"){\n    return [null, null, msg, null, {payload: \"off_override \" + msg.payload + \":00\"}];\n} else if (topicSplit[topicSplit.length - 1] == \"vehicle\"){\n    return [null, null, null, msg, null];\n}\n\nreturn null;","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":150,"y":340,"wires":[["3b0dc497.2f73dc"],["5250c78f.fcaf48"],["239faf83.9411f"],["c1f666fc.6f158"],["45cb8e67.ae3fe"]],"outputLabels":["Auto","OnTime","Off Time","Vehicle","Timer"]},{"id":"cf2e0286.06ca7","type":"mqtt in","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"edit","topic":"farm/sockets/socket1/cmd2/#","qos":"1","datatype":"auto","broker":"74795e65.53b29","x":110,"y":240,"wires":[["a5bbe8ba.d069b8"]]},{"id":"e315fd4b.4689b","type":"function","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"edit","func":"var name = \"socket1\";\nvar preTopic = \"farm/sockets/\" + name;\n\n// farm/sockets/[name]/cmd2/[sub topic]\n\nmsg.topicTag = msg.topic;\n\nif (msg.topicTag == \"ontime\"){\n    msg.topic = preTopic + \"/cmd2/ontime\";\n} else if (msg.topicTag == \"offtime\"){\n    msg.topic = preTopic + \"/cmd2/offtime\";\n} else if (msg.topicTag == \"manual\"){\n    msg.topic = preTopic + \"/cmd2/manual\";\n} else if (msg.topicTag == \"auto\"){\n    msg.topic = preTopic + \"/cmd2/auto\";\n} else if (msg.topicTag == \"power1\"){\n    msg.topic = preTopic + \"/cmnd/power1\";\n} else if (msg.topicTag == \"timermsg\"){\n    msg.topic = preTopic + \"/timermsg\";\n} else if (msg.topicTag == \"vehicle\"){\n    msg.topic = preTopic + \"/vehicle\";\n} else if (msg.topicTag == \"telem\"){\n    msg.topic = preTopic + \"/telem\";\n} else {\n    return null;\n}\n\nmsg.retain = true;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":690,"y":280,"wires":[["9a203dad.aad0d8"]]},{"id":"9a203dad.aad0d8","type":"mqtt out","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"","topic":"","qos":"1","retain":"true","broker":"74795e65.53b29","x":730,"y":220,"wires":[]},{"id":"239faf83.9411f","type":"ui_slider","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"","label":"Off Time","tooltip":"","group":"4887617d.2cc85","order":8,"width":4,"height":1,"passthru":false,"outs":"end","topic":"offtime","min":0,"max":"23","step":1,"x":380,"y":280,"wires":[["e315fd4b.4689b"]]},{"id":"ecd07b47.083fc","type":"ui_text","z":"96854d35.bb36c8","g":"813f8d9f.d31db","group":"4887617d.2cc85","order":1,"width":3,"height":1,"name":"","label":"Name:","format":"{{msg.name}}","layout":"row-left","x":690,"y":120,"wires":[]},{"id":"5564577d.7b5a28","type":"function","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"filter sensor","func":"// farm/sockets/[name]/sensor\n//  0      1      2      3\n\nvar topicSplit = msg.topic.split('/');\n\nif (topicSplit[topicSplit.length - 1] == \"sensor\"){\n    return msg;\n}\n\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":130,"y":160,"wires":[["3be5881f.2d8ed8"]]},{"id":"26a2695a.0eba46","type":"ui_text","z":"96854d35.bb36c8","g":"813f8d9f.d31db","group":"4887617d.2cc85","order":10,"width":4,"height":1,"name":"sensor telem","label":"","format":"{{msg.telem}}","layout":"row-left","x":710,"y":160,"wires":[]},{"id":"3be5881f.2d8ed8","type":"json","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"","property":"payload","action":"","pretty":false,"x":290,"y":160,"wires":[["b1524a36.c69548"]]},{"id":"b1524a36.c69548","type":"function","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"format telem","func":"msg.telem = msg.payload.ENERGY.Voltage + \"V \" + msg.payload.ENERGY.Current.toFixed(1) + \"A \" + \n    (msg.payload.ENERGY.Voltage * msg.payload.ENERGY.Current).toFixed(1) + \"W\";\n\nvar msg2 = {};\nmsg2.payload = msg.payload.ENERGY.Voltage + \"V\\r\\n\" + msg.payload.ENERGY.Current.toFixed(1) + \"A\\r\\n\" + \n    (msg.payload.ENERGY.Voltage * msg.payload.ENERGY.Current).toFixed(1) + \"W\";\nmsg2.topic = \"telem\";\n\nreturn [msg, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","x":450,"y":160,"wires":[["26a2695a.0eba46"],["e315fd4b.4689b"]]},{"id":"c1f666fc.6f158","type":"ui_dropdown","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"Vehicle","label":"","tooltip":"","place":"Select option","group":"4887617d.2cc85","order":2,"width":2,"height":1,"passthru":true,"multiple":false,"options":[{"label":"","value":"none","type":"str"},{"label":"","value":"Misc","type":"str"},{"label":"","value":"Binga","type":"str"},{"label":"","value":"Red Ford","type":"str"},{"label":"","value":"Blue GM","type":"str"},{"label":"","value":"Volvo","type":"str"},{"label":"","value":"Elias Case","type":"str"},{"label":"","value":"DSL Case","type":"str"},{"label":"","value":"Beast","type":"str"},{"label":"","value":"560 Auger","type":"str"},{"label":"","value":"Scraper Case","type":"str"},{"label":"","value":"8320T","type":"str"},{"label":"","value":"8410T","type":"str"},{"label":"","value":"4720","type":"str"}],"payload":"","topic":"vehicle","topicType":"str","className":"","x":380,"y":320,"wires":[["e315fd4b.4689b"]]},{"id":"92b85c69.1d51","type":"function","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"","func":"msg.topic = \"timermsg\";\nmsg.payload = msg.extState;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":555,"y":340,"wires":[["e315fd4b.4689b"]],"l":false},{"id":"5250c78f.fcaf48","type":"ui_dropdown","z":"96854d35.bb36c8","g":"813f8d9f.d31db","name":"On Time","label":"On Time","tooltip":"","place":"","group":"4887617d.2cc85","order":7,"width":4,"height":1,"passthru":false,"multiple":false,"options":[{"label":"0","value":"0","type":"str"},{"label":"1","value":"1","type":"str"},{"label":"2","value":"2","type":"str"},{"label":"3","value":"3","type":"str"},{"label":"4","value":"4","type":"str"},{"label":"","value":"5","type":"str"},{"label":"","value":"6","type":"str"},{"label":"","value":"7","type":"str"},{"label":"","value":"8","type":"str"},{"label":"","value":"9","type":"str"},{"label":"","value":"10","type":"str"},{"label":"","value":"11","type":"str"},{"label":"","value":"12","type":"str"},{"label":"","value":"13","type":"str"},{"label":"","value":"14","type":"str"},{"label":"","value":"15","type":"str"},{"label":"","value":"16","type":"str"},{"label":"","value":"17","type":"str"},{"label":"","value":"18","type":"str"},{"label":"","value":"19","type":"str"},{"label":"","value":"20","type":"str"},{"label":"","value":"21","type":"str"},{"label":"","value":"22","type":"str"},{"label":"","value":"23","type":"str"}],"payload":"","topic":"ontime","x":380,"y":240,"wires":[["e315fd4b.4689b"]]},{"id":"4887617d.2cc85","type":"ui_group","name":"Socket1_s31","tab":"bb4dc79a.2ffdf8","order":1,"disp":true,"width":"8","collapse":false},{"id":"74795e65.53b29","type":"mqtt-broker","name":"Docker Mosquitto 12.169","broker":"192.168.12.169","port":"1883","clientid":"node-red","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"3439faa0.e89296","type":"telegram bot","botname":"esp8266test","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"2000","usesocks":false,"sockshost":"","socksport":"","socksusername":"","sockspassword":"","bothost":"","localbotport":"","publicbotport":"","privatekey":"","certificate":"","useselfsignedcertificate":false,"verboselogging":false},{"id":"bb4dc79a.2ffdf8","type":"ui_tab","name":"Sockets","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.