- 积分
- 228
- 金钱
- 173
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
中级会员
- 积分
- 228
- 金钱
- 173
- HASS币
- 0
|
发表于 2024-6-14 18:09:06
|
显示全部楼层
限制mac那段不知道是代码被我动过了还是啥原因的,反正也是调不起来,现在改好了,贴出来以防万一
[
{
"id": "c8e808abf4f80545",
"type": "debug",
"z": "0380ab821e0383ce",
"name": "ACL-MAC",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 900,
"y": 380,
"wires": []
},
{
"id": "a1ea73e0c7966881",
"type": "mqtt in",
"z": "0380ab821e0383ce",
"name": "MAC限网开关接收",
"topic": "cmnd/ikuai/acl",
"qos": "2",
"datatype": "auto",
"broker": "854a61c87270b850",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 210,
"y": 300,
"wires": [
[
"7747972f81806646",
"9322ad2d9688c2ec"
]
]
},
{
"id": "7747972f81806646",
"type": "function",
"z": "0380ab821e0383ce",
"name": "开关限网cmnd",
"func": "const rmsg = {};\nconst cmnd = msg.payload;\n\nswitch (cmnd) {\n case \"10\":\n rmsg.id = \"1\"; // mac限网ID\n rmsg.action = \"down\"; // 限网开up/关down\n break;\n case \"11\":\n rmsg.id = \"1\"; // mac限网ID\n rmsg.action = \"up\"; // 限网开up/关down\n break;\n case \"20\":\n rmsg.id = \"2\"; // mac限网ID\n rmsg.action = \"down\"; // 限网开up/关down\n break;\n case \"21\":\n rmsg.id = \"2\"; // mac限网ID\n rmsg.action = \"up\"; // 限网开up/关down\n break;\n default:\n node.warn(\"Unknown command: \" + cmnd);\n return null;\n}\n\nreturn rmsg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 460,
"y": 300,
"wires": [
[
"0964acc01adccbbd"
]
]
},
{
"id": "0964acc01adccbbd",
"type": "function",
"z": "0380ab821e0383ce",
"name": "MAC_ALC限网",
"func": "var cookie = flow.get(\"cookie\");\nvar ip = flow.get(\"ip\");\n\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json';\nmsg.headers['cookie'] = cookie;\nmsg.payload = `{\"func_name\":\"acl_mac\",\"action\":\"${msg.action}\",\"param\":{\"id\":\"${msg.id}\"}}`;\nmsg.url = 'http://' + ip +'/Action/call';\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 660,
"y": 300,
"wires": [
[
"e3c0eedca3929c6e",
"810937fe64701f1a"
]
]
},
{
"id": "d85996e020c63e58",
"type": "function",
"z": "0380ab821e0383ce",
"name": "整理结果",
"func": "var data = msg.payload.Data.data;\nvar id;\nvar enabled;\nmsg = {};\nmsg.payload = {};\nvar dalen = data.length;\n\nfor (var i = 0; i < dalen; i++) {\n id = data[i].id;\n if (data[i].enabled === \"yes\") {\n enabled = \"ON\";\n } else {\n enabled = \"OFF\";\n }\n msg.payload[id] = enabled;\n}\n\n// 添加调试信息\nnode.warn(`Parsed Data: ${JSON.stringify(msg.payload)}`);\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 960,
"y": 460,
"wires": [
[
"c8e808abf4f80545",
"289c13a9895f9ed6"
]
]
},
{
"id": "8c70993fcd533113",
"type": "function",
"z": "0380ab821e0383ce",
"name": "请求更新限网状态",
"func": "msg.action=\"show\";//限网开up/关down\nmsg.id=\"\";//mac限网ID\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 460,
"wires": [
[
"6ae93e1b4659ae12",
"69765f8b22e1b19a"
]
]
},
{
"id": "6ae93e1b4659ae12",
"type": "function",
"z": "0380ab821e0383ce",
"name": "MAC_ALC限网",
"func": "var cookie = flow.get(\"cookie\");\nvar ip = flow.get(\"ip\");\n\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json';\nmsg.headers['cookie'] = cookie;\nmsg.payload = `{\"func_name\":\"acl_mac\",\"action\":\"${msg.action}\",\"param\":{\"id\":\"${msg.id}\"}}`;\nmsg.url = 'http://' + ip +'/Action/call';\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 460,
"wires": [
[
"44e8ff13fdb4714d",
"952fc8c0daea76a6"
]
]
},
{
"id": "44e8ff13fdb4714d",
"type": "http request",
"z": "0380ab821e0383ce",
"name": "发送请求",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 780,
"y": 460,
"wires": [
[
"d85996e020c63e58"
]
]
},
{
"id": "289c13a9895f9ed6",
"type": "mqtt out",
"z": "0380ab821e0383ce",
"name": "ikuai/acl",
"topic": "stat/ikuai/acl",
"qos": "0",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "854a61c87270b850",
"x": 920,
"y": 560,
"wires": []
},
{
"id": "e3c0eedca3929c6e",
"type": "http request",
"z": "0380ab821e0383ce",
"name": "发送请求",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 840,
"y": 300,
"wires": [
[
"24466d6b5e210fcc",
"8c70993fcd533113"
]
]
},
{
"id": "810937fe64701f1a",
"type": "debug",
"z": "0380ab821e0383ce",
"name": "发送请求",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 820,
"y": 220,
"wires": []
},
{
"id": "9322ad2d9688c2ec",
"type": "debug",
"z": "0380ab821e0383ce",
"name": "收到",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 390,
"y": 240,
"wires": []
},
{
"id": "952fc8c0daea76a6",
"type": "debug",
"z": "0380ab821e0383ce",
"name": "发送请求2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 690,
"y": 560,
"wires": []
},
{
"id": "24466d6b5e210fcc",
"type": "debug",
"z": "0380ab821e0383ce",
"name": "debug 11",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1040,
"y": 300,
"wires": []
},
{
"id": "69765f8b22e1b19a",
"type": "debug",
"z": "0380ab821e0383ce",
"name": "请求更新限网状态",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 390,
"y": 620,
"wires": []
},
{
"id": "854a61c87270b850",
"type": "mqtt-broker",
"name": "",
"broker": "core-mosquitto",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
] |
|