Skip to content

Instantly share code, notes, and snippets.

@mhelff
Last active December 14, 2020 10:07
Show Gist options
  • Save mhelff/7c809ced79e9240286d660b622d84120 to your computer and use it in GitHub Desktop.
Save mhelff/7c809ced79e9240286d660b622d84120 to your computer and use it in GitHub Desktop.
Zigbee2mqtt Admin panel
[{"id":"1112a3ea.54efdc","type":"tab","label":"Z2M Admin","disabled":false,"info":""},{"id":"fe321b77.50b858","type":"function","z":"1112a3ea.54efdc","name":"Format Data","func":"var groupname = msg.groupname;\nvar device = flow.get('device');\n\nif (typeof groupname !== undefined && typeof device !== undefined) {\n var action = \"Adding \";\n var what = \" to group \";\n if(msg.payload == \"remove\") {\n action = \"Removing \";\n what = \" from group \";\n }\nvar msg1 = { payload: device, topic: \"zigbee2mqtt/bridge/group/\" + groupname + \"/\" + msg.payload};\nvar msg2 = { payload: action + \" \" + device + what + groupname };\n\nreturn [msg1, msg2];\n}","outputs":2,"noerr":0,"x":770,"y":1980,"wires":[["67f130eb.efef3","f10dea4c.a81728"],["89490386.cf438"]]},{"id":"89490386.cf438","type":"ui_toast","z":"1112a3ea.54efdc","position":"top right","displayTime":"5","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":920,"y":2020,"wires":[]},{"id":"d7c7c87a.3b1e58","type":"comment","z":"1112a3ea.54efdc","name":"Group management","info":"","x":130,"y":1460,"wires":[]},{"id":"fae942d1.d6e91","type":"function","z":"1112a3ea.54efdc","name":"Format Data","func":"var srcdev = flow.get('device');\nvar bindtarget = flow.get('bindtarget');\n\nif (typeof srcdev !== undefined && typeof bindtarget !== undefined) {\n msg1 = { 'payload': bindtarget, 'topic': 'zigbee2mqtt/bridge/' + msg.payload + '/' + srcdev};\n msg2 = { 'payload': msg.payload + ' ' + srcdev + ' to target ' + bindtarget };\n\n return [msg1, msg2];\n}","outputs":2,"noerr":0,"x":750,"y":2320,"wires":[["bf8faaff.5215b8"],["a7b346c6.0c9d18"]]},{"id":"a29bad1b.88ab","type":"ui_button","z":"1112a3ea.54efdc","name":"","group":"38009ddc.858562","order":11,"width":"3","height":"1","passthru":false,"label":"Bind device","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Bind","payloadType":"str","topic":"","x":110,"y":2300,"wires":[["4d02aaf3.2fbb24"]]},{"id":"1352a9c5.0a7b96","type":"mqtt in","z":"1112a3ea.54efdc","name":"","topic":"zigbee2mqtt/#","qos":"2","datatype":"utf8","broker":"f5594d13.23bec","x":110,"y":100,"wires":[["5564a681.f2b1d8"]]},{"id":"a600ffb3.fdd1b","type":"switch","z":"1112a3ea.54efdc","name":"log type","property":"payload.type","propertyType":"msg","rules":[{"t":"eq","v":"devices","vt":"str"},{"t":"eq","v":"groups","vt":"str"},{"t":"eq","v":"zigbee_publish_error","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":4,"x":540,"y":540,"wires":[["dc9da24.290da6"],["4b369b1.1c23164"],["a4e5b5d9.2c3e88"],["e3b7ead2.4ac6f8"]]},{"id":"ba524055.a6136","type":"json","z":"1112a3ea.54efdc","name":"","property":"payload","action":"","pretty":false,"x":410,"y":540,"wires":[["a600ffb3.fdd1b"]]},{"id":"dc9da24.290da6","type":"link out","z":"1112a3ea.54efdc","name":"Z2M LOG DEVICELIST","links":["28c00ddc.4dea62","94e9b5e4.4a4158"],"x":695,"y":500,"wires":[]},{"id":"87ab5849.f09d28","type":"function","z":"1112a3ea.54efdc","name":"Reformat for list","func":"newPayload = [];\nmsg.payload.message.forEach(function(entry) {\n if(entry.type != 'Coordinator') {\n newentry = {'title': entry.friendly_name, \n 'description': entry.model + ' (' + entry.ieeeAddr + ')',\n 'icon': 'https://www.zigbee2mqtt.io/images/devices/' + entry.model.replace(new RegExp('/', 'g'), '-') + '.jpg'\n };\n newPayload.push(newentry);\n }\n});\n\nmsg.payload=newPayload;\nreturn msg;\n","outputs":1,"noerr":0,"x":180,"y":920,"wires":[["6c06b987.6f7098"]]},{"id":"28c00ddc.4dea62","type":"link in","z":"1112a3ea.54efdc","name":"Z2M DEV LIST INPUT","links":["dc9da24.290da6"],"x":55,"y":940,"wires":[["87ab5849.f09d28","f3505bcc.2352d8"]]},{"id":"6c06b987.6f7098","type":"ui_list","z":"1112a3ea.54efdc","group":"902c151e.212a38","name":"Devices","order":1,"width":"6","height":"11","lineType":"three","actionType":"click","allowHTML":true,"x":340,"y":920,"wires":[["9fa73b15.846b38"]]},{"id":"9fa73b15.846b38","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"device","pt":"flow","to":"payload.title","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":960,"wires":[["1a63fe7a.9d0142","4b968044.ca533","4d2d1114.f6adf","8eadd875.984dc8"]]},{"id":"ab86c3a1.ed149","type":"mqtt out","z":"1112a3ea.54efdc","name":"Generic output","topic":"","qos":"","retain":"false","broker":"f5594d13.23bec","x":420,"y":160,"wires":[]},{"id":"398af7a3.80e388","type":"link in","z":"1112a3ea.54efdc","name":"Z2M GENERIC MQTT OUT","links":["67f130eb.efef3","458d2db0.4f1c14","3b86e8ee.a04ed8","632c3105.5495f","bf8faaff.5215b8","75d20744.52cef8","207b74ec.1d3f1c","699fc636.402658","ec7b44f2.6b8df8"],"x":55,"y":160,"wires":[["ab86c3a1.ed149"]]},{"id":"67f130eb.efef3","type":"link out","z":"1112a3ea.54efdc","name":"Z2M GROUP BIND OUT","links":["398af7a3.80e388"],"x":875,"y":1960,"wires":[]},{"id":"f3505bcc.2352d8","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"devices","pt":"flow","to":"payload.message","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":960,"wires":[[]]},{"id":"1a63fe7a.9d0142","type":"function","z":"1112a3ea.54efdc","name":"Lookup device details","func":"devices = flow.get('devices');\n\nfor (var i in devices) {\n if(devices[i].friendly_name == msg.payload.title) {\n flow.set('seldevice_details', devices[i]);\n msg.payload = devices[i];\n return msg;\n }\n}\n\nmsg.payload.friendly_name='unknown';\nreturn msg;\n","outputs":1,"noerr":0,"x":620,"y":960,"wires":[["46646ab3.510094"]]},{"id":"9de0998d.8b3668","type":"function","z":"1112a3ea.54efdc","name":"Reformat for dropdown","func":"newPayload = [];\nmsg.payload.message.forEach(function(entry) {\n newPayload.push(entry.friendly_name);\n});\n\nnewMsg = {'payload': flow.get('bindtarget'), 'options': newPayload};\n\nreturn newMsg;\n","outputs":1,"noerr":0,"x":200,"y":2240,"wires":[["ce73ad6f.0b69"]]},{"id":"94e9b5e4.4a4158","type":"link in","z":"1112a3ea.54efdc","name":"Z2M BIND LIST INPUT","links":["dc9da24.290da6"],"x":55,"y":2240,"wires":[["9de0998d.8b3668"]]},{"id":"ce73ad6f.0b69","type":"ui_dropdown","z":"1112a3ea.54efdc","name":"","label":"Target device","tooltip":"","place":"Select target device","group":"38009ddc.858562","order":10,"width":"6","height":"1","passthru":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":410,"y":2240,"wires":[["74886cbc.2a0f14"]]},{"id":"74886cbc.2a0f14","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"bindtarget","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":2240,"wires":[[]]},{"id":"c1eb42c4.f454a","type":"inject","z":"1112a3ea.54efdc","name":"","topic":"","payload":"","payloadType":"date","repeat":"6","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":1140,"wires":[["ba7821e1.93e46"]]},{"id":"260ce836.2e4f98","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"bridgestate","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":480,"wires":[[]]},{"id":"14507948.bc92c7","type":"ui_button","z":"1112a3ea.54efdc","name":"","group":"38009ddc.858562","order":12,"width":"3","height":"1","passthru":false,"label":"Unbind device","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Unbind","payloadType":"str","topic":"","x":120,"y":2340,"wires":[["2862cc.8a6c4d34"]]},{"id":"463d3907.451408","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Add device <b>{{flow.device}}</b> to group <b>{{groupname}}</b>?","output":"str","x":320,"y":1960,"wires":[["d1c4f87f.dbce28"]]},{"id":"d1c4f87f.dbce28","type":"ui_toast","z":"1112a3ea.54efdc","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"add","cancel":"cancel","topic":"Add to group","name":"","x":470,"y":1960,"wires":[["b7ebccd6.217c7"]]},{"id":"b7ebccd6.217c7","type":"switch","z":"1112a3ea.54efdc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"add","vt":"str"},{"t":"eq","v":"remove","vt":"str"},{"t":"eq","v":"cancel","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":630,"y":1980,"wires":[["fe321b77.50b858"],["fe321b77.50b858"],[]]},{"id":"3b260768.9d2d38","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Remove device <b>{{flow.device}}</b> from group <b>{{groupname}}</b>?","output":"str","x":320,"y":2000,"wires":[["99104ccd.a2827"]]},{"id":"99104ccd.a2827","type":"ui_toast","z":"1112a3ea.54efdc","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"remove","cancel":"cancel","topic":"Remove from group","name":"","x":470,"y":2000,"wires":[["b7ebccd6.217c7"]]},{"id":"4d02aaf3.2fbb24","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}} device <b>{{flow.device}}</b> to <b>{{flow.bindtarget}}</b>?","output":"str","x":280,"y":2300,"wires":[["28efb09d.6d9cb"]]},{"id":"28efb09d.6d9cb","type":"ui_toast","z":"1112a3ea.54efdc","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"bind","cancel":"cancel","topic":"Bind device","name":"","x":430,"y":2300,"wires":[["5f4235aa.d48c2c"]]},{"id":"2862cc.8a6c4d34","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}} device <b>{{flow.device}}</b> from <b>{{flow.bindtarget}}</b>?","output":"str","x":280,"y":2340,"wires":[["b41dcb39.fffc48"]]},{"id":"b41dcb39.fffc48","type":"ui_toast","z":"1112a3ea.54efdc","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"unbind","cancel":"cancel","topic":"Unbind device","name":"","x":430,"y":2340,"wires":[["5f4235aa.d48c2c"]]},{"id":"5f4235aa.d48c2c","type":"switch","z":"1112a3ea.54efdc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"bind","vt":"str"},{"t":"eq","v":"unbind","vt":"str"},{"t":"eq","v":"cancel","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":590,"y":2320,"wires":[["fae942d1.d6e91"],["fae942d1.d6e91"],[]]},{"id":"af2bd47b.bb43c8","type":"ui_text_input","z":"1112a3ea.54efdc","name":"","label":"New device name","tooltip":"","group":"38009ddc.858562","order":4,"width":"6","height":"1","passthru":true,"mode":"text","delay":"100","topic":"","x":130,"y":1860,"wires":[["740e14d9.a5ad0c"]]},{"id":"67a03950.a9be58","type":"comment","z":"1112a3ea.54efdc","name":"Device management","info":"","x":130,"y":1740,"wires":[]},{"id":"740e14d9.a5ad0c","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"newdevicename","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":1860,"wires":[[]]},{"id":"3f245891.878948","type":"ui_button","z":"1112a3ea.54efdc","name":"","group":"38009ddc.858562","order":5,"width":"6","height":"1","passthru":false,"label":"Rename device","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Rename","payloadType":"str","topic":"","x":120,"y":2140,"wires":[["16376b86.70cdb4"]]},{"id":"16376b86.70cdb4","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}} device <b>{{flow.device}}</b> to <b>{{flow.newdevicename}}</b>?","output":"str","x":280,"y":2140,"wires":[["1c5b4126.8d8daf"]]},{"id":"1c5b4126.8d8daf","type":"ui_toast","z":"1112a3ea.54efdc","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"rename","cancel":"cancel","topic":"Rename device","name":"","x":430,"y":2140,"wires":[["c65c2cb3.8fafb"]]},{"id":"c65c2cb3.8fafb","type":"switch","z":"1112a3ea.54efdc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"rename","vt":"str"},{"t":"eq","v":"cancel","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":570,"y":2140,"wires":[["6a0ab4e.825834c"],[]]},{"id":"6a0ab4e.825834c","type":"function","z":"1112a3ea.54efdc","name":"Format Data","func":"var oldname = flow.get('device');\nvar newname = flow.get('newdevicename');\n\nif (typeof oldname !== undefined && typeof newname !== undefined) {\n msg1 = { 'payload': {\"old\": oldname, \"new\": newname}, 'topic': 'zigbee2mqtt/bridge/config/rename'};\n msg2 = { 'payload': msg.payload + ' ' + oldname + ' to ' + newname };\n\n return [msg1, msg2];\n}","outputs":2,"noerr":0,"x":730,"y":2140,"wires":[["75d20744.52cef8"],["6c972cc3.1c1ce4"]]},{"id":"6c972cc3.1c1ce4","type":"ui_toast","z":"1112a3ea.54efdc","position":"top right","displayTime":"5","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":790,"y":2200,"wires":[]},{"id":"6d78e825.7722f8","type":"switch","z":"1112a3ea.54efdc","name":"","property":"topic","propertyType":"msg","rules":[{"t":"regex","v":".*/bridge/state","vt":"str","case":false},{"t":"regex","v":".*/bridge/log","vt":"str","case":false},{"t":"regex","v":".*/bridge/config$","vt":"str","case":false},{"t":"regex","v":".*/networkmap/graphviz$","vt":"str","case":false},{"t":"regex","v":".*/bridge/config/.*","vt":"str","case":false},{"t":"regex","v":"^(?!.*get$|.*set$).*$","vt":"str","case":false}],"checkall":"false","repair":false,"outputs":6,"x":230,"y":540,"wires":[["260ce836.2e4f98"],["ba524055.a6136"],["3d8a0b9a.aa0504"],["162ed5bf.58dd8a"],[],["d3fbf1d9.d4525"]]},{"id":"3d8a0b9a.aa0504","type":"json","z":"1112a3ea.54efdc","name":"","property":"payload","action":"","pretty":false,"x":410,"y":620,"wires":[["619cfbc2.0293b4"]]},{"id":"619cfbc2.0293b4","type":"link out","z":"1112a3ea.54efdc","name":"Z2M BRIDGE CONFIG INPUT","links":["d983172a.616bc8"],"x":515,"y":620,"wires":[]},{"id":"61a80af8.34eb64","type":"ui_switch","z":"1112a3ea.54efdc","name":"","label":"Permit join","tooltip":"","group":"d40979a3.d11a08","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"zigbee2mqtt/bridge/config/permit_join","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":470,"y":1280,"wires":[["3b86e8ee.a04ed8"]]},{"id":"aef8aa15.a42ce8","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"move","p":"payload.permit_join","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":1280,"wires":[["61a80af8.34eb64"]]},{"id":"d983172a.616bc8","type":"link in","z":"1112a3ea.54efdc","name":"Z2M BRIDGE CONFIG","links":["619cfbc2.0293b4"],"x":55,"y":1280,"wires":[["aef8aa15.a42ce8","67251463.751fec","be14f64d.ceb358","56f299a2.6327d8"]]},{"id":"2efc8bac.a29ab4","type":"ui_dropdown","z":"1112a3ea.54efdc","name":"","label":"Log level","tooltip":"","place":"Select log level","group":"d40979a3.d11a08","order":2,"width":0,"height":0,"passthru":false,"options":[{"label":"Info","value":"info","type":"str"},{"label":"Debug","value":"debug","type":"str"},{"label":"Warn","value":"warn","type":"str"},{"label":"Error","value":"error","type":"str"}],"payload":"","topic":"zigbee2mqtt/bridge/config/log_level","x":460,"y":1320,"wires":[["3b86e8ee.a04ed8"]]},{"id":"3b86e8ee.a04ed8","type":"link out","z":"1112a3ea.54efdc","name":"Z2M BRIDGE CONFIG OUT","links":["398af7a3.80e388"],"x":615,"y":1300,"wires":[]},{"id":"67251463.751fec","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"move","p":"payload.log_level","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":1320,"wires":[["2efc8bac.a29ab4"]]},{"id":"e3b7ead2.4ac6f8","type":"link out","z":"1112a3ea.54efdc","name":"Z2M NOTIFICATIONS OUT","links":["71034afb.6773f4"],"x":695,"y":600,"wires":[]},{"id":"b2123a08.a7deb8","type":"ui_toast","z":"1112a3ea.54efdc","position":"top right","displayTime":"3","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":840,"y":2600,"wires":[]},{"id":"71034afb.6773f4","type":"link in","z":"1112a3ea.54efdc","name":"Z2M NOTIFICATIONS INPUT","links":["e3b7ead2.4ac6f8"],"x":65,"y":2580,"wires":[["f24e73c5.e5cad"]]},{"id":"7d4fa71c.1ec908","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.type","tot":"msg"},{"t":"move","p":"payload.message","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":2680,"wires":[["b2123a08.a7deb8"]]},{"id":"7475bcd5.f978c4","type":"comment","z":"1112a3ea.54efdc","name":"Bridge status","info":"","x":110,"y":1100,"wires":[]},{"id":"99d65db9.18641","type":"ui_button","z":"1112a3ea.54efdc","name":"remove device","group":"38009ddc.858562","order":2,"width":"6","height":"1","passthru":false,"label":"Remove device","tooltip":"","color":"","bgcolor":"","icon":"","payload":"remove","payloadType":"str","topic":"","x":120,"y":1820,"wires":[["d0e1401d.17d42"]]},{"id":"d0e1401d.17d42","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}} device <b>{{flow.device}}</b> permanently?","output":"str","x":280,"y":1820,"wires":[["215d69ec.df3ec6"]]},{"id":"215d69ec.df3ec6","type":"ui_toast","z":"1112a3ea.54efdc","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"remove","cancel":"cancel","topic":"Remove device","name":"","x":430,"y":1820,"wires":[["cc05901d.7d2bb"]]},{"id":"cc05901d.7d2bb","type":"switch","z":"1112a3ea.54efdc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"remove","vt":"str"},{"t":"eq","v":"cancel","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":570,"y":1820,"wires":[["d44c81f5.d4712"],[]]},{"id":"d44c81f5.d4712","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"zigbee2mqtt/bridge/config/remove","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"device","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":1820,"wires":[["207b74ec.1d3f1c"]]},{"id":"4fe45eac.983e","type":"ui_text","z":"1112a3ea.54efdc","group":"d40979a3.d11a08","order":4,"width":"0","height":"0","name":"","label":"Status","format":"{{msg.payload.bridgestate}}","layout":"row-left","x":510,"y":1200,"wires":[]},{"id":"d36f839f.5fd8a","type":"ui_text","z":"1112a3ea.54efdc","group":"d40979a3.d11a08","order":7,"width":"0","height":"0","name":"","label":"Devices","format":"{{msg.payload.numdevices}}","layout":"row-left","x":520,"y":1160,"wires":[]},{"id":"ba7821e1.93e46","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.numdevices","pt":"msg","to":"devices.length","tot":"flow"},{"t":"set","p":"payload.bridgestate","pt":"msg","to":"bridgestate","tot":"flow"},{"t":"set","p":"payload.nwlast","pt":"msg","to":"networkmap_last","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":1140,"wires":[["d36f839f.5fd8a","4fe45eac.983e","7e27d95b.8f7028"]]},{"id":"46646ab3.510094","type":"function","z":"1112a3ea.54efdc","name":"Reformat for details","func":"newPayload = [];\n\nnewentry = {\n 'title': msg.payload.friendly_name,\n 'description': 'zigbee2mqtt/' + msg.payload.friendly_name,\n 'icon': 'https://www.zigbee2mqtt.io/images/logo.png'\n};\nnewPayload.push(newentry);\nnewentry = {\n 'title': msg.payload.ieeeAddr,\n 'description': 'NwkAddr: ' + msg.payload.nwkAddr + ' / manufId: ' + msg.payload.manufId,\n 'icon_name': 'settings_input_antenna'\n};\nnewPayload.push(newentry);\nnewentry = { \n 'title': msg.payload.model,\n 'description': msg.payload.modelId,\n 'icon': 'https://www.zigbee2mqtt.io/images/devices/' + msg.payload.model.replace(new RegExp('/', 'g'), '-') + '.jpg'\n};\nnewPayload.push(newentry);\nnewentry = { \n 'title': msg.payload.manufName,\n 'description': 'HW: ' + msg.payload.hwVersion + ' / SW: ' + msg.payload.swBuildId,\n 'icon_name': 'bookmark'\n};\nnewPayload.push(newentry);\nvar type_icon = msg.payload.type=='Router' ? 'device_hub' : 'input';\nnewentry = {\n 'title': msg.payload.type,\n 'description': 'Powersource: ' + msg.payload.powerSource,\n 'icon_name': type_icon\n};\nnewPayload.push(newentry);\n\nmsg.payload=newPayload;\nreturn msg;\n","outputs":1,"noerr":0,"x":630,"y":1020,"wires":[["2694bda5.0e1732"]]},{"id":"162ed5bf.58dd8a","type":"change","z":"1112a3ea.54efdc","name":"save networkmap","rules":[{"t":"set","p":"networkmap","pt":"flow","to":"payload","tot":"msg"},{"t":"set","p":"networkmap_last","pt":"flow","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":680,"wires":[["9596b7ff.dac428"]]},{"id":"5857ba56.3a5444","type":"http in","z":"1112a3ea.54efdc","name":"","url":"/z2mpanel/networkmap","method":"get","upload":false,"swaggerDoc":"","x":160,"y":3080,"wires":[["368af09e.feec5"]]},{"id":"368af09e.feec5","type":"template","z":"1112a3ea.54efdc","name":"Render page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n <meta charset=\"utf-8\">\n <title>Network topology</title>\n <style>\n #graphviz_svg_div svg {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n \n </style>\n </head>\n <body>\n <div id=\"graphviz_svg_div\"></div>\n <script language=\"javascript\" type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/npm/[email protected]/viz.js\"></script>\n <script language=\"javascript\" type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/npm/[email protected]/full.render.js\"></script>\n <script language=\"javascript\" type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/svg-pan-zoom.min.js\"></script>\n <script type=\"bogus\" id=\"graphviz_input\">\n {{{flow.networkmap}}}\n </script>\n <script language=\"javascript\" type=\"text/javascript\">\n document.addEventListener(\"DOMContentLoaded\", function(event) {\n var viz = new Viz();\n var svg = document.getElementById(\"graphviz_input\").innerHTML;\n viz.renderSVGElement(svg, {engine: \"{{{flow.nwrenderengine}}}\"})\n .then(function(element) {\n document.getElementById(\"graphviz_svg_div\").appendChild(element);\n panZoom = svgPanZoom(element, {\n zoomEnabled: true,\n controlIconsEnabled: true,\n fit: true,\n center: true,\n minZoom: 0.1\n });\n\n element.addEventListener('paneresize', function(e) {\n panZoom.resize();\n }, false);\n window.addEventListener('resize', function(e) {\n panZoom.resize();\n });\n })\n .catch(error => {\n // Create a new Viz instance (@see Caveats page for more info)\n viz = new Viz();\n\n // Possibly display the error\n console.error(error);\n });\n //var svg = Viz(document.getElementById(\"graphviz_input\").innerHTML, \"svg\", {render: \"circo\"});\n //document.getElementById(\"graphviz_svg_div\").innerHTML = svg;\n });\n </script>\n </body>\n</html>","output":"str","x":450,"y":3080,"wires":[["65139275.6e325c"]]},{"id":"65139275.6e325c","type":"http response","z":"1112a3ea.54efdc","name":"","statusCode":"","headers":{},"x":650,"y":3080,"wires":[]},{"id":"2ba4c4f9.de559c","type":"ui_template","z":"1112a3ea.54efdc","group":"fd4925c4.d13458","name":"iframe nw map","order":0,"width":"27","height":"11","format":"<iframe frameborder=\"0\" width=\"100%\" height=\"100%\" src=\"/z2mpanel/networkmap\"></iframe>","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":120,"y":3040,"wires":[[]]},{"id":"2694bda5.0e1732","type":"ui_list","z":"1112a3ea.54efdc","group":"ee188496.59ff28","name":"Selected device","order":1,"width":"6","height":"7","lineType":"three","actionType":"none","allowHTML":true,"x":820,"y":1020,"wires":[[]]},{"id":"5821943.e8f1e6c","type":"comment","z":"1112a3ea.54efdc","name":"Device list & selected device","info":"","x":160,"y":880,"wires":[]},{"id":"202259f7.b7a9c6","type":"inject","z":"1112a3ea.54efdc","name":"Create network map","topic":"zigbee2mqtt/bridge/networkmap","payload":"graphviz","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"10","x":130,"y":200,"wires":[["ab86c3a1.ed149"]]},{"id":"dcf15903.6ff8e8","type":"inject","z":"1112a3ea.54efdc","name":"Request Device List","topic":"zigbee2mqtt/bridge/config/devices/get","payload":"","payloadType":"date","repeat":"5","crontab":"","once":true,"onceDelay":0.1,"x":140,"y":240,"wires":[["ab86c3a1.ed149"]]},{"id":"f24e73c5.e5cad","type":"switch","z":"1112a3ea.54efdc","name":"","property":"payload.type","propertyType":"msg","rules":[{"t":"eq","v":"pairing","vt":"str"},{"t":"eq","v":"device_connected","vt":"str"},{"t":"eq","v":"device_removed","vt":"str"},{"t":"istype","v":"object","vt":"object"},{"t":"else"}],"checkall":"false","repair":false,"outputs":5,"x":160,"y":2580,"wires":[["1e0e2fff.2eee5"],["eaaa0045.a639"],["51ff0ea1.0a919"],["8ae66b7.1c0af98"],["7d4fa71c.1ec908"]]},{"id":"1e0e2fff.2eee5","type":"switch","z":"1112a3ea.54efdc","name":"","property":"payload.message","propertyType":"msg","rules":[{"t":"eq","v":"connecting with device","vt":"str"},{"t":"eq","v":"device incoming","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":320,"y":2480,"wires":[["2d86241a.ba284c"],["7fc722db.eb28ac"]]},{"id":"2d86241a.ba284c","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"A device is attempting to pair...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":2460,"wires":[["b2123a08.a7deb8"]]},{"id":"7fc722db.eb28ac","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"A device is incoming or repairing...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":2500,"wires":[["b2123a08.a7deb8"]]},{"id":"eaaa0045.a639","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Device paired successfully: {{msg.payload.message}}","output":"str","x":330,"y":2540,"wires":[["b2123a08.a7deb8"]]},{"id":"51ff0ea1.0a919","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Deviced removed: {{msg.payload.message}}","output":"str","x":330,"y":2580,"wires":[["b2123a08.a7deb8"]]},{"id":"61db4308.05a59c","type":"comment","z":"1112a3ea.54efdc","name":"Notifications","info":"","x":120,"y":2420,"wires":[]},{"id":"a7b346c6.0c9d18","type":"ui_toast","z":"1112a3ea.54efdc","position":"top right","displayTime":"5","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":940,"y":2340,"wires":[]},{"id":"bf8faaff.5215b8","type":"link out","z":"1112a3ea.54efdc","name":"Z2M BINDING OUT","links":["398af7a3.80e388"],"x":875,"y":2300,"wires":[]},{"id":"75d20744.52cef8","type":"link out","z":"1112a3ea.54efdc","name":"Z2M RENAME OUT","links":["398af7a3.80e388"],"x":855,"y":2120,"wires":[]},{"id":"207b74ec.1d3f1c","type":"link out","z":"1112a3ea.54efdc","name":"Z2M REMOVE OUT","links":["398af7a3.80e388"],"x":835,"y":1820,"wires":[]},{"id":"6e76defe.80e97","type":"comment","z":"1112a3ea.54efdc","name":"Zigbee2Mqtt Admin Panel","info":"","x":150,"y":40,"wires":[]},{"id":"638e5203.cd6f8c","type":"comment","z":"1112a3ea.54efdc","name":"---- Dont change things down here ----","info":"","x":190,"y":400,"wires":[]},{"id":"8ae66b7.1c0af98","type":"switch","z":"1112a3ea.54efdc","name":"","property":"payload.type.group","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":410,"y":2620,"wires":[["587b2872.f7c9c8"]]},{"id":"587b2872.f7c9c8","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Succesfully changed device {{payload.type.device}} in group {{payload.type.group}}","output":"str","x":570,"y":2620,"wires":[["b2123a08.a7deb8"]]},{"id":"cd065e2e.3e334","type":"ui_toast","z":"1112a3ea.54efdc","position":"top right","displayTime":"3","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":880,"y":640,"wires":[]},{"id":"9596b7ff.dac428","type":"debug","z":"1112a3ea.54efdc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":650,"y":680,"wires":[]},{"id":"7e27d95b.8f7028","type":"ui_text","z":"1112a3ea.54efdc","group":"d40979a3.d11a08","order":9,"width":"0","height":"0","name":"","label":"Last created","format":"{{msg.payload.nwlast | date:'dd.MM.yy HH:mm'}}","layout":"row-spread","x":530,"y":1120,"wires":[]},{"id":"d0f962f1.6e1fd","type":"ui_button","z":"1112a3ea.54efdc","name":"","group":"d40979a3.d11a08","order":11,"width":"5","height":"1","passthru":false,"label":"Show network map","tooltip":"","color":"","bgcolor":"","icon":"","payload":"{\"tab\":\"Z2M Network map\"}","payloadType":"json","topic":"","x":130,"y":2920,"wires":[["d64445e4.511f88"]]},{"id":"d64445e4.511f88","type":"ui_ui_control","z":"1112a3ea.54efdc","name":"","x":340,"y":2920,"wires":[[]]},{"id":"4b968044.ca533","type":"link out","z":"1112a3ea.54efdc","name":"Z2M FLOW DEV TRIGGER","links":["f7eaa817.70bfd8","ced9b243.c5dfc","afb0f244.23a25","d8fc6e0f.d831c"],"x":475,"y":1020,"wires":[]},{"id":"5bdeb97.e5ea048","type":"inject","z":"1112a3ea.54efdc","name":"","topic":"","payload":"","payloadType":"date","repeat":"5","crontab":"","once":true,"onceDelay":0.1,"x":330,"y":1020,"wires":[["4b968044.ca533"]]},{"id":"a4e5b5d9.2c3e88","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.message}} to device {{payload.meta.entity.friendlyName}}\nOriginal message: {{payload.meta.message}}","output":"str","x":780,"y":580,"wires":[["cd065e2e.3e334","aab0241a.1dabd8"]]},{"id":"aab0241a.1dabd8","type":"link out","z":"1112a3ea.54efdc","name":"PUBLISH ERROR TO TELEGRAM","links":["34d4fa40.340716","237ac04e.ab42b"],"x":895,"y":560,"wires":[]},{"id":"d595fafe.6834b8","type":"inject","z":"1112a3ea.54efdc","name":"Request Group List","topic":"zigbee2mqtt/bridge/config/groups","payload":"","payloadType":"date","repeat":"5","crontab":"","once":true,"onceDelay":0.1,"x":140,"y":280,"wires":[["ab86c3a1.ed149"]]},{"id":"9cce1a99.a33f28","type":"link out","z":"1112a3ea.54efdc","name":"Z2M LOG GROUPLIST","links":["7ede0202.b35fec","b259a6a5.f45d38","a5f793a4.b6462"],"x":895,"y":520,"wires":[]},{"id":"1109a698.6fc9c9","type":"comment","z":"1112a3ea.54efdc","name":"Networkmap","info":"","x":110,"y":2840,"wires":[]},{"id":"b259a6a5.f45d38","type":"link in","z":"1112a3ea.54efdc","name":"Z2M GROUP UI","links":["9cce1a99.a33f28","da845187.f7cd2"],"x":55,"y":1920,"wires":[["8ee1c3a9.368aa"]]},{"id":"be14f64d.ceb358","type":"ui_text","z":"1112a3ea.54efdc","group":"d40979a3.d11a08","order":5,"width":"0","height":"0","name":"","label":"Zigbee2MQTT version","format":"{{msg.payload.version}}","layout":"row-left","x":220,"y":1180,"wires":[]},{"id":"56f299a2.6327d8","type":"ui_text","z":"1112a3ea.54efdc","group":"d40979a3.d11a08","order":6,"width":"0","height":"0","name":"","label":"Coordinator firmware","format":"{{msg.payload.coordinator_firmware}}","layout":"row-left","x":220,"y":1220,"wires":[]},{"id":"f94fee3a.19978","type":"inject","z":"1112a3ea.54efdc","name":"Reset CC253x","topic":"zigbee2mqtt/bridge/config/reset","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":320,"wires":[["ab86c3a1.ed149"]]},{"id":"ce7e9b39.36a138","type":"ui_text_input","z":"1112a3ea.54efdc","name":"Selected device","label":"Selected device","tooltip":"Select device in device list","group":"38009ddc.858562","order":1,"width":0,"height":0,"passthru":false,"mode":"text","delay":300,"topic":"","x":420,"y":1780,"wires":[[]]},{"id":"d8fc6e0f.d831c","type":"link in","z":"1112a3ea.54efdc","name":"Z2M BIND DEVICE INP","links":["4b968044.ca533"],"x":55,"y":1780,"wires":[["90333b0d.d35758"]]},{"id":"90333b0d.d35758","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"device","tot":"flow"},{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":1780,"wires":[["ce7e9b39.36a138"]]},{"id":"3becb9b5.67b2a6","type":"ui_toast","z":"1112a3ea.54efdc","position":"top right","displayTime":"5","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":810,"y":1580,"wires":[]},{"id":"48a7a523.1678fc","type":"function","z":"1112a3ea.54efdc","name":"Format Data","func":"\nif (msg.payload == \"add\") {\n var action = \"Adding \";\n var what = \"group \";\n var cmd = \"add_group\";\n var groupname = flow.get('newgroupname');\n}\nif(msg.payload == \"remove\") {\n action = \"Removing \";\n what = \"group \";\n cmd = \"remove_group\";\n groupname = flow.get('groupname2');\n}\nvar msg1 = { payload: groupname, topic: \"zigbee2mqtt/bridge/config/\" + cmd};\nvar msg2 = { payload: action + what + groupname };\n\nreturn [msg1, msg2];\n","outputs":2,"noerr":0,"x":770,"y":1520,"wires":[["699fc636.402658"],["3becb9b5.67b2a6"]]},{"id":"699fc636.402658","type":"link out","z":"1112a3ea.54efdc","name":"Z2M GROUP BIND OUT","links":["398af7a3.80e388"],"x":875,"y":1500,"wires":[]},{"id":"1eab9c80.093434","type":"switch","z":"1112a3ea.54efdc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"add","vt":"str"},{"t":"eq","v":"remove","vt":"str"},{"t":"eq","v":"cancel","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":630,"y":1520,"wires":[["48a7a523.1678fc"],["48a7a523.1678fc"],[]]},{"id":"c4fe2b67.cf9738","type":"ui_toast","z":"1112a3ea.54efdc","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"add","cancel":"cancel","topic":"Add group","name":"","x":470,"y":1500,"wires":[["1eab9c80.093434"]]},{"id":"aea3baea.3e1e18","type":"ui_toast","z":"1112a3ea.54efdc","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"remove","cancel":"cancel","topic":"Remove group","name":"","x":470,"y":1540,"wires":[["1eab9c80.093434"]]},{"id":"cc1b1b4c.c16468","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Add group <b>{{flow.newgroupname}}</b>?","output":"str","x":320,"y":1500,"wires":[["c4fe2b67.cf9738"]]},{"id":"60051e06.1b187","type":"template","z":"1112a3ea.54efdc","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Remove group <b>{{flow.groupname2}}</b>?","output":"str","x":320,"y":1540,"wires":[["aea3baea.3e1e18"]]},{"id":"bc9a1621.4bf0d8","type":"ui_button","z":"1112a3ea.54efdc","name":"","group":"d9a11d4b.0417f","order":15,"width":"6","height":"1","passthru":false,"label":"Add group","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Add","payloadType":"str","topic":"","x":110,"y":1500,"wires":[["cc1b1b4c.c16468"]]},{"id":"d87bfe09.f0b49","type":"ui_button","z":"1112a3ea.54efdc","name":"","group":"d9a11d4b.0417f","order":17,"width":"6","height":"1","passthru":false,"label":"Remove group","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Remove","payloadType":"str","topic":"","x":120,"y":1540,"wires":[["60051e06.1b187"]]},{"id":"9f335ddf.67d2b","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"groupname2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":1580,"wires":[[]]},{"id":"a5f793a4.b6462","type":"link in","z":"1112a3ea.54efdc","name":"Z2M GROUP UI","links":["9cce1a99.a33f28"],"x":55,"y":1580,"wires":[["78d47084.a872f"]]},{"id":"78d47084.a872f","type":"function","z":"1112a3ea.54efdc","name":"Reformat for list","func":"newPayload = [];\nObject.keys(msg.payload.message).forEach(function(key) {\n var msgKey = msg.payload.message[key].friendly_name + \" (ID: \" + key + \")\";\n var msgVar = msg.payload.message[key].friendly_name;\n newentry = '{\"'+msgKey+'\":\" '+ msgVar+'\"}';\n newPayload.push(msg.payload.message[key].friendly_name);\n});\n\nnewMsg = {'payload': flow.get('groupname2'), 'options': newPayload}\nreturn newMsg;\n","outputs":1,"noerr":0,"x":170,"y":1580,"wires":[["45acd531.d9045c"]]},{"id":"45acd531.d9045c","type":"ui_dropdown","z":"1112a3ea.54efdc","name":"Groups","label":"","tooltip":"Selected group","place":"Select group","group":"d9a11d4b.0417f","order":16,"width":"6","height":"1","passthru":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":340,"y":1580,"wires":[["9f335ddf.67d2b"]]},{"id":"dcb4f7a6.e845b8","type":"ui_text_input","z":"1112a3ea.54efdc","name":"","label":"New group name","tooltip":"","group":"d9a11d4b.0417f","order":14,"width":"6","height":"1","passthru":true,"mode":"text","delay":"100","topic":"","x":130,"y":1640,"wires":[["bcb48a8a.a55288"]]},{"id":"bcb48a8a.a55288","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"newgroupname","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":1640,"wires":[[]]},{"id":"1ba11ffa.fb4e","type":"ui_text","z":"1112a3ea.54efdc","group":"38009ddc.858562","order":6,"width":"5","height":"1","name":"Group membership","label":"<h3>Group memberships</h3>","format":"","layout":"row-left","x":150,"y":2060,"wires":[]},{"id":"1303ac28.147ee4","type":"ui_text","z":"1112a3ea.54efdc","group":"38009ddc.858562","order":9,"width":"6","height":"1","name":"Bind device label","label":"<h3>Bind device</h3>","format":"","layout":"row-left","x":130,"y":2200,"wires":[]},{"id":"60a53cc.67bb1c4","type":"ui_text","z":"1112a3ea.54efdc","group":"d40979a3.d11a08","order":3,"width":0,"height":0,"name":"bridge status label","label":"<h3>Bridge status</h3>","format":"","layout":"row-left","x":140,"y":1380,"wires":[]},{"id":"9377320a.f91bf","type":"ui_text","z":"1112a3ea.54efdc","group":"38009ddc.858562","order":3,"width":0,"height":0,"name":"rename device label","label":"<h3>Rename device</h3>","format":"","layout":"row-left","x":660,"y":1780,"wires":[]},{"id":"7c8cc223.0d85cc","type":"debug","z":"1112a3ea.54efdc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":740,"wires":[]},{"id":"4a76279b.a9ad98","type":"ui_dropdown","z":"1112a3ea.54efdc","name":"renderer","label":"Renderer","tooltip":"Graphviz renderer","place":"Select renderer","group":"d40979a3.d11a08","order":10,"width":"0","height":"0","passthru":false,"options":[{"label":"Circo","value":"circo","type":"str"},{"label":"Dot","value":"dot","type":"str"},{"label":"Neato","value":"neato","type":"str"},{"label":"Twopi","value":"twopi","type":"str"},{"label":"Fdp","value":"fdp","type":"str"}],"payload":"","topic":"","x":340,"y":2960,"wires":[["884ed07d.681f1"]]},{"id":"884ed07d.681f1","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"nwrenderengine","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":2960,"wires":[[]]},{"id":"b6513876.8ae868","type":"inject","z":"1112a3ea.54efdc","name":"","topic":"","payload":"nwrenderengine","payloadType":"flow","repeat":"","crontab":"","once":true,"onceDelay":"1","x":140,"y":2960,"wires":[["4a76279b.a9ad98"]]},{"id":"829ae398.1035","type":"ui_text","z":"1112a3ea.54efdc","group":"d40979a3.d11a08","order":8,"width":0,"height":0,"name":"nw map label","label":"<h3>Network map</h3>","format":"","layout":"row-left","x":430,"y":2880,"wires":[]},{"id":"5564a681.f2b1d8","type":"link out","z":"1112a3ea.54efdc","name":"Z2M GENERIC IN","links":["f0917fb5.7bbd7"],"x":255,"y":100,"wires":[]},{"id":"f0917fb5.7bbd7","type":"link in","z":"1112a3ea.54efdc","name":"Z2M INPUT","links":["5564a681.f2b1d8"],"x":75,"y":540,"wires":[["6d78e825.7722f8"]]},{"id":"7eec6698.521ae8","type":"inject","z":"1112a3ea.54efdc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":470,"y":320,"wires":[["af2ee649.26fd78"]]},{"id":"af2ee649.26fd78","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"nwrenderengine","pt":"flow","to":"circo","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":320,"wires":[[]]},{"id":"f0e7e75a.3440d8","type":"function","z":"1112a3ea.54efdc","name":"Save last msg","func":"lastDevMsgs = flow.get('lastdevmsgs')||{};\ngroupMemberships = flow.get('groupmemberships')||{};\n\nlastDevMsgs[msg.topic] = msg.payload;\nif(msg.payload.group_list !== undefined) {\n groupMemberships[msg.topic] = msg.payload.group_list;\n flow.set('groupmemberships', groupMemberships);\n}\nflow.set('lastdevmsgs', lastDevMsgs);\n\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":740,"wires":[["7c8cc223.0d85cc","4d2d1114.f6adf","8eadd875.984dc8"]]},{"id":"4d2d1114.f6adf","type":"function","z":"1112a3ea.54efdc","name":"Lookup device last msg","func":"lastmsgs = flow.get('lastdevmsgs');\ndevice = flow.get('device');\n\nentry=lastmsgs[\"zigbee2mqtt/\"+device];\n\nflow.set('lastdevmsg', entry);\n\nnewPayload = [];\n\nnewentry = {\n 'title': '<h3>Last message</h3>'\n};\nnewPayload.push(newentry);\n\nfor(var prop in entry) {\n newentry = {\n 'title': '<b>' + prop + '</b>: ' + entry[prop],\n 'description': entry[prop]\n };\n newPayload.push(newentry);\n}\n\nmsg.payload = newPayload;\nreturn msg;\n","outputs":1,"noerr":0,"x":630,"y":920,"wires":[["3d3db415.2dcb2c"]]},{"id":"d3fbf1d9.d4525","type":"json","z":"1112a3ea.54efdc","name":"","property":"payload","action":"","pretty":false,"x":390,"y":740,"wires":[["f0e7e75a.3440d8"]]},{"id":"3d3db415.2dcb2c","type":"ui_list","z":"1112a3ea.54efdc","group":"ee188496.59ff28","name":"Selected device msg","order":2,"width":"6","height":"6","lineType":"one","actionType":"none","allowHTML":true,"x":860,"y":920,"wires":[[]]},{"id":"8ee1c3a9.368aa","type":"function","z":"1112a3ea.54efdc","name":"Reformat for details","func":"membership = flow.get('devgroupmembership');\n\ngroups = flow.get('groups');\n\nnewPayload = [];\nObject.keys(groups).forEach(function(key) {\n checked = false;\n if(membership !== undefined) {\n membership.forEach(grp => {\n if(grp == key) {\n checked = true;\n }\n });\n }\n newentry = { 'title': groups[key].friendly_name,\n 'description': key,\n 'isChecked': checked\n };\n newPayload.push(newentry);\n});\n\n\nmsg.payload=newPayload;\nreturn msg;\n","outputs":1,"noerr":0,"x":190,"y":1920,"wires":[["485fc41b.7b444c"]]},{"id":"485fc41b.7b444c","type":"ui_list","z":"1112a3ea.54efdc","group":"38009ddc.858562","name":"Groups","order":8,"width":"6","height":"3","lineType":"one","actionType":"check","allowHTML":false,"x":380,"y":1920,"wires":[["b5daecf5.8ead2"]]},{"id":"ffd3a692.8773f8","type":"debug","z":"1112a3ea.54efdc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":1920,"wires":[]},{"id":"62a2e5be.e305bc","type":"ui_button","z":"1112a3ea.54efdc","name":"Create nw map","group":"d40979a3.d11a08","order":12,"width":"1","height":"1","passthru":false,"label":"","tooltip":"Refresh network map","color":"","bgcolor":"","icon":"refresh","payload":"graphviz","payloadType":"str","topic":"zigbee2mqtt/bridge/networkmap","x":120,"y":2880,"wires":[["632c3105.5495f"]]},{"id":"632c3105.5495f","type":"link out","z":"1112a3ea.54efdc","name":"Z2M NW MAP GEN","links":["398af7a3.80e388"],"x":255,"y":2880,"wires":[]},{"id":"72dba32e.85d3cc","type":"ui_button","z":"1112a3ea.54efdc","name":"Update grp member","group":"38009ddc.858562","order":7,"width":"1","height":"1","passthru":false,"label":"","tooltip":"Reload group memberships","color":"","bgcolor":"","icon":"refresh","payload":"","payloadType":"str","topic":"","x":380,"y":2060,"wires":[["30a9f3c5.b7bacc"]]},{"id":"ec7b44f2.6b8df8","type":"link out","z":"1112a3ea.54efdc","name":"Z2M DEV GRP MEM","links":["398af7a3.80e388"],"x":915,"y":2060,"wires":[]},{"id":"30a9f3c5.b7bacc","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"'zigbee2mqtt/bridge/device/' & $flowContext('device') & '/get_group_membership'","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"null","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":2060,"wires":[["ec7b44f2.6b8df8"]]},{"id":"4b369b1.1c23164","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"groups","pt":"flow","to":"payload.message","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":540,"wires":[["9cce1a99.a33f28"]]},{"id":"da845187.f7cd2","type":"link out","z":"1112a3ea.54efdc","name":"Z2M DEV MSG UPD","links":["b259a6a5.f45d38"],"x":855,"y":880,"wires":[]},{"id":"af7ccf99.27225","type":"switch","z":"1112a3ea.54efdc","name":"checked?","property":"payload.isChecked","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"false","repair":false,"outputs":2,"x":180,"y":1980,"wires":[["463d3907.451408"],["3b260768.9d2d38"]]},{"id":"b5daecf5.8ead2","type":"change","z":"1112a3ea.54efdc","name":"","rules":[{"t":"set","p":"groupname","pt":"msg","to":"payload.title","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1920,"wires":[["ffd3a692.8773f8","af7ccf99.27225"]]},{"id":"8eadd875.984dc8","type":"function","z":"1112a3ea.54efdc","name":"Lookup device group membership","func":"lastmsgs = flow.get('groupmemberships');\ndevice = flow.get('device');\n\nentry=lastmsgs[\"zigbee2mqtt/\"+device];\n\nflow.set('devgroupmembership', entry);\n\nreturn msg;\n","outputs":1,"noerr":0,"x":660,"y":880,"wires":[["da845187.f7cd2"]]},{"id":"f10dea4c.a81728","type":"delay","z":"1112a3ea.54efdc","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":640,"y":2040,"wires":[["30a9f3c5.b7bacc"]]},{"id":"38009ddc.858562","type":"ui_group","z":"","name":"Device management","tab":"4d997c7f.f72024","order":3,"disp":true,"width":"6","collapse":false},{"id":"f5594d13.23bec","type":"mqtt-broker","z":"","name":"mqtt","broker":"mqtt","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"902c151e.212a38","type":"ui_group","z":"","name":"Device list","tab":"4d997c7f.f72024","order":1,"disp":true,"width":"6","collapse":false},{"id":"d40979a3.d11a08","type":"ui_group","z":"","name":"Bridge configuration","tab":"4d997c7f.f72024","order":5,"disp":true,"width":"6","collapse":true},{"id":"fd4925c4.d13458","type":"ui_group","z":"","name":"Network map","tab":"6db85f70.6d8a2","disp":false,"width":"27","collapse":false},{"id":"ee188496.59ff28","type":"ui_group","z":"","name":"Device details","tab":"4d997c7f.f72024","order":2,"disp":true,"width":"6","collapse":false},{"id":"d9a11d4b.0417f","type":"ui_group","z":"","name":"Group configuration","tab":"4d997c7f.f72024","order":4,"disp":true,"width":"6","collapse":true},{"id":"4d997c7f.f72024","type":"ui_tab","z":"","name":"Z2M Admin","icon":"dashboard","disabled":false,"hidden":false},{"id":"6db85f70.6d8a2","type":"ui_tab","z":"","name":"Z2M Network map","icon":"dashboard","disabled":false,"hidden":true}]
@hugalafutro
Copy link

Hi, this works perfectly I had no idea node-red can do stuff like this. This flow is so much beyond what I ever accomplished in NR that I'm having trouble making 1 modification. The icon for innr SP 222 plug has a whitespace in model name thus the flow tries to retrieve https://www.zigbee2mqtt.io/images/devices/SP%20222.jpg which doesn't exist, however https://www.zigbee2mqtt.io/images/devices/SP-222.jpg does.

From my poking around my understanding is the img is generated in the Reformat for list node in the line:
icon: ${imgBase}${d.model.replace(new RegExp('/', 'g'), '-')}.jpg``
but I've no idea how to modify it to work with the whitespace in the name of this plug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment