余弦玩BPI M2 Berry 余弦物联网网关——9 实现家庭自动化模板


#1

上一篇中介绍了一套共享的ZigBee系统,通过这个资料和野蜂开发板可以搭建一个简单的demo:
1 野蜂开发板+气体传感器(模拟量)
2 野蜂开发板+火焰传感器(数字量)
3 野蜂开发板+光敏传感器(数字量)
4 野蜂开发板+伏羲扩展板+光照传感器(标准电流)+温湿度传感器(标准电流)
5 野蜂开发板(协调器)
6 野蜂开发板+2通继电器+风扇+灯

1 2 3的合照

4的合照 ,伏羲开发板的电流采集使用电阻分压,有温飘,达不到工业标准,做演示够了


5和香蕉派连接(当然USB口连接也行)

6 风扇和灯12V供电

所有设备烧共享的hex文件,然后配置到同一 信道、panid、设置恰当的序列号

然后就是node-red里编程进行数据解析,具体数据协议见上一章节
需要安装node-red-node-serialport插件让红点可以连接开发板通过协调器串口进行数据通信,如果串口连接失败一般是没有权限,修改一下串口权限777进行

调试效果

最终效果,这里对电流(4-20ma)还没有做进一步处理



image


#2

红点代码导出

[
{
“id”: “66887f54.dc717”,
“type”: “serial in”,
“z”: “a902018.e4bbe”,
“name”: “”,
“serial”: “ca3fbf87.3a16f”,
“x”: 1060,
“y”: 740,
“wires”: [
[
“fe46044e.c23a98”
]
]
},
{
“id”: “12bd6886.b60f17”,
“type”: “debug”,
“z”: “a902018.e4bbe”,
“name”: “”,
“active”: false,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “false”,
“x”: 1270,
“y”: 1000,
“wires”: []
},
{
“id”: “fe46044e.c23a98”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “自组网-数据2对象”,
“func”: “var HEAD=0xfe;\nvar CMD0=0x46;\nvar CMD1=0x87;\nvar DTYPEL=0x02;\nvar DTYPEH=0x0;\n\nfunction calcFCS(pBuf,start , len)\n{\n var rtrn = 0;\n var i = start;\n\n while (len-- != 0)\n {\n rtrn ^= pBuf[i++];\n }\n\n return rtrn;\n}\n\nvar payload =msg.payload;\n//msg.payload =(msg.payload)[0].toString();\n//console.log(msg.payload );\n//err\nmsg.payload=null;\n\nif(payload[0]==HEAD&& payload[2]==CMD0&& payload[3]==CMD1)\n{\n var chk=0;\n for(var i=1; i<payload.length-1; i++)\n {\n chk^=payload[i];\n }\n //msg.payload=[chk,payload[payload.length-1],payload];\n \n if(chk==payload[payload.length-1])\n {\n var data=new Object();\n //data.Obj=payload;//debug 源数据\n data.Addr=payload[5]<<8|payload[4];\n data.pAddr=payload[13]<<8|payload[12];\n data.inTemp=payload[10];\n data.inVol=payload[11];\n data.lgType=payload[14];\n data.sorAddr=payload[16]<<8|payload[15];\n data.sType=payload[17];\n var len=payload.length-1-18;\n var buf=new Buffer(len);\n payload.copy(buf, 0, 18, len+18);\n data.sorData=buf;\n msg.payload=data;\n }\n}\n\nreturn msg;\n”,
“outputs”: 1,
“noerr”: 0,
“x”: 1250,
“y”: 800,
“wires”: [
[
“e879d5e6.d07ca8”
]
]
},
{
“id”: “e879d5e6.d07ca8”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “自组网-数据按类型处理”,
“func”: “\nvar payload =msg.payload;\n\nif(payload!=null)\n{\n msg.topic=“BEE”+payload.Addr;\n switch (payload.sType)\n {\n case 0x11:\n if(payload.title===undefined)\n payload.title=“人体”\n payload.sorValue=payload.sorData[0];\n break;\n \n case 0x21:\n if(payload.title===undefined)\n payload.title=“光照”;\n case 0x22:\n if(payload.title===undefined)\n payload.title=“CO”;\n case 0x23:\n if(payload.title===undefined)\n payload.title=“可燃气”;\n case 0x24:\n if(payload.title===undefined)\n payload.title=“火焰”;\n case 0x25:\n if(payload.title===undefined)\n payload.title=“酒精”;\n \n //payload.sorValue=1;//\n payload.sorValue=payload.sorData[1]<<8|payload.sorData[0];\n break;\n \n case 0x30:\n //if(payload.title===undefined)\n // payload.title=“标准电流”;\n payload.sorValue0=payload.sorData[1]<<8|payload.sorData[0];\n payload.sorValue0=3300payload.sorValue0/1023/150;\n \n payload.sorValue1=payload.sorData[3]<<8|payload.sorData[2]; \n payload.sorValue1=3300payload.sorValue1/1023/150;\n \n payload.sorValue2=payload.sorData[5]<<8|payload.sorData[4]; \n payload.sorValue2=3300payload.sorValue2/1023/150;\n \n payload.sorValue3=payload.sorData[7]<<8|payload.sorData[6]; \n payload.sorValue3=3300payload.sorValue3/1023/150;\n break; \n default:\n break;\n }\n \n msg.payload=payload;\n \n}\n\nreturn msg;\n”,
“outputs”: 1,
“noerr”: 5,
“x”: 1270,
“y”: 880,
“wires”: [
[
“bd3dd026.d024f”
]
]
},
{
“id”: “41afeca8.e24694”,
“type”: “debug”,
“z”: “a902018.e4bbe”,
“name”: “”,
“active”: false,
“tosidebar”: true,
“console”: true,
“complete”: “payload”,
“x”: 1240,
“y”: 1620,
“wires”: []
},
{
“id”: “9b33ddc6.c8922”,
“type”: “comment”,
“z”: “a902018.e4bbe”,
“name”: “串口获取ZigBee网络数据”,
“info”: “”,
“x”: 1170,
“y”: 660,
“wires”: []
},
{
“id”: “bd3dd026.d024f”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “列表更新”,
“func”: “var SYSDevList=flow.get(‘SYSDevList’)||{};\nvar SYSDevInfo=flow.get(‘SYSDevInfo’)||{};\n\nvar topic=msg.topic;\n\n//修改\nSYSDevList[topic]=msg.payload;\n//time\nif(SYSDevInfo[topic]===undefined)\n SYSDevInfo[topic]={};\nSYSDevInfo[topic][‘time’]=new Date().getTime();\n\n//save\nflow.set(‘SYSDevList’,SYSDevList);\nflow.set(‘SYSDevInfo’,SYSDevInfo);\n//输出key表\nmsg.payload=SYSDevList;\n\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1280,
“y”: 940,
“wires”: [
[
“12bd6886.b60f17”
]
]
},
{
“id”: “b4efadd.d31175”,
“type”: “inject”,
“z”: “a902018.e4bbe”,
“name”: “”,
“topic”: “刷新UI”,
“payload”: “”,
“payloadType”: “str”,
“repeat”: “3”,
“crontab”: “”,
“once”: true,
“onceDelay”: “”,
“x”: 1040,
“y”: 1120,
“wires”: [
[
“95a29e2d.282ad”,
“31ce5d6d.66ccb2”,
“876a62e2.f33d3”
]
]
},
{
“id”: “c744e0c6.c159b”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 11,
“width”: “4”,
“height”: “1”,
“name”: “6”,
“label”: “{{msg.topic}}”,
“format”: “{{msg.payload}} V”,
“layout”: “row-spread”,
“x”: 1430,
“y”: 1480,
“wires”: []
},
{
“id”: “95a29e2d.282ad”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “数据分离”,
“func”: “var BEE_HEX_01_0 = {\n topic:“温度”,\n payload: “-”\n};\nvar BEE_HEX_01_1 = {\n topic:“湿度”,\n payload: “-”\n};\nvar BEE_HEX_11 = {\n topic:“人体”,\n payload: “-”\n};\nvar BEE_HEX_21 = {\n topic:“光照”,\n payload: “-”\n};\nvar BEE_HEX_22 = {\n topic:“CO”,\n payload: “-”\n};\nvar BEE_HEX_23 = {\n topic:“可燃气”,\n payload: “-”\n};\nvar BEE_HEX_24 = {\n topic:“火焰”,\n payload: “-”\n};\nvar BEE_HEX_25 = {\n topic:“酒精”,\n payload: “-”\n};\n\nvar SYSDevList=flow.get(‘SYSDevList’)||{};\nvar SYSDevInfo=flow.get(‘SYSDevInfo’)||{};\nfor (var key in SYSDevList)\n{\n var payload = SYSDevList[key];\n if(payload!==null)\n {\n msg.time= SYSDevInfo[key][‘time’];\n if(payload.title!==undefined)\n msg.topic=payload.title;\n else\n msg.topic=”【未定义】";\n switch (payload.sType)\n {\n case 0x11:\n BEE_HEX_11.payload=payload.sorValue;\n BEE_HEX_11.topic=msg.topic;\n BEE_HEX_11.time=msg.time;\n break;\n \n case 0x21:\n BEE_HEX_21.payload=payload.sorValue/100;\n BEE_HEX_21.topic=msg.topic;\n BEE_HEX_21.time=msg.time;\n break;\n case 0x22:\n BEE_HEX_22.payload=payload.sorValue/100;\n BEE_HEX_22.topic=msg.topic;\n BEE_HEX_22.time=msg.time;\n break;\n case 0x23:\n BEE_HEX_23.payload=payload.sorValue/100;\n BEE_HEX_23.topic=msg.topic;\n BEE_HEX_23.time=msg.time;\n break;\n case 0x24:\n BEE_HEX_24.payload=payload.sorValue/100;\n BEE_HEX_24.topic=msg.topic;\n BEE_HEX_24.time=msg.time;\n break;\n case 0x25:\n BEE_HEX_25.payload=payload.sorValue/100;\n BEE_HEX_25.topic=msg.topic;\n BEE_HEX_25.time=msg.time;\n break;\n default:\n break;\n }\n }\n}\n\nreturn [BEE_HEX_01_0, BEE_HEX_01_1, BEE_HEX_11, BEE_HEX_21, BEE_HEX_22, BEE_HEX_23, BEE_HEX_24, BEE_HEX_25 ];",
“outputs”: 8,
“noerr”: 0,
“x”: 1220,
“y”: 1460,
“wires”: [
[
“81c35dbd.f5488”,
“c8fc341a.915cb8”
],
[
“2151623a.7a37ee”,
“d889170f.6f47d8”
],
[
“2e2012d.80960ee”,
“70004f5b.c23c1”
],
[
“f512f274.fc5d9”,
“5c6ebd4d.3d58f4”
],
[
“51222756.776d48”,
“bcd7c244.ec2db”
],
[
“c744e0c6.c159b”,
“421a01c3.c8c83”,
“93041973.efc7b8”
],
[
“d6087563.405eb8”,
“41afeca8.e24694”,
“75378e5c.a09bb”
],
[
“9c07144b.b8c7d8”,
“6795079c.2d6e38”
]
],
“outputLabels”: [
“温度”,
“湿度”,
“人体”,
“光照”,
“CO”,
“可燃气”,
“火焰”,
“酒精”
]
},
{
“id”: “1948c02d.f1558”,
“type”: “comment”,
“z”: “a902018.e4bbe”,
“name”: “ZigBee网络数据呈现”,
“info”: “”,
“x”: 1170,
“y”: 1200,
“wires”: []
},
{
“id”: “33973a03.ff8bc6”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “清空缓存”,
“func”: “//save\nflow.set(‘SYSDevList’,{});\nflow.set(‘SYSDevInfo’,{});\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1720,
“y”: 800,
“wires”: [
[]
]
},
{
“id”: “4891cc87.052e84”,
“type”: “inject”,
“z”: “a902018.e4bbe”,
“name”: “”,
“topic”: “”,
“payload”: “”,
“payloadType”: “str”,
“repeat”: “”,
“crontab”: “”,
“once”: true,
“onceDelay”: “”,
“x”: 1570,
“y”: 800,
“wires”: [
[
“33973a03.ff8bc6”
]
]
},
{
“id”: “2151623a.7a37ee”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 3,
“width”: “4”,
“height”: “1”,
“name”: “2”,
“label”: “{{msg.topic}}”,
“format”: “{{msg.payload}}%”,
“layout”: “row-spread”,
“x”: 1430,
“y”: 1320,
“wires”: []
},
{
“id”: “d6087563.405eb8”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 13,
“width”: “4”,
“height”: “1”,
“name”: “7”,
“label”: “{{msg.topic}}”,
“format”: “{{msg.payload}} V”,
“layout”: “row-spread”,
“x”: 1490,
“y”: 1520,
“wires”: []
},
{
“id”: “9c07144b.b8c7d8”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 15,
“width”: “4”,
“height”: “1”,
“name”: “8”,
“label”: “{{msg.topic}}”,
“format”: “{{msg.payload}} V”,
“layout”: “row-spread”,
“x”: 1430,
“y”: 1560,
“wires”: []
},
{
“id”: “51222756.776d48”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 9,
“width”: “4”,
“height”: “1”,
“name”: “5”,
“label”: “{{msg.topic}}”,
“format”: “{{msg.payload}} V”,
“layout”: “row-spread”,
“x”: 1490,
“y”: 1440,
“wires”: []
},
{
“id”: “f512f274.fc5d9”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 7,
“width”: “4”,
“height”: “1”,
“name”: “4”,
“label”: “{{msg.topic}}”,
“format”: “{{msg.payload}} V”,
“layout”: “row-spread”,
“x”: 1430,
“y”: 1400,
“wires”: []
},
{
“id”: “2e2012d.80960ee”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 5,
“width”: “4”,
“height”: “1”,
“name”: “3”,
“label”: “{{msg.topic}}”,
“format”: “{{msg.payload}}”,
“layout”: “row-spread”,
“x”: 1510,
“y”: 1360,
“wires”: []
},
{
“id”: “81c35dbd.f5488”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 1,
“width”: “4”,
“height”: “1”,
“name”: “1”,
“label”: “{{msg.topic}}”,
“format”: “{{msg.payload}}℃”,
“layout”: “row-spread”,
“x”: 1470,
“y”: 1280,
“wires”: []
},
{
“id”: “93041973.efc7b8”,
“type”: “ui_chart”,
“z”: “a902018.e4bbe”,
“name”: “”,
“group”: “2db2f922.0e2a26”,
“order”: 9,
“width”: 0,
“height”: 0,
“label”: “可燃气”,
“chartType”: “line”,
“legend”: “false”,
“xformat”: “HH:mm:ss”,
“interpolate”: “linear”,
“nodata”: “”,
“dot”: false,
“ymin”: “-0”,
“ymax”: “4”,
“removeOlder”: 1,
“removeOlderPoints”: “”,
“removeOlderUnit”: “3600”,
“cutout”: 0,
“useOneColor”: false,
“colors”: [
#1f77b4”,
#aec7e8”,
#ff7f0e”,
#2ca02c”,
#98df8a”,
#d62728”,
#ff9896”,
#9467bd”,
#c5b0d5
],
“useOldStyle”: true,
“x”: 1610,
“y”: 1240,
“wires”: [
[],
[]
]
},
{
“id”: “2648eb04.2d6814”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 2,
“width”: “2”,
“height”: “1”,
“name”: “最后在线”,
“label”: “”,
“format”: “{{msg.payload}}”,
“layout”: “row-left”,
“x”: 1760,
“y”: 1180,
“wires”: []
},
{
“id”: “c8fc341a.915cb8”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “获取时间2”,
“func”: “msg.payload=msg.time;\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1770,
“y”: 1100,
“wires”: [
[
“c1cd33ba.b26bb”
]
]
},
{
“id”: “149c7680.afc48a”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 4,
“width”: “2”,
“height”: “1”,
“name”: “最后在线”,
“label”: “”,
“format”: “{{msg.payload}}”,
“layout”: “row-left”,
“x”: 1940,
“y”: 1240,
“wires”: []
},
{
“id”: “d889170f.6f47d8”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “获取时间2”,
“func”: “msg.payload=msg.time;\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1950,
“y”: 1160,
“wires”: [
[
“84c6e5ec.48b718”
]
]
},
{
“id”: “c4f6a3a4.a8d03”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 6,
“width”: “2”,
“height”: “1”,
“name”: “最后在线”,
“label”: “”,
“format”: “{{msg.payload}}”,
“layout”: “row-left”,
“x”: 1760,
“y”: 1360,
“wires”: []
},
{
“id”: “70004f5b.c23c1”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “获取时间2”,
“func”: “msg.payload=msg.time;\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1770,
“y”: 1280,
“wires”: [
[
“a58bd568.f9a778”
]
]
},
{
“id”: “61cc6e6a.4244f”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 8,
“width”: “2”,
“height”: “1”,
“name”: “最后在线”,
“label”: “”,
“format”: “{{msg.payload}}”,
“layout”: “row-left”,
“x”: 1940,
“y”: 1400,
“wires”: []
},
{
“id”: “5c6ebd4d.3d58f4”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “获取时间2”,
“func”: “msg.payload=msg.time;\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1950,
“y”: 1320,
“wires”: [
[
“a95a7ec7.eb8e9”
]
]
},
{
“id”: “7941327b.8a184c”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 10,
“width”: “2”,
“height”: “1”,
“name”: “最后在线”,
“label”: “”,
“format”: “{{msg.payload}}”,
“layout”: “row-left”,
“x”: 1760,
“y”: 1500,
“wires”: []
},
{
“id”: “bcd7c244.ec2db”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “获取时间2”,
“func”: “msg.payload=msg.time;\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1770,
“y”: 1420,
“wires”: [
[
“c71bc41a.d258f8”
]
]
},
{
“id”: “c0841b29.87b638”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 12,
“width”: “2”,
“height”: “1”,
“name”: “最后在线”,
“label”: “”,
“format”: “{{msg.payload}}”,
“layout”: “row-left”,
“x”: 1940,
“y”: 1560,
“wires”: []
},
{
“id”: “421a01c3.c8c83”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “获取时间2”,
“func”: “msg.payload=msg.time;\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1950,
“y”: 1480,
“wires”: [
[
“ed192592.009588”
]
]
},
{
“id”: “be5a33ba.90831”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 14,
“width”: “2”,
“height”: “1”,
“name”: “最后在线”,
“label”: “”,
“format”: “{{msg.payload}}”,
“layout”: “row-left”,
“x”: 1760,
“y”: 1660,
“wires”: []
},
{
“id”: “75378e5c.a09bb”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “获取时间2”,
“func”: “msg.payload=msg.time;\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1770,
“y”: 1580,
“wires”: [
[
“664ef716.eceee8”
]
]
},
{
“id”: “df5a7325.c0ab”,
“type”: “ui_text”,
“z”: “a902018.e4bbe”,
“group”: “a07a0a3b.9778c8”,
“order”: 16,
“width”: “2”,
“height”: “1”,
“name”: “最后在线”,
“label”: “”,
“format”: “{{msg.payload}}”,
“layout”: “row-left”,
“x”: 1940,
“y”: 1720,
“wires”: []
},
{
“id”: “6795079c.2d6e38”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “获取时间2”,
“func”: “msg.payload=msg.time;\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 1950,
“y”: 1640,
“wires”: [
[
“9d9b33f9.34c81”
]
]
},
{
“id”: “9d9b33f9.34c81”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “时间差”,
“func”: “var dateTimeStamp = msg.payload; \n//------------------------------ \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult="" + parseInt(monthC) + “月前”;\n}\nelse if(weekC>=1){\n\tresult="" + parseInt(weekC) + “周前”;\n}\nelse if(dayC>=1){\n\tresult=""+ parseInt(dayC) +“天前”;\n}\nelse if(hourC>=1){\n\tresult=""+ parseInt(hourC) +“小时前”;\n}\nelse if(minC>=1){\n\tresult=""+ parseInt(minC) +“分钟前”;\n}\nelse if(secC>=1){\n\tresult=""+ parseInt(secC) +“秒前”;\n}else\nresult=“刚刚”;\n//------------------------------ \nif(dateTimeStamp===undefined)\n msg.payload="";\nelse\n msg.payload=result;\nreturn msg;\n",
“outputs”: 1,
“noerr”: 0,
“x”: 1930,
“y”: 1680,
“wires”: [
[
“df5a7325.c0ab”
]
]
},
{
“id”: “ed192592.009588”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “时间差”,
“func”: "var dateTimeStamp = msg.payload; \n//------------------------------ \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7
day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=”" + parseInt(monthC) + “月前”;\n}\nelse if(weekC>=1){\n\tresult="" + parseInt(weekC) + “周前”;\n}\nelse if(dayC>=1){\n\tresult=""+ parseInt(dayC) +“天前”;\n}\nelse if(hourC>=1){\n\tresult=""+ parseInt(hourC) +“小时前”;\n}\nelse if(minC>=1){\n\tresult=""+ parseInt(minC) +“分钟前”;\n}\nelse if(secC>=1){\n\tresult=""+ parseInt(secC) +“秒前”;\n}else\nresult=“刚刚”;\n//------------------------------ \nif(dateTimeStamp===undefined)\n msg.payload="";\nelse\n msg.payload=result;\nreturn msg;\n",
“outputs”: 1,
“noerr”: 0,
“x”: 1930,
“y”: 1520,
“wires”: [
[
“c0841b29.87b638”
]
]
},
{
“id”: “664ef716.eceee8”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “时间差”,
“func”: “var dateTimeStamp = msg.payload; \n//------------------------------ \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult="" + parseInt(monthC) + “月前”;\n}\nelse if(weekC>=1){\n\tresult="" + parseInt(weekC) + “周前”;\n}\nelse if(dayC>=1){\n\tresult=""+ parseInt(dayC) +“天前”;\n}\nelse if(hourC>=1){\n\tresult=""+ parseInt(hourC) +“小时前”;\n}\nelse if(minC>=1){\n\tresult=""+ parseInt(minC) +“分钟前”;\n}\nelse if(secC>=1){\n\tresult=""+ parseInt(secC) +“秒前”;\n}else\nresult=“刚刚”;\n//------------------------------ \nif(dateTimeStamp===undefined)\n msg.payload="";\nelse\n msg.payload=result;\nreturn msg;\n",
“outputs”: 1,
“noerr”: 0,
“x”: 1750,
“y”: 1620,
“wires”: [
[
“be5a33ba.90831”
]
]
},
{
“id”: “c71bc41a.d258f8”,
“type”: “function”,
“z”: “a902018.e4bbe”,
“name”: “时间差”,
“func”: "var dateTimeStamp = msg.payload; \n//------------------------------ \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7
day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=”" + parseInt(monthC) + “月前”;\n}\nelse if(weekC>=1){\n\tresult="" + parseInt(weekC) + “周前”;\n}\nelse if(dayC>=1){\n\tresult=""+ parseInt(dayC) +“天前”;\n}\nelse if(hourC>=1){\n\tresult=""+ parseInt(hourC) +“小时前”;\n}\nelse if(minC>=1){\n\tresult=""+ parseInt(minC) +“分钟前”;\n}\nelse if(secC>=1){\n\tresult=""+ parseInt(secC) +“秒前”;\n}else\nresult=“刚刚”;\n//------------------------------ \nif(dateTimeStamp===undefined)\n msg.payload="";\nelse\n msg.payload=result;\nreturn msg;\n",
“outputs”: 1,
“noerr”: 0,
“x”: 1750,
“y”: 1460,
“wires”: [
[
“7941327b.8a184c”
]
]
},


#3
{
    "id": "a95a7ec7.eb8e9",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1930,
    "y": 1360,
    "wires": [
        [
            "61cc6e6a.4244f"
        ]
    ]
},
{
    "id": "a58bd568.f9a778",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1750,
    "y": 1320,
    "wires": [
        [
            "c4f6a3a4.a8d03"
        ]
    ]
},
{
    "id": "84c6e5ec.48b718",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1930,
    "y": 1200,
    "wires": [
        [
            "149c7680.afc48a"
        ]
    ]
},
{
    "id": "c1cd33ba.b26bb",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1750,
    "y": 1140,
    "wires": [
        [
            "2648eb04.2d6814"
        ]
    ]
},
{
    "id": "b44cb879.c53448",
    "type": "debug",
    "z": "a902018.e4bbe",
    "name": "",
    "active": false,
    "tosidebar": true,
    "console": true,
    "complete": "payload",
    "x": 1240,
    "y": 2340,
    "wires": []
},
{
    "id": "768c13ab.116f6c",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 11,
    "width": "4",
    "height": "1",
    "name": "6",
    "label": "{{msg.topic}}",
    "format": "{{msg.payload}}",
    "layout": "row-spread",
    "x": 1430,
    "y": 2200,
    "wires": []
},
{
    "id": "31ce5d6d.66ccb2",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "数据分离",
    "func": "var OUT0 = {\n    topic:\"通道0\",\n    payload: \"-\"\n};\nvar OUT1 = {\n    topic:\"通道1\",\n    payload: \"-\"\n};\nvar OUT2 = {\n    topic:\"通道2\",\n    payload: \"-\"\n};\nvar OUT3 = {\n    topic:\"通道3\",\n    payload: \"-\"\n};\nvar OUT4 = {\n    topic:\"通道0\",\n    payload: \"-\"\n};\nvar OUT5 = {\n    topic:\"通道1\",\n    payload: \"-\"\n};\nvar OUT6 = {\n    topic:\"通道2\",\n    payload: \"-\"\n};\nvar OUT7 = {\n    topic:\"通道3\",\n    payload: \"-\"\n};\n\nvar SYSDevList=flow.get('SYSDevList')||{};\nvar SYSDevInfo=flow.get('SYSDevInfo')||{};\nfor (var key in SYSDevList)\n{\n    var payload = SYSDevList[key];\n    if(payload!==null)\n    {\n        msg.time= SYSDevInfo[key]['time'];\n        if(payload.title!==undefined)\n            msg.topic=payload.title;\n        else\n            msg.topic=\"【未定义】\";\n        switch (payload.sType)\n        {\n            case 0x30:\n                if(payload.sorAddr==0)\n                {\n                    OUT0.payload=payload.sorValue0.toFixed(3);\n                    //OUT0.topic=msg.topic;\n                    OUT0.time=msg.time;\n                    \n                    OUT1.payload=payload.sorValue1.toFixed(3);\n                    //OUT1.topic=msg.topic;\n                    OUT1.time=msg.time;\n                    \n                    OUT2.payload=payload.sorValue2.toFixed(3);\n                    //OUT2.topic=msg.topic;\n                    OUT2.time=msg.time;\n                    \n                    \n                    OUT3.payload=payload.sorValue3.toFixed(3);\n                    //OUT3.topic=msg.topic;\n                    OUT3.time=msg.time;\n                }\n                else if(payload.sorAddr==0x1234)\n                {\n                    \n                    OUT4.payload=payload.sorValue0.toFixed(3);\n                    //OUT4.topic=msg.topic;\n                    OUT4.time=msg.time;\n                    \n                    OUT5.payload=payload.sorValue1.toFixed(3);\n                    //OUT5.topic=msg.topic;\n                    OUT5.time=msg.time;\n                    \n                    OUT6.payload=payload.sorValue2.toFixed(3);\n                    //OUT6.topic=msg.topic;\n                    OUT6.time=msg.time;\n                    \n                    OUT7.payload=payload.sorValue3.toFixed(3);\n                    //OUT7.topic=msg.topic;\n                    OUT7.time=msg.time;\n                }\n                break;\n            default:\n                break;\n        }\n    }\n}\n\nreturn [OUT0, OUT1, OUT2, OUT3, OUT4, OUT5, OUT6, OUT7 ];",
    "outputs": 8,
    "noerr": 0,
    "x": 1220,
    "y": 2180,
    "wires": [
        [
            "1d4c3930.cfd247",
            "71169ec3.cdc6c"
        ],
        [
            "8c84ceec.c6c78",
            "280558a.30cf9a8"
        ],
        [
            "d5ada5a2.4adb28",
            "4368a357.162a8c"
        ],
        [
            "cf0fde04.f12d9",
            "647a03bc.f840ec"
        ],
        [
            "cb4cd955.a985b8",
            "cc464f9d.4cda4"
        ],
        [
            "768c13ab.116f6c",
            "dc40910b.ca915"
        ],
        [
            "8b3ab393.a4364",
            "b44cb879.c53448",
            "34ee44e1.cad80c"
        ],
        [
            "22debf6.55cd24",
            "2993261c.aed6ea"
        ]
    ],
    "outputLabels": [
        "温度",
        "湿度",
        "人体",
        "光照",
        "CO",
        "可燃气",
        "火焰",
        "酒精"
    ]
},
{
    "id": "3456fdd5.d78a92",
    "type": "comment",
    "z": "a902018.e4bbe",
    "name": "ZigBee网络数据呈现",
    "info": "",
    "x": 1170,
    "y": 1920,
    "wires": []
},
{
    "id": "8c84ceec.c6c78",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 3,
    "width": "4",
    "height": "1",
    "name": "2",
    "label": "{{msg.topic}}",
    "format": "{{msg.payload}}",
    "layout": "row-spread",
    "x": 1430,
    "y": 2040,
    "wires": []
},
{
    "id": "8b3ab393.a4364",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 13,
    "width": "4",
    "height": "1",
    "name": "7",
    "label": "{{msg.topic}}",
    "format": "{{msg.payload}}",
    "layout": "row-spread",
    "x": 1490,
    "y": 2240,
    "wires": []
},
{
    "id": "22debf6.55cd24",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 15,
    "width": "4",
    "height": "1",
    "name": "8",
    "label": "{{msg.topic}}",
    "format": "{{msg.payload}}",
    "layout": "row-spread",
    "x": 1430,
    "y": 2280,
    "wires": []
},
{
    "id": "cb4cd955.a985b8",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 9,
    "width": "4",
    "height": "1",
    "name": "5",
    "label": "{{msg.topic}}",
    "format": "{{msg.payload}}",
    "layout": "row-spread",
    "x": 1490,
    "y": 2160,
    "wires": []
},
{
    "id": "cf0fde04.f12d9",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 7,
    "width": "4",
    "height": "1",
    "name": "4",
    "label": "{{msg.topic}}",
    "format": "{{msg.payload}}",
    "layout": "row-spread",
    "x": 1430,
    "y": 2120,
    "wires": []
},
{
    "id": "d5ada5a2.4adb28",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 5,
    "width": "4",
    "height": "1",
    "name": "3",
    "label": "{{msg.topic}}",
    "format": "{{msg.payload}}",
    "layout": "row-spread",
    "x": 1510,
    "y": 2080,
    "wires": []
},
{
    "id": "1d4c3930.cfd247",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 1,
    "width": "4",
    "height": "1",
    "name": "1",
    "label": "{{msg.topic}}",
    "format": "{{msg.payload}}",
    "layout": "row-spread",
    "x": 1470,
    "y": 2000,
    "wires": []
},
{
    "id": "a445f096.2b0af",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 2,
    "width": "2",
    "height": "1",
    "name": "最后在线",
    "label": "",
    "format": "{{msg.payload}}",
    "layout": "row-left",
    "x": 1760,
    "y": 1900,
    "wires": []
},
{
    "id": "71169ec3.cdc6c",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "获取时间2",
    "func": "msg.payload=msg.time;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1770,
    "y": 1820,
    "wires": [
        [
            "d85d10c4.dc36f"
        ]
    ]
},
{
    "id": "baa40c26.3bc13",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 4,
    "width": "2",
    "height": "1",
    "name": "最后在线",
    "label": "",
    "format": "{{msg.payload}}",
    "layout": "row-left",
    "x": 1940,
    "y": 1960,
    "wires": []
},
{
    "id": "280558a.30cf9a8",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "获取时间2",
    "func": "msg.payload=msg.time;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1950,
    "y": 1880,
    "wires": [
        [
            "8b7a180a.968758"
        ]
    ]
},
{
    "id": "2263624a.ca929e",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 6,
    "width": "2",
    "height": "1",
    "name": "最后在线",
    "label": "",
    "format": "{{msg.payload}}",
    "layout": "row-left",
    "x": 1760,
    "y": 2080,
    "wires": []
},
{
    "id": "4368a357.162a8c",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "获取时间2",
    "func": "msg.payload=msg.time;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1770,
    "y": 2000,
    "wires": [
        [
            "14b28130.c7aaff"
        ]
    ]
},
{
    "id": "871b204c.9a297",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 8,
    "width": "2",
    "height": "1",
    "name": "最后在线",
    "label": "",
    "format": "{{msg.payload}}",
    "layout": "row-left",
    "x": 1940,
    "y": 2120,
    "wires": []
},
{
    "id": "647a03bc.f840ec",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "获取时间2",
    "func": "msg.payload=msg.time;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1950,
    "y": 2040,
    "wires": [
        [
            "3170312f.724fde"
        ]
    ]
},
{
    "id": "fce1ae41.5eb8e",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 10,
    "width": "2",
    "height": "1",
    "name": "最后在线",
    "label": "",
    "format": "{{msg.payload}}",
    "layout": "row-left",
    "x": 1760,
    "y": 2220,
    "wires": []
},
{
    "id": "cc464f9d.4cda4",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "获取时间2",
    "func": "msg.payload=msg.time;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1770,
    "y": 2140,
    "wires": [
        [
            "f2afba31.a55558"
        ]
    ]
},
{
    "id": "2fe7b3c3.c1247c",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 12,
    "width": "2",
    "height": "1",
    "name": "最后在线",
    "label": "",
    "format": "{{msg.payload}}",
    "layout": "row-left",
    "x": 1940,
    "y": 2280,
    "wires": []
},
{
    "id": "dc40910b.ca915",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "获取时间2",
    "func": "msg.payload=msg.time;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1950,
    "y": 2200,
    "wires": [
        [
            "b584c499.ebf928"
        ]
    ]
},
{
    "id": "a70e9006.23dc6",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 14,
    "width": "2",
    "height": "1",
    "name": "最后在线",
    "label": "",
    "format": "{{msg.payload}}",
    "layout": "row-left",
    "x": 1760,
    "y": 2380,
    "wires": []
},
{
    "id": "34ee44e1.cad80c",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "获取时间2",
    "func": "msg.payload=msg.time;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1770,
    "y": 2300,
    "wires": [
        [
            "144bb8bd.121927"
        ]
    ]
},
{
    "id": "7735ab1b.365894",
    "type": "ui_text",
    "z": "a902018.e4bbe",
    "group": "f9c50b26.3766e8",
    "order": 16,
    "width": "2",
    "height": "1",
    "name": "最后在线",
    "label": "",
    "format": "{{msg.payload}}",
    "layout": "row-left",
    "x": 1940,
    "y": 2440,
    "wires": []
},
{
    "id": "2993261c.aed6ea",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "获取时间2",
    "func": "msg.payload=msg.time;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1950,
    "y": 2360,
    "wires": [
        [
            "35f7c417.d80fbc"
        ]
    ]
},
{
    "id": "35f7c417.d80fbc",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1930,
    "y": 2400,
    "wires": [
        [
            "7735ab1b.365894"
        ]
    ]
},
{
    "id": "b584c499.ebf928",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1930,
    "y": 2240,
    "wires": [
        [
            "2fe7b3c3.c1247c"
        ]
    ]
},
{
    "id": "144bb8bd.121927",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1750,
    "y": 2340,
    "wires": [
        [
            "a70e9006.23dc6"
        ]
    ]
},
{
    "id": "f2afba31.a55558",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1750,
    "y": 2180,
    "wires": [
        [
            "fce1ae41.5eb8e"
        ]
    ]
},
{
    "id": "3170312f.724fde",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1930,
    "y": 2080,
    "wires": [
        [
            "871b204c.9a297"
        ]
    ]
},
{
    "id": "14b28130.c7aaff",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1750,
    "y": 2040,
    "wires": [
        [
            "2263624a.ca929e"
        ]
    ]
},
{
    "id": "8b7a180a.968758",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1930,
    "y": 1920,
    "wires": [
        [
            "baa40c26.3bc13"
        ]
    ]
},
{
    "id": "d85d10c4.dc36f",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "时间差",
    "func": "var dateTimeStamp = msg.payload;   \n//------------------------------  \nvar seconds = 1000;\nvar minute = 60 * seconds;\nvar hour = minute * 60;\nvar day = hour * 24;\nvar halfamonth = day * 15;\nvar month = day * 30;\nvar now = new Date().getTime();\n//时间差的毫秒数\nvar diffValue = now - dateTimeStamp;\nif(diffValue < 0){return;}\nvar monthC =diffValue/month;\nvar weekC =diffValue/(7*day);\nvar dayC =diffValue/day;\nvar hourC =diffValue/hour;\nvar minC =diffValue/minute;\nvar secC =diffValue/seconds;\nif(monthC>=1){\n\tresult=\"\" + parseInt(monthC) + \"月前\";\n}\nelse if(weekC>=1){\n\tresult=\"\" + parseInt(weekC) + \"周前\";\n}\nelse if(dayC>=1){\n\tresult=\"\"+ parseInt(dayC) +\"天前\";\n}\nelse if(hourC>=1){\n\tresult=\"\"+ parseInt(hourC) +\"小时前\";\n}\nelse if(minC>=1){\n\tresult=\"\"+ parseInt(minC) +\"分钟前\";\n}\nelse if(secC>=1){\n\tresult=\"\"+ parseInt(secC) +\"秒前\";\n}else\nresult=\"刚刚\";\n//------------------------------ \nif(dateTimeStamp===undefined)\n    msg.payload=\"\";\nelse\n    msg.payload=result;\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1750,
    "y": 1860,
    "wires": [
        [
            "a445f096.2b0af"
        ]
    ]
},
{
    "id": "826982ef.7707",
    "type": "ui_switch",
    "z": "a902018.e4bbe",
    "name": "",
    "label": "开关1",
    "group": "7b3f440e.efd59c",
    "order": 4,
    "width": "6",
    "height": "1",
    "passthru": true,
    "decouple": "false",
    "topic": "RELAY",
    "style": "",
    "onvalue": "0100000103",
    "onvalueType": "str",
    "onicon": "",
    "oncolor": "",
    "offvalue": "0100000202",
    "offvalueType": "str",
    "officon": "",
    "offcolor": "",
    "x": 1310,
    "y": 2500,
    "wires": [
        [
            "ce83ed14.5e78a"
        ]
    ]
},
{
    "id": "892c611a.c847c",
    "type": "ui_switch",
    "z": "a902018.e4bbe",
    "name": "",
    "label": "开关2",
    "group": "7b3f440e.efd59c",
    "order": 4,
    "width": "6",
    "height": "1",
    "passthru": true,
    "decouple": "false",
    "topic": "RELAY",
    "style": "",
    "onvalue": "0200000102",
    "onvalueType": "str",
    "onicon": "",
    "oncolor": "",
    "offvalue": "0200000101",
    "offvalueType": "str",
    "officon": "",
    "offcolor": "",
    "x": 1310,
    "y": 2540,
    "wires": [
        [
            "ce83ed14.5e78a"
        ]
    ]
},
{
    "id": "17b6b26d.1b1c8e",
    "type": "ui_switch",
    "z": "a902018.e4bbe",
    "name": "",
    "label": "开关3",
    "group": "7b3f440e.efd59c",
    "order": 4,
    "width": "6",
    "height": "1",
    "passthru": true,
    "decouple": "false",
    "topic": "RELAY",
    "style": "",
    "onvalue": "0300000101",
    "onvalueType": "str",
    "onicon": "",
    "oncolor": "",
    "offvalue": "0300000100",
    "offvalueType": "str",
    "officon": "",
    "offcolor": "",
    "x": 1310,
    "y": 2580,
    "wires": [
        [
            "ce83ed14.5e78a"
        ]
    ]
},

#4
{
    "id": "20ed5cac.3c72f4",
    "type": "ui_switch",
    "z": "a902018.e4bbe",
    "name": "",
    "label": "开关4",
    "group": "7b3f440e.efd59c",
    "order": 4,
    "width": "6",
    "height": "1",
    "passthru": true,
    "decouple": "false",
    "topic": "RELAY",
    "style": "",
    "onvalue": "0400001101",
    "onvalueType": "str",
    "onicon": "",
    "oncolor": "",
    "offvalue": "0400002200",
    "offvalueType": "str",
    "officon": "",
    "offcolor": "",
    "x": 1310,
    "y": 2620,
    "wires": [
        [
            "ce83ed14.5e78a"
        ]
    ]
},
{
    "id": "d4ddc064.b8155",
    "type": "ui_switch",
    "z": "a902018.e4bbe",
    "name": "",
    "label": "开关5",
    "group": "7b3f440e.efd59c",
    "order": 4,
    "width": "6",
    "height": "1",
    "passthru": true,
    "decouple": "false",
    "topic": "RELAY",
    "style": "",
    "onvalue": "0500001101",
    "onvalueType": "str",
    "onicon": "",
    "oncolor": "",
    "offvalue": "0500002200",
    "offvalueType": "str",
    "officon": "",
    "offcolor": "",
    "x": 1310,
    "y": 2660,
    "wires": [
        [
            "ce83ed14.5e78a"
        ]
    ]
},
{
    "id": "d9704e46.7ba46",
    "type": "ui_switch",
    "z": "a902018.e4bbe",
    "name": "",
    "label": "开关6",
    "group": "7b3f440e.efd59c",
    "order": 4,
    "width": "6",
    "height": "1",
    "passthru": true,
    "decouple": "false",
    "topic": "RELAY",
    "style": "",
    "onvalue": "0100001000",
    "onvalueType": "str",
    "onicon": "",
    "oncolor": "",
    "offvalue": "0100002000",
    "offvalueType": "str",
    "officon": "",
    "offcolor": "",
    "x": 1310,
    "y": 2740,
    "wires": [
        [
            "ce83ed14.5e78a"
        ]
    ]
},
{
    "id": "dbf7b7a9.7b12e8",
    "type": "ui_switch",
    "z": "a902018.e4bbe",
    "name": "",
    "label": "开关7",
    "group": "7b3f440e.efd59c",
    "order": 4,
    "width": "6",
    "height": "1",
    "passthru": true,
    "decouple": "false",
    "topic": "RELAY",
    "style": "",
    "onvalue": "0100000100",
    "onvalueType": "str",
    "onicon": "",
    "oncolor": "",
    "offvalue": "0100000200",
    "offvalueType": "str",
    "officon": "",
    "offcolor": "",
    "x": 1310,
    "y": 2780,
    "wires": [
        [
            "ce83ed14.5e78a"
        ]
    ]
},
{
    "id": "d1ac6d5b.0268c",
    "type": "ui_switch",
    "z": "a902018.e4bbe",
    "name": "",
    "label": "开关8",
    "group": "7b3f440e.efd59c",
    "order": 4,
    "width": "6",
    "height": "1",
    "passthru": true,
    "decouple": "false",
    "topic": "RELAY",
    "style": "",
    "onvalue": "0100001100",
    "onvalueType": "str",
    "onicon": "",
    "oncolor": "",
    "offvalue": "0100002200",
    "offvalueType": "str",
    "officon": "",
    "offcolor": "",
    "x": 1310,
    "y": 2820,
    "wires": [
        [
            "ce83ed14.5e78a"
        ]
    ]
},
{
    "id": "3f2148f7.d6c098",
    "type": "serial in",
    "z": "a902018.e4bbe",
    "name": "串口 伏羲四通道电流采集",
    "serial": "eb58d82e.13bd98",
    "x": 1270,
    "y": 720,
    "wires": [
        [
            "fe46044e.c23a98"
        ]
    ]
},
{
    "id": "1bc78b0b.fece25",
    "type": "comment",
    "z": "a902018.e4bbe",
    "name": "ZigBee网络继电器",
    "info": "",
    "x": 1170,
    "y": 2440,
    "wires": []
},
{
    "id": "ce83ed14.5e78a",
    "type": "function",
    "z": "a902018.e4bbe",
    "name": "生成指令",
    "func": "//需要预设5字节hex已经校验过的控制指令\nmsg.payload=new Buffer(\"fff50502\"+msg.payload,'hex');\nreturn msg;\n",
    "outputs": 1,
    "noerr": 0,
    "x": 1520,
    "y": 2640,
    "wires": [
        [
            "a01e586d.1d9968"
        ]
    ]
},
{
    "id": "a01e586d.1d9968",
    "type": "serial out",
    "z": "a902018.e4bbe",
    "name": "",
    "serial": "ca3fbf87.3a16f",
    "x": 1700,
    "y": 2660,
    "wires": []
},
{
    "id": "ca3fbf87.3a16f",
    "type": "serial-port",
    "z": "",
    "serialport": "/dev/ttyS2",
    "serialbaud": "38400",
    "databits": "8",
    "parity": "none",
    "stopbits": "1",
    "newline": "5",
    "bin": "bin",
    "out": "time",
    "addchar": false
},
{
    "id": "a07a0a3b.9778c8",
    "type": "ui_group",
    "z": "",
    "name": "简单传感器",
    "tab": "2cac0a0.ed17cf6",
    "order": 1,
    "disp": true,
    "width": "6",
    "collapse": false
},
{
    "id": "2db2f922.0e2a26",
    "type": "ui_group",
    "z": "",
    "name": "可视化呈现",
    "tab": "2cac0a0.ed17cf6",
    "order": 4,
    "disp": true,
    "width": "6",
    "collapse": false
},
{
    "id": "f9c50b26.3766e8",
    "type": "ui_group",
    "z": "",
    "name": "工业级传感器(电流)",
    "tab": "2cac0a0.ed17cf6",
    "order": 2,
    "disp": true,
    "width": "6",
    "collapse": false
},
{
    "id": "7b3f440e.efd59c",
    "type": "ui_group",
    "z": "",
    "name": "开关",
    "tab": "2cac0a0.ed17cf6",
    "order": 3,
    "disp": true,
    "width": "6",
    "collapse": false
},
{
    "id": "eb58d82e.13bd98",
    "type": "serial-port",
    "z": "",
    "serialport": "/dev/ttyUSB1",
    "serialbaud": "38400",
    "databits": "8",
    "parity": "none",
    "stopbits": "1",
    "newline": "5",
    "bin": "bin",
    "out": "time",
    "addchar": false
},
{
    "id": "2cac0a0.ed17cf6",
    "type": "ui_tab",
    "z": "",
    "name": "Zigbee 无线传感网",
    "icon": "dashboard",
    "order": 1
}

]