zigbee2mqt接入nodered(2019.12.27增加多docker说明)

前言

最近妖神的zigbee2mqtt项目发布,蹭着热度,打板、购买元件等等,本帖不进行细说,具体打板、焊接、刷固件请参考以下帖子:

自己动手做zigbee网关,小米网关之外的另一个选择

先放一张我的成品


说明:zigbee芯片我使用的是小功率的E18-MS1-IPX,接口与E18-MS1PA1-IPX是一致的,只是功率小很多(计划多点放z2m,所以减少功率,同时也更便宜),更美想到,体积也小了一点,焊接的时候还是有点难度。

刷机

参考:

zigbeeV2.0网关刷机教程

记录一下自建ZigBee网关过程

type-c链接到电脑

ESP Firmware 选择 firmware/bin/espFW/ser2net.bin

CClib Firmware 选择 firmware/bin/espFW/cclib.bin

Zigbee Firmware 选择 firmware/bin/zigbeeFW/normal_21db/CC2530ZNP-Prod.hex

ssid填写WiFi名,passwd填写WiFi密码,hostname填写z2mp,tcp port填写8880

最后点击Flash列All选项,约20分钟可以完成刷机

安装zigbee2mqtt

本帖只说docker方式,如非docker,请参考记录一下自建ZigBee网关过程 或官方说明

执行使用命令:

docker run \

-it \

-v /opt/zigbee2mqtt/data:/app/data \ #个人习惯,将docker的文件夹挂载到opt下,此处可按需更换

-e TZ =Asia/Shanghai \

-v /run/udev:/run/udev:ro \

--privileged = true \

koenkk/zigbee2mqtt

或使用docker-compose

version: ‘2’

services:

  zigbee2mqtt:

  container_name: zigbee2mqtt

  image: koenkk/zigbee2mqtt:latest-dev

  volumes:

    - /opt/zigbee2mqtt/data:/app/data  #个人习惯,将docker的文件夹挂载到opt下,此处可按需更换

    - /run/udev:/run/udev:ro

  restart: always

  network_mode: host

  privileged: true

  environment:

    - TZ=Asia/Shanghai

注:经NULL提醒,zigbee2mqtt的dev分支可直接使用tcp连接,故使用dev版本

启动完成后,打开 /opt/zigbee2mqtt/data/configuration.yaml文件(默认已安装mqtt服务器,若未安装,请先安装mqtt服务器)

# Home Assistant integration (MQTT discovery)

homeassistant: false

# allow new devices to join

permit_join: true #设备增加完记得修改为false,禁止增加设备

# MQTT settings

mqtt:

# MQTT base topic for zigbee2mqtt MQTT messages

base_topic: zigbee2mqtt

# MQTT server URL

server: 'mqtt://192.168.2.6' #改为自己的mqtt服务器地址

# MQTT server authentication, uncomment if required:

# user: my_user

# password: my_password

include_device_information: true

# Serial settings

serial:

# Location of CC2531 USB sniffer

# port: /dev/ttyACM0 #注释或修改port

port: 'tcp://192.168.2.11:8880' #填写z2m的ip+端口(建议在路由中将z2m的ip固定)

多个z2m传感器配置docker说明

同样在 /opt/zigbee2mqtt/data/configuration.yaml文件中配置,在文件最后增加

advanced:
  channel: 11 #每个z2m都要不同channel且需大于等于11
  ext_pan_id: [0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD] #随意修改一个字符,确保每个z2m适配器都不一样即可。

image
也可直接修改被z2m程序格式化后的数据:

advanced:
  channel: 12
  ext_pan_id:
    - 221
    - 221
    - 221
    - 221
    - 221
    - 221
    - 221
    - 210

PS:因一开始没有设置这些,导致所有适配器都传感器都完全一致,经老妖提醒需要修改channel和ext_pan_id(修改后需重新接入传感器),再次感谢老妖。

接入传感器

因手边目前仅有Aqara的温湿度传感器,以此为例

先将传感器从米家移除;

长按reset按钮5S重置,此时Z2M会自动发现并加入

# nodered配置

使用 Admin Panel for Node-Red对z2m进行管理,增加工作流

[{"id":"1d7f96d0.a5ef29","type":"subflow","name":"Network Map (4)","info":"","category":"Zigbee2MQTT Admin Panel","in":[],"out":[]},{"id":"16f0a6aa.365fd9","type":"mqtt in","z":"1d7f96d0.a5ef29","name":"zigbee2mqtt/out","topic":"zigbee2mqtt/bridge/networkmap/graphviz","qos":"2","broker":"cae262ab.45512","x":120,"y":140,"wires":[["fe591242.503dd"]]},{"id":"acba4c61.f1022","type":"http in","z":"1d7f96d0.a5ef29","name":"","url":"/adminpanelapi/networkmap/graphviz","method":"get","upload":false,"swaggerDoc":"","x":200,"y":200,"wires":[["f57c1c5c.db0c4"]]},{"id":"77ae799c.51ee38","type":"http response","z":"1d7f96d0.a5ef29","name":"","x":610,"y":200,"wires":[]},{"id":"f57c1c5c.db0c4","type":"function","z":"1d7f96d0.a5ef29","name":"get from flow","func":"var networkmap = flow.get('networkmap');\n\nmsg.payload = networkmap;\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":200,"wires":[["77ae799c.51ee38"]]},{"id":"7e78e0f8.3ee19","type":"inject","z":"1d7f96d0.a5ef29","name":"","topic":"","payload":"graphviz","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"300","x":120,"y":80,"wires":[["9a6b1034.fada4"]]},{"id":"fe591242.503dd","type":"function","z":"1d7f96d0.a5ef29","name":"store in flow","func":"flow.set('networkmap',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":140,"wires":[[]]},{"id":"9a6b1034.fada4","type":"mqtt out","z":"1d7f96d0.a5ef29","name":"zigbee2mqtt/in","topic":"zigbee2mqtt/bridge/networkmap","qos":"","retain":"","broker":"cae262ab.45512","x":280,"y":80,"wires":[]},{"id":"85c669c4.62eca8","type":"http in","z":"1d7f96d0.a5ef29","name":"","url":"/adminpanelapi/networkmap/viz/:engine","method":"get","upload":false,"swaggerDoc":"","x":210,"y":260,"wires":[["ca7e5a95.b39b78"]]},{"id":"769c032.82029fc","type":"http response","z":"1d7f96d0.a5ef29","name":"","statusCode":"","headers":{},"x":810,"y":260,"wires":[]},{"id":"87a8d60a.86d478","type":"function","z":"1d7f96d0.a5ef29","name":"generate viz html","func":"var html = `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>NetworkMap</title>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/viz.js/2.1.2/viz.js\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/viz.js/2.1.2/full.render.js\"></script>\n <script src='https://cdn.jsdelivr.net/npm/svg-pan-zoom@3.5.0/dist/svg-pan-zoom.min.js'></script>\n <style>\n svg {\n width: 100% !important;\n height: 100% !important;\n min-width: 100% !important;\n min-height: 80% !important;\n }\n </style>\n </head>\n <body>\n <div id=\"output\"></div>\n \n <script>\n var graphData = '${(flow.get('networkmap')).replace(/(\\r\\n \\n \\r)/gm,\"\")}';\n var vizOptions = { format: 'svg', engine: '${msg.engine}'}\n var graph = document.querySelector(\"#output\");\n var svg = graph.querySelector(\"svg\");\n if (svg) {\n graph.removeChild(svg);\n } \n\n var viz = new Viz();\n\n viz.renderSVGElement(graphData, vizOptions)\n .then(function(svg) {\n svg.id = \"svg_output\";\n graph.appendChild(svg); \n \n panZoom = svgPanZoom(svg, {\n zoomEnabled: true,\n controlIconsEnabled: true,\n contain: true,\n center: true,\n minZoom: 0.1\n });\n\n svg.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 </script>\n </body>\n</html>\n`\n\nmsg.payload = html;\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":260,"wires":[["769c032.82029fc"]]},{"id":"ca7e5a95.b39b78","type":"function","z":"1d7f96d0.a5ef29","name":"set engine","func":"var availableEngines = ['circo', 'dot', 'fdp', 'neato', 'osage', 'twopi']\nif(availableEngines.includes(msg.req.params.engine)) { msg.engine = msg.req.params.engine }\nelse { msg.engine = 'dot' }\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":260,"wires":[["87a8d60a.86d478"]]},{"id":"c2287cf1.f1006","type":"subflow","name":"Pairing Notifications (5)","info":"","category":"Zigbee2MQTT Admin Panel","in":[],"out":[]},{"id":"307ac2fc.2856ae","type":"mqtt in","z":"c2287cf1.f1006","name":"zigbee2mqtt/logging","topic":"zigbee2mqtt/bridge/log","qos":"2","broker":"","x":290,"y":140,"wires":[["45e00180.83e83"]]},{"id":"45e00180.83e83","type":"json","z":"c2287cf1.f1006","name":"","property":"payload","action":"","pretty":false,"x":450,"y":140,"wires":[["dc358e29.225bb","764d802.91a968","b08008c5.204708"]]},{"id":"8daaa3f0.d30ab","type":"ui_toast","z":"c2287cf1.f1006","position":"top right","displayTime":"30","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":950,"y":80,"wires":[]},{"id":"dc358e29.225bb","type":"function","z":"c2287cf1.f1006","name":"Notification","func":"if(msg.payload.type == \"pairing\" && msg.payload.message == \"connecting with device\") {\n\nmsg.payload = (\"A device is attempting to pair...\");\n\nreturn msg;\n}\n","outputs":1,"noerr":0,"x":750,"y":80,"wires":[["8daaa3f0.d30ab"]]},{"id":"25f76ee9.aae022","type":"comment","z":"c2287cf1.f1006","name":"Notification","info":"","x":110,"y":140,"wires":[]},{"id":"b43fd89c.464988","type":"comment","z":"c2287cf1.f1006","name":"Pairing","info":"","x":590,"y":80,"wires":[]},{"id":"b3978445.0b5e68","type":"ui_toast","z":"c2287cf1.f1006","position":"top right","displayTime":"10","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":950,"y":200,"wires":[]},{"id":"764d802.91a968","type":"function","z":"c2287cf1.f1006","name":"Notification","func":"if(msg.payload.type == \"device_connected\") {\n\nmsg.payload = (\"Device paired successfully: \" + msg.payload.message);\n\nreturn msg;\n}\n","outputs":1,"noerr":0,"x":750,"y":200,"wires":[["b3978445.0b5e68"]]},{"id":"6997afbb.5fbb5","type":"comment","z":"c2287cf1.f1006","name":"Paired","info":"","x":590,"y":200,"wires":[]},{"id":"bb7fadab.5e5b3","type":"ui_toast","z":"c2287cf1.f1006","position":"top right","displayTime":"30","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":1030,"y":140,"wires":[]},{"id":"b08008c5.204708","type":"function","z":"c2287cf1.f1006","name":"Notification","func":"if(msg.payload.type == \"pairing\" && msg.payload.message == \"device incoming\") {\n\nmsg.payload = (\"A device is incoming or repairing...\");\n\nreturn msg;\n}\n","outputs":1,"noerr":0,"x":830,"y":140,"wires":[["bb7fadab.5e5b3"]]},{"id":"20b50057.748cd","type":"comment","z":"c2287cf1.f1006","name":"Incoming or Repairing","info":"","x":640,"y":140,"wires":[]},{"id":"ef334060.da584","type":"subflow","name":"Devices (5)","info":"","category":"Zigbee2MQTT Admin Panel","in":[],"out":[]},{"id":"7e8b83dd.fefb2c","type":"mqtt in","z":"ef334060.da584","name":"zigbee2mqtt/out devices","topic":"zigbee2mqtt/bridge/log","qos":"2","broker":"","x":350,"y":140,"wires":[["493b6023.cb968"]]},{"id":"9e679d81.13fa7","type":"ui_template","z":"ef334060.da584","group":"25691028.52c6a","name":"","order":0,"width":"12","height":"12","format":"<table>\n<tr>\n <td><B><U>Name:</U></B></td>\n <td><B><U>ieeeAddr:</U></B></td>\n <td><B><U>Model:</U></B></td>\n <td><B><U>Type:</U></B></td>\n</tr>\n <tr ng-repeat=\"obj in msg.payload.message\">\n <td>{{ obj.friendly_name }}</td>\n <td>{{ obj.ieeeAddr }}</td>\n <td>{{ obj.model }}</td>\n <td>{{ obj.type }}</td>\n </tr>\n\n</table>\n\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":660,"y":140,"wires":[[]]},{"id":"99faecf2.930b","type":"mqtt out","z":"ef334060.da584","name":"zigbee2mqtt/in devices","topic":"zigbee2mqtt/bridge/config/devices","qos":"","retain":"","broker":"","x":580,"y":60,"wires":[]},{"id":"3470fa68.a6a0f6","type":"inject","z":"ef334060.da584","name":"Request Device List","topic":"","payload":"","payloadType":"date","repeat":"4","crontab":"","once":true,"onceDelay":0.1,"x":360,"y":60,"wires":[["99faecf2.930b"]]},{"id":"9db58260.e1cef","type":"comment","z":"ef334060.da584","name":"Request Device List","info":"","x":130,"y":60,"wires":[]},{"id":"c504a6d9.be0f88","type":"comment","z":"ef334060.da584","name":"Receive Device List","info":"","x":130,"y":140,"wires":[]},{"id":"493b6023.cb968","type":"json","z":"ef334060.da584","name":"","property":"payload","action":"","pretty":false,"x":530,"y":140,"wires":[["9e679d81.13fa7","ec8f578e.d813d8","5fc28354.efa61c"]]},{"id":"62d673de.710fdc","type":"http in","z":"ef334060.da584","name":"","url":"/adminpanelapi/devicelist","method":"get","upload":false,"swaggerDoc":"","x":530,"y":220,"wires":[["e07b6d25.d3f88"]]},{"id":"ec8f578e.d813d8","type":"function","z":"ef334060.da584","name":"Store Data","func":"flow.set('devicelist',msg.payload);","outputs":1,"noerr":0,"x":310,"y":220,"wires":[[]]},{"id":"9e2e3a21.508488","type":"http response","z":"ef334060.da584","name":"","x":870,"y":220,"wires":[]},{"id":"e07b6d25.d3f88","type":"function","z":"ef334060.da584","name":"Get Data","func":"var devicelist = flow.get('devicelist');\nmsg.payload = devicelist;\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":220,"wires":[["9e2e3a21.508488"]]},{"id":"159e20d8.80f35f","type":"comment","z":"ef334060.da584","name":"HTTP JSON API","info":"","x":120,"y":220,"wires":[]},{"id":"5fc28354.efa61c","type":"function","z":"ef334060.da584","name":"Store Globally","func":"global.set('zigbee2mqttdevicelist',msg.payload.message);\nreturn msg;","outputs":1,"noerr":0,"x":890,"y":120,"wires":[[]]},{"id":"25691028.52c6a","type":"ui_group","z":"ef334060.da584","name":"Devices","tab":"8a847acd.0763c8","order":1,"disp":true,"width":"12","collapse":false},{"id":"745da55.b69b05c","type":"subflow","name":"Status (5)","info":"","category":"Zigbee2MQTT Admin Panel","in":[],"out":[]},{"id":"279644dc.6dee7c","type":"mqtt in","z":"745da55.b69b05c","name":"zigbee2mqtt/bridge state","topic":"zigbee2mqtt/bridge/state","qos":"2","broker":"","x":270,"y":80,"wires":[["73aeae18.80fcc"]]},{"id":"73aeae18.80fcc","type":"function","z":"745da55.b69b05c","name":"Format Data","func":"flow.set('bridgestate',msg.payload);\nvar bridgestate = flow.get('bridgestate');\nmsg.payload = bridgestate;\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":80,"wires":[["dd378351.d3647"]]},{"id":"a34a71ef.4217d","type":"ui_template","z":"745da55.b69b05c","group":"40573a59.6ec0c4","name":"","order":0,"width":"6","height":"2","format":"<style>\n {{msg.style}}\n</style>\n\n<table>\n <tr>\n <td>Bridge</td>\n <td>{{msg.payload.bridgestate}}</td>\n </tr>\n <tr>\n <td>Devices</td>\n <td>{{msg.payload.numberofdevices}}</td>\n </tr>\n</table>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":660,"y":140,"wires":[[]]},{"id":"200af5e2.bc798a","type":"function","z":"745da55.b69b05c","name":"Format Data","func":"var bridgestate = flow.get('bridgestate');\nvar devicelist = global.get('zigbee2mqttdevicelist');\nmsg.payload = {}\nmsg.payload.bridgestate = bridgestate;\nmsg.payload.numberofdevices = devicelist.length;\n\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":140,"wires":[["a34a71ef.4217d"]]},{"id":"55e501ad.f5a31","type":"inject","z":"745da55.b69b05c","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":true,"onceDelay":0.1,"x":350,"y":140,"wires":[["200af5e2.bc798a"]]},{"id":"dd378351.d3647","type":"debug","z":"745da55.b69b05c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":610,"y":80,"wires":[]},{"id":"4cc29788.d3dfb8","type":"comment","z":"745da55.b69b05c","name":"Get state","info":"","x":80,"y":80,"wires":[]},{"id":"9a06de18.4cfd6","type":"comment","z":"745da55.b69b05c","name":"Update Web UI on Interval","info":"","x":130,"y":140,"wires":[]},{"id":"b6701cc1.b20c1","type":"http in","z":"745da55.b69b05c","name":"","url":"/adminpanelapi/state","method":"get","upload":false,"swaggerDoc":"","x":270,"y":220,"wires":[["eaa0f59a.9ea2e8"]]},{"id":"91945b7c.338b18","type":"http response","z":"745da55.b69b05c","name":"","x":590,"y":220,"wires":[]},{"id":"eaa0f59a.9ea2e8","type":"function","z":"745da55.b69b05c","name":"Get Data","func":"var bridgestate = flow.get('bridgestate');\nmsg.payload = bridgestate;\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":220,"wires":[["91945b7c.338b18"]]},{"id":"911973d4.caa7b","type":"comment","z":"745da55.b69b05c","name":"HTTP API","info":"","x":80,"y":220,"wires":[]},{"id":"40573a59.6ec0c4","type":"ui_group","z":"","name":"Status","tab":"8a847acd.0763c8","order":2,"disp":true,"width":"6","collapse":false},{"id":"4b20a347.6179ec","type":"subflow","name":"Logging Level (5)","info":"","category":"Zigbee2MQTT Admin Panel","in":[],"out":[]},{"id":"e536b93d.38ce58","type":"ui_dropdown","z":"4b20a347.6179ec","name":"","label":"","place":"Select option","group":"4cb35853.cdcde8","order":1,"width":0,"height":0,"passthru":true,"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":"","x":120,"y":60,"wires":[["7557b403.7b31cc"]]},{"id":"7557b403.7b31cc","type":"mqtt out","z":"4b20a347.6179ec","name":"zigbee2mqtt/in Logging Level","topic":"zigbee2mqtt/bridge/config/log_level","qos":"","retain":"","broker":"","x":380,"y":60,"wires":[]},{"id":"4cb35853.cdcde8","type":"ui_group","z":"4b20a347.6179ec","name":"Logging Level","tab":"8a847acd.0763c8","order":4,"disp":true,"width":"6","collapse":false},{"id":"321dbafd.bfadd6","type":"subflow","name":"Remove Device (5)","info":"","category":"Zigbee2MQTT Admin Panel","in":[],"out":[]},{"id":"3d54715b.2d141e","type":"ui_text_input","z":"321dbafd.bfadd6","name":"","label":"Device Name","group":"bbb3596e.f2c6a8","order":3,"width":0,"height":0,"passthru":true,"mode":"text","delay":"5","topic":"","x":300,"y":60,"wires":[["7bbae970.739f08"]]},{"id":"77e98a80.5cecc4","type":"mqtt out","z":"321dbafd.bfadd6","name":"zigbee2mqtt/in Remove","topic":"zigbee2mqtt/bridge/config/remove","qos":"","retain":"","broker":"","x":1190,"y":60,"wires":[]},{"id":"bba4a9e2.774a58","type":"function","z":"321dbafd.bfadd6","name":"Format Data","func":"flow.set('remove',msg.payload.remove);","outputs":1,"noerr":0,"x":650,"y":60,"wires":[[]]},{"id":"7bbae970.739f08","type":"change","z":"321dbafd.bfadd6","name":"change msg old","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.remove","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":60,"wires":[["bba4a9e2.774a58"]]},{"id":"23f4c1c8.b1cdee","type":"function","z":"321dbafd.bfadd6","name":"Format Data","func":"var remove = flow.get('remove');\nif (typeof remove !== 'undefined' && remove !== null && remove !== \"\"){\nmsg.payload = remove;\n\nreturn msg;\n}","outputs":1,"noerr":0,"x":970,"y":60,"wires":[["77e98a80.5cecc4"]]},{"id":"2fb6b0f0.c1b22","type":"ui_button","z":"321dbafd.bfadd6","name":"","group":"bbb3596e.f2c6a8","order":5,"width":0,"height":0,"passthru":false,"label":"Remove","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":820,"y":60,"wires":[["23f4c1c8.b1cdee","33ef226e.e110ce"]]},{"id":"4475f491.2a912c","type":"comment","z":"321dbafd.bfadd6","name":"Remove Device","info":"","x":120,"y":60,"wires":[]},{"id":"ff765b29.6adee8","type":"mqtt in","z":"321dbafd.bfadd6","name":"zigbee2mqtt/logging","topic":"zigbee2mqtt/bridge/log","qos":"2","broker":"","x":290,"y":120,"wires":[["745b519f.3cebe"]]},{"id":"745b519f.3cebe","type":"json","z":"321dbafd.bfadd6","name":"","property":"payload","action":"","pretty":false,"x":450,"y":120,"wires":[["7ddf8dc.b520d74"]]},{"id":"1e58e32b.ccff3d","type":"ui_toast","z":"321dbafd.bfadd6","position":"top right","displayTime":"5","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":790,"y":120,"wires":[]},{"id":"7ddf8dc.b520d74","type":"function","z":"321dbafd.bfadd6","name":"Notification","func":"if(msg.payload.type == 'device_removed') {\nvar remove = flow.get('remove');\nif (typeof remove !== 'undefined' && remove !== null && remove !== \"\"){\nmsg.payload = (\"Deviced removed: \" + msg.payload.message);\n\n// Reset field\n//remove = \"\";\n//flow.set('remove',msg.payload.message);\n\nreturn msg;\n}\n}\n\n","outputs":1,"noerr":0,"x":590,"y":120,"wires":[["1e58e32b.ccff3d"]]},{"id":"f7da77dc.c6e758","type":"comment","z":"321dbafd.bfadd6","name":"Notification","info":"","x":110,"y":120,"wires":[]},{"id":"f33f2806.7e7f48","type":"ui_toast","z":"321dbafd.bfadd6","position":"top right","displayTime":"5","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":1210,"y":120,"wires":[]},{"id":"33ef226e.e110ce","type":"function","z":"321dbafd.bfadd6","name":"Notification","func":"var remove = flow.get('remove');\nif (typeof remove === 'undefined' remove === null remove === \"\"){\nmsg.payload = \"Enter a device to remove\";\n\nreturn msg;\n}","outputs":1,"noerr":0,"x":1010,"y":120,"wires":[["f33f2806.7e7f48"]]},{"id":"bbb3596e.f2c6a8","type":"ui_group","z":"321dbafd.bfadd6","name":"Remove Device","tab":"8a847acd.0763c8","order":5,"disp":true,"width":"6","collapse":false},{"id":"8bff0e3.fceb9f","type":"subflow","name":"Permit Join (5)","info":"","category":"Zigbee2MQTT Admin Panel","in":[],"out":[]},{"id":"17f72daf.369812","type":"ui_dropdown","z":"8bff0e3.fceb9f","name":"","label":"","place":"Select option","group":"7b37feaf.b63ae","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"Allow","value":"true","type":"str"},{"label":"Deny","value":"false","type":"str"}],"payload":"","topic":"","x":90,"y":40,"wires":[["32c724f.65b28dc","2c5e4cc7.f1b534"]]},{"id":"32c724f.65b28dc","type":"mqtt out","z":"8bff0e3.fceb9f","name":"zigbee2mqtt/in Join","topic":"zigbee2mqtt/bridge/config/permit_join","qos":"","retain":"","broker":"cae262ab.45512","x":270,"y":40,"wires":[]},{"id":"4cfd10b0.ff8d6","type":"ui_toast","z":"8bff0e3.fceb9f","position":"top right","displayTime":"5","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":450,"y":100,"wires":[]},{"id":"2c5e4cc7.f1b534","type":"function","z":"8bff0e3.fceb9f","name":"Notification","func":"if (typeof msg.payload !== 'undefined' && msg.payload !== null && msg.payload !== \"\"){\nif (msg.payload == \"false\"){\n msg.payload = \"Permit join: Deny\";\n}\nif (msg.payload == \"true\"){\n msg.payload = \"Permit join: Allow\";\n}\nreturn msg;\n}\n","outputs":1,"noerr":0,"x":250,"y":100,"wires":[["4cfd10b0.ff8d6"]]},{"id":"7b37feaf.b63ae","type":"ui_group","z":"","name":"Permit Join","tab":"8a847acd.0763c8","order":3,"disp":true,"width":"6","collapse":false},{"id":"cae262ab.45512","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.5","port":"8883","tls":"9895f781.42a5e8","clientid":"","usetls":true,"compatmode":true,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9895f781.42a5e8","type":"tls-config","z":"","name":"","cert":"","key":"","ca":"","certname":"m2mqtt_srv.crt","keyname":"m2mqtt_srv.key","caname":"m2mqtt_ca.crt","servername":"","verifyservercert":false},{"id":"e084a6a.4631f58","type":"subflow","name":"Rename Device (5)","info":"","category":"Zigbee2MQTT Admin Panel","in":[],"out":[]},{"id":"b8f2f698.57e568","type":"ui_text_input","z":"e084a6a.4631f58","name":"","label":"Old Name","group":"241ead91.463d32","order":3,"width":0,"height":0,"passthru":true,"mode":"text","delay":"5","topic":"","x":120,"y":140,"wires":[["d7eb0922.b84f08"]]},{"id":"94d90d29.f3402","type":"ui_text_input","z":"e084a6a.4631f58","name":"","label":"New Name","group":"241ead91.463d32","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":"5","topic":"","x":130,"y":200,"wires":[["affaacf8.e5f47"]]},{"id":"42f80cde.64caa4","type":"mqtt out","z":"e084a6a.4631f58","name":"zigbee2mqtt/in Rename","topic":"zigbee2mqtt/bridge/config/rename","qos":"","retain":"","broker":"","x":1010,"y":140,"wires":[]},{"id":"45b3ba5.f047644","type":"function","z":"e084a6a.4631f58","name":"Format Data","func":"flow.set('oldname',msg.payload.old);","outputs":1,"noerr":0,"x":470,"y":140,"wires":[[]]},{"id":"d7eb0922.b84f08","type":"change","z":"e084a6a.4631f58","name":"change msg old","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.old","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":140,"wires":[["45b3ba5.f047644"]]},{"id":"affaacf8.e5f47","type":"change","z":"e084a6a.4631f58","name":"change msg new","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.new","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":200,"wires":[["f95d60ee.d6ca"]]},{"id":"21cf98b4.9a32f8","type":"function","z":"e084a6a.4631f58","name":"Format Data","func":"var oldname = flow.get('oldname');\nvar newname = flow.get('newname');\n\nif (typeof oldname !== 'undefined' && oldname !== null && oldname !== \"\" && typeof newname !== 'undefined' && newname !== null && newname !== \"\"){\nmsg.payload = {\"old\": oldname, \"new\": newname}\n\n// Reset fields\noldname = \"\";\nnewname = \"\";\nflow.set('oldname',msg.payload.old);\nflow.set('newname',msg.payload.new);\n\nreturn msg;\n}","outputs":1,"noerr":0,"x":790,"y":140,"wires":[["42f80cde.64caa4"]]},{"id":"f95d60ee.d6ca","type":"function","z":"e084a6a.4631f58","name":"Format Data","func":"flow.set('newname',msg.payload.new);","outputs":1,"noerr":0,"x":490,"y":200,"wires":[[]]},{"id":"f3b62056.55b2d","type":"ui_button","z":"e084a6a.4631f58","name":"","group":"241ead91.463d32","order":5,"width":0,"height":0,"passthru":false,"label":"Rename","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":640,"y":140,"wires":[["21cf98b4.9a32f8","413a9336.12cf2c"]]},{"id":"2826da46.731886","type":"ui_toast","z":"e084a6a.4631f58","position":"top right","displayTime":"5","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"System Notification","name":"","x":850,"y":200,"wires":[]},{"id":"413a9336.12cf2c","type":"function","z":"e084a6a.4631f58","name":"Notification","func":"var oldname = flow.get('oldname');\nvar newname = flow.get('newname');\n\nif (typeof oldname !== 'undefined' && oldname !== null && oldname !== \"\" && typeof newname !== 'undefined' && newname !== null && newname !== \"\"){\nmsg.payload = (\"Rename Device: \" + oldname + \" to \" + newname);\nreturn msg;\n} else {\nmsg.payload = \"Enter device to rename\";\nreturn msg;\n}\n","outputs":1,"noerr":0,"x":670,"y":200,"wires":[["2826da46.731886"]]},{"id":"241ead91.463d32","type":"ui_group","z":"","name":"Rename Device","tab":"8a847acd.0763c8","order":6,"disp":true,"width":"6","collapse":false},{"id":"8a847acd.0763c8","type":"ui_tab","z":"","name":"Zigbee2MQTT Admin Panel","icon":"dashboard"},{"id":"d2be8f77.7326a","type":"subflow:e084a6a.4631f58","z":"7fbc8cf2.96adb4","name":"","x":120,"y":120,"wires":[]},{"id":"12b79f03.54ddc1","type":"subflow:8bff0e3.fceb9f","z":"7fbc8cf2.96adb4","name":"","x":100,"y":80,"wires":[]},{"id":"bbc5a6f7.dde758","type":"subflow:321dbafd.bfadd6","z":"7fbc8cf2.96adb4","name":"","x":120,"y":160,"wires":[]},{"id":"2a059d07.c5db22","type":"comment","z":"7fbc8cf2.96adb4","name":"Function","info":"","x":100,"y":40,"wires":[]},{"id":"c6a120ae.fc064","type":"subflow:4b20a347.6179ec","z":"7fbc8cf2.96adb4","name":"","x":110,"y":200,"wires":[]},{"id":"9748fef8.41217","type":"subflow:745da55.b69b05c","z":"7fbc8cf2.96adb4","name":"","x":90,"y":240,"wires":[]},{"id":"b8612dd3.59558","type":"subflow:ef334060.da584","z":"7fbc8cf2.96adb4","name":"","x":90,"y":280,"wires":[]},{"id":"48f768d0.746138","type":"comment","z":"7fbc8cf2.96adb4","name":"Other","info":"","x":350,"y":40,"wires":[]},{"id":"ea0eb635.470828","type":"subflow:c2287cf1.f1006","z":"7fbc8cf2.96adb4","name":"","x":390,"y":80,"wires":[]},{"id":"1651116a.3aec8f","type":"subflow:1d7f96d0.a5ef29","z":"7fbc8cf2.96adb4","name":"","x":370,"y":140,"wires":[]}]


增加后可对z2m连接设备进行管理

# 获取设备状态

新建mqtt节点 topics(主题) 填写 zigbee2mqtt/[FRIENDLY_NAME]

FRIENDLY_NAME 在加入网关后,有一串0x开头的字符,就是FRIENDLY_NAME


注1:需将mqtt节点输出改为a parsed JSON object,默认会打印出字符串
image
image

总结

个人比较菜,可能很多地方讲的不到位,也缺少很多详细步骤欧,还请各位多参考其他更详细的帖子和官网文档

参考

1、自己动手做zigbee网关,小米网关之外的另一个选择

2、zigbeeV2.0网关刷机教程

3、记录一下自建ZigBee网关过程

4、https://www.zigbee2mqtt.io/

5、https://github.com/ben423423n32j14e/zigbee2mqttadminpanel

膜拜大佬,大神牛逼@honry

好厉害,赶来学习下

没有焊接拨码开关啊,那篇帖子的步骤还适用吗?

哪篇? 新的硬件版本v2p1不需要焊接拨码开关了

意思是直接插线就能刷机是吧

是的。字数补丁。。。

感谢大佬 感谢叼大的吴彦祖

大神 这个怎么重置wifi 只能用电脑设置吗?

直接重刷一次esp配置就可以了吧,貌似只能电脑搞

用电脑,还是刷机工具, 直接刷wifi_info就可以

好的,我以为板子上的按键能重置呢

大佬 这个怎么搞呀 能不能贴个完整的配置呀 我按你的配置 之后 都加不进设备了

homeassistant: false
permit_join: true
mqtt:
base_topic: zigbee2mqtt1
server: ‘mqtt://192.168.2.6’
serial:
port: ‘tcp://192.168.2.11:8880’
advanced:
channel: 11
ext_pan_id:
- 111
- 111
- 221
- 221
- 221
- 221
- 221
- 111

你理解错了,这个是一个的,如果你有两个z2m适配器的话,需要再开一个docker

大佬,这是干啥的 ,看半天没看明白
channel: 11
ext_pan_id:

  • 111
  • 111
  • 221
  • 221
  • 221
  • 221
  • 221
  • 111

类似密码的东西?我也不晓得是啥 :sweat_smile:

膜拜大佬,大神牛逼@honry

docker安装命令,里面的/ \ :等符号复制下来不对,运行报错 docker: invalid reference format 要自己手动敲一遍才可以

可能格式问题吧,我是在macOS的备忘录里写的,然后复制过来