『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: adxr

[经验分享] 让爱快路由器对接HASS 版本2.0 全用Node-RED+MQTT实现

[复制链接]

3

主题

167

帖子

1023

积分

金牌会员

Rank: 6Rank: 6

积分
1023
金钱
856
HASS币
0
发表于 2024-3-22 21:39:03 | 显示全部楼层
分享一下格式化过的,直接复制粘贴就行

[
    {
        "id": "2c2c3be32c085667",
        "type": "tab",
        "label": "爱快系统信息V2.0",
        "disabled": false,
        "info": ""
    },
    {
        "id": "7e912416d539be36",
        "type": "debug",
        "z": "2c2c3be32c085667",
        "name": "ACL-MAC",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 800,
        "y": 360,
        "wires": []
    },
    {
        "id": "fae72fe3e40be763",
        "type": "mqtt in",
        "z": "2c2c3be32c085667",
        "name": "MAC限网开关接收",
        "topic": "cmnd/ikuai/acl",
        "qos": "2",
        "datatype": "auto",
        "broker": "854a61c87270b850",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 110,
        "y": 280,
        "wires": [
            [
                "a850f81f97c18cf0"
            ]
        ]
    },
    {
        "id": "eec6094e6fa6575c",
        "type": "inject",
        "z": "2c2c3be32c085667",
        "name": "10m'更新限网状态",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "600",
        "crontab": "",
        "once": true,
        "onceDelay": "2",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 500,
        "wires": [
            [
                "7ff150da9f24d11b"
            ]
        ]
    },
    {
        "id": "422d615e49b03d09",
        "type": "debug",
        "z": "2c2c3be32c085667",
        "name": "整理后的系统信息",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 240,
        "wires": []
    },
    {
        "id": "bfa7ee77d2b8793e",
        "type": "mqtt out",
        "z": "2c2c3be32c085667",
        "name": "ikuai",
        "topic": "ikuai/int",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "854a61c87270b850",
        "x": 810,
        "y": 140,
        "wires": []
    },
    {
        "id": "552df1d30c2a267e",
        "type": "function",
        "z": "2c2c3be32c085667",
        "name": "账号参数",
        "func": "var username=\"admin\" ; //用户名\nvar pass = \"ff303c2ss3fa1584seaaaafb2wwwc7dcf\"; //密码MD5加密值\nvar ip=\"192.168.1.1:8880\";//爱快IP加端口\nglobal.set(\"ip\", ip);\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json';\nmsg.payload = `{\"username\": \"${username}\",\"passwd\":\"${pass}\",\"pass\":\"c2FsdF8xMXNoMTIzNDU2\",\"remember_password\":\"\"}`;\nmsg.url = 'http://'+ip+'/Action/login';\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 40,
        "wires": [
            [
                "483fe70d6de6c849"
            ]
        ]
    },
    {
        "id": "aaaf8c0f9239c9ff",
        "type": "function",
        "z": "2c2c3be32c085667",
        "name": "整理结果",
        "func": "const rmsg={};\nmsg.payload ={\n    \"cpu\": msg.payload.Data.sysstat.cpu[0].replace(\"%\", \"\"),//CPU信息,可做多个CUP平均值\n    \"cputemp\":msg.payload.Data.sysstat.cputemp[0],//CPU温度\n    \"memory\": msg.payload.Data.sysstat.memory.used.replace(\"%\", \"\"), \n    \"online_user\":msg.payload.Data.sysstat.online_user.count,\n    \"connect_num\":msg.payload.Data.sysstat.stream.connect_num,\n    \"upload\":msg.payload.Data.sysstat.stream.upload, \n    \"total_down\":msg.payload.Data.sysstat.stream.download\n    }\nreturn msg;\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 660,
        "y": 140,
        "wires": [
            [
                "422d615e49b03d09",
                "bfa7ee77d2b8793e"
            ]
        ]
    },
    {
        "id": "fb9186f4099b2613",
        "type": "function",
        "z": "2c2c3be32c085667",
        "name": "保存cookie",
        "func": "var cookie = msg.headers[\"set-cookie\"][0];\nglobal.set(\"cookie\", cookie);\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 710,
        "y": 40,
        "wires": [
            [
                "be39a8868377510c"
            ]
        ]
    },
    {
        "id": "a850f81f97c18cf0",
        "type": "function",
        "z": "2c2c3be32c085667",
        "name": "开关限网cmnd",
        "func": "const rmsg={};\nconst cmnd = msg.payload;\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    case \"30\":\n    rmsg.id=\"3\";//mac限网ID\n    rmsg.action=\"down\";//限网开up/关down\n    break;\n    case \"31\":\n    rmsg.id=\"3\";//mac限网ID\n    rmsg.action=\"up\";//限网开up/关down\n    break;\n    case \"40\":\n    rmsg.id=\"4\";//mac限网ID\n    rmsg.action=\"down\";//限网开up/关down\n    break;\n    case \"41\":\n    rmsg.id=\"4\";//mac限网ID\n    rmsg.action=\"up\";//限网开up/关down\n    break;\n    }\nreturn rmsg;\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 280,
        "wires": [
            [
                "23f451bab059d7ba"
            ]
        ]
    },
    {
        "id": "23f451bab059d7ba",
        "type": "function",
        "z": "2c2c3be32c085667",
        "name": "MAC_ALC限网",
        "func": "var cookie = global.get(\"cookie\");\nvar ip = global.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": 280,
        "wires": [
            [
                "6c563cabecf54d48"
            ]
        ]
    },
    {
        "id": "cb97d1e4113f7f0b",
        "type": "function",
        "z": "2c2c3be32c085667",
        "name": "整理结果",
        "func": "var data=msg.payload.Data.data\nvar id ;\nvar enabled;\nmsg={};\nmsg.payload={};\nvar dalen = data.length;\nfor(var i=0;i<dalen;i++){\n    id = data.id;\n    if (data.enabled==\"yes\"){\n        enabled =\"ON\";\n        }else{\n            enabled = \"OFF\";\n            }\n            msg.payload[id] = enabled;\n            }\nreturn msg;\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 860,
        "y": 440,
        "wires": [
            [
                "7e912416d539be36",
                "cdf692300fd5fabc"
            ]
        ]
    },
    {
        "id": "7ff150da9f24d11b",
        "type": "function",
        "z": "2c2c3be32c085667",
        "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": 440,
        "wires": [
            [
                "2dd5b4d5cc02327f"
            ]
        ]
    },
    {
        "id": "af744a977946c193",
        "type": "function",
        "z": "2c2c3be32c085667",
        "name": "请求系统信息",
        "func": "var cookie = global.get(\"cookie\");\nvar ip = global.get(\"ip\");\n\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json';\nmsg.headers['cookie'] = cookie;\nmsg.payload = `{\"func_name\":\"homepage\",\"action\":\"show\",\"param\":{\"TYPE\":\"sysstat,ac_status\"}}`;\nmsg.url = 'http://' + ip +'/Action/call';\nreturn msg;\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 320,
        "y": 140,
        "wires": [
            [
                "d7a94c9712ee6ce2"
            ]
        ]
    },
    {
        "id": "2dd5b4d5cc02327f",
        "type": "function",
        "z": "2c2c3be32c085667",
        "name": "MAC_ALC限网",
        "func": "var cookie = global.get(\"cookie\");\nvar ip = global.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": 440,
        "wires": [
            [
                "b134d64590a2ecde"
            ]
        ]
    },
    {
        "id": "be39a8868377510c",
        "type": "debug",
        "z": "2c2c3be32c085667",
        "name": "login",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 870,
        "y": 40,
        "wires": []
    },
    {
        "id": "25626fb7e0af0a12",
        "type": "inject",
        "z": "2c2c3be32c085667",
        "name": "2小时重新登录一次",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "7200",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 40,
        "wires": [
            [
                "552df1d30c2a267e"
            ]
        ]
    },
    {
        "id": "483fe70d6de6c849",
        "type": "http request",
        "z": "2c2c3be32c085667",
        "name": "发送登录请求",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 540,
        "y": 40,
        "wires": [
            [
                "fb9186f4099b2613"
            ]
        ]
    },
    {
        "id": "bb9bbbe268ff6273",
        "type": "inject",
        "z": "2c2c3be32c085667",
        "name": "10秒更新系统信息",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "10",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 140,
        "wires": [
            [
                "af744a977946c193"
            ]
        ]
    },
    {
        "id": "d7a94c9712ee6ce2",
        "type": "http request",
        "z": "2c2c3be32c085667",
        "name": "发送请求",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 500,
        "y": 140,
        "wires": [
            [
                "aaaf8c0f9239c9ff",
                "9a38cc04ad825160"
            ]
        ]
    },
    {
        "id": "9a38cc04ad825160",
        "type": "debug",
        "z": "2c2c3be32c085667",
        "name": "未整理的系统信息",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 750,
        "y": 80,
        "wires": []
    },
    {
        "id": "b134d64590a2ecde",
        "type": "http request",
        "z": "2c2c3be32c085667",
        "name": "发送请求",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 720,
        "y": 440,
        "wires": [
            [
                "cb97d1e4113f7f0b"
            ]
        ]
    },
    {
        "id": "cdf692300fd5fabc",
        "type": "mqtt out",
        "z": "2c2c3be32c085667",
        "name": "ikuai/acl",
        "topic": "stat/ikuai/acl",
        "qos": "0",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "854a61c87270b850",
        "x": 820,
        "y": 540,
        "wires": []
    },
    {
        "id": "6c563cabecf54d48",
        "type": "http request",
        "z": "2c2c3be32c085667",
        "name": "发送请求",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 740,
        "y": 280,
        "wires": [
            [
                "7ff150da9f24d11b"
            ]
        ]
    },
    {
        "id": "854a61c87270b850",
        "type": "mqtt-broker",
        "name": "",
        "broker": "127.0.0.1",
        "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": {},
        "sessionExpiry": ""
    }
]
回复

使用道具 举报

0

主题

39

帖子

147

积分

注册会员

Rank: 2

积分
147
金钱
108
HASS币
0
发表于 2024-3-23 17:50:19 | 显示全部楼层
这个好,看看,学习下
回复

使用道具 举报

0

主题

74

帖子

217

积分

中级会员

Rank: 3Rank: 3

积分
217
金钱
143
HASS币
0
发表于 2024-3-23 19:08:59 | 显示全部楼层
学习学习一下!感谢分享!
回复

使用道具 举报

0

主题

12

帖子

51

积分

注册会员

Rank: 2

积分
51
金钱
39
HASS币
0
发表于 2024-3-24 21:33:18 | 显示全部楼层
学习学习!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
回复

使用道具 举报

0

主题

1

帖子

24

积分

新手上路

Rank: 1

积分
24
金钱
23
HASS币
0
发表于 2024-3-27 13:39:14 | 显示全部楼层
upnp的不能正常显示,看看这个
回复

使用道具 举报

3

主题

32

帖子

113

积分

注册会员

Rank: 2

积分
113
金钱
81
HASS币
0
发表于 2024-3-27 13:50:29 | 显示全部楼层
爱快路由器?
回复

使用道具 举报

0

主题

15

帖子

62

积分

注册会员

Rank: 2

积分
62
金钱
47
HASS币
0
发表于 2024-3-27 17:16:24 | 显示全部楼层
谢谢分享!!!
回复

使用道具 举报

1

主题

21

帖子

165

积分

注册会员

Rank: 2

积分
165
金钱
144
HASS币
0
发表于 2024-3-27 18:35:40 | 显示全部楼层
谢谢大佬分享
回复

使用道具 举报

32

主题

2002

帖子

5091

积分

论坛元老

Rank: 8Rank: 8

积分
5091
金钱
3089
HASS币
50
QQ
发表于 2024-3-28 01:23:08 | 显示全部楼层
adxr 发表于 2024-3-21 12:41
高格也差不多的,抓一下包改一下

关键我是小白,不会
我不生产技术,我只是技术的搬运工。
回复

使用道具 举报

2

主题

411

帖子

2367

积分

金牌会员

Rank: 6Rank: 6

积分
2367
金钱
1956
HASS币
0
QQ
发表于 2024-3-28 09:40:52 | 显示全部楼层
谢谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-29 23:02 , Processed in 0.063630 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表