JSON 代码,可直接导入到 Node - RED 中。请确保在实际使用时,将占位的手机号、验证码、设备 `did` 和 `pk` 等信息替换为真实有效的值。
```json
[
{
"id": "c29c1697.56e9e8",
"type": "inject",
"z": "2797f4c1.8b059e",
"name": "发送短信验证码",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{"phone":"13xxxxx"}",
"payloadType": "json",
"x": 110,
"y": 140,
"wires": [
[
"56c98c0f.d009d4"
]
]
},
{
"id": "56c98c0f.d009d4",
"type": "http request",
"z": "2797f4c1.8b059e",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": false,
"url": "https://smthomeav.aux-home.com/app/login_sms_code",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"headers": {},
"x": 300,
"y": 140,
"wires": [
[
"7c9c0f01.15c28c"
]
]
},
{
"id": "7c9c0f01.15c28c",
"type": "debug",
"z": "2797f4c1.8b059e",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 480,
"y": 140,
"wires": []
},
{
"id": "f0e75b33.8d0798",
"type": "inject",
"z": "2797f4c1.8b059e",
"name": "登录",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{"phone":"13xxxxx","code":"xxxx"}",
"payloadType": "json",
"x": 110,
"y": 200,
"wires": [
[
"6c978c13.16c99c"
]
]
},
{
"id": "6c978c13.16c99c",
"type": "http request",
"z": "2797f4c1.8b059e",
"name": "",
"method": "POST",
"ret": "json",
"paytoqs": false,
"url": "https://smthomeav.aux-home.com/app/wechatMini/loginBySms",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"headers": {},
"x": 300,
"y": 200,
"wires": [
[
"a58d9725.5c102"
]
]
},
{
"id": "a58d9725.5c102",
"type": "function",
"z": "2797f4c1.8b059e",
"name": "提取并存储token",
"func": "global.set("aux_token", msg.payload.openApiToken.token);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 480,
"y": 200,
"wires": [
[
"d1b4a72d.75529"
]
]
},
{
"id": "d1b4a72d.75529",
"type": "debug",
"z": "2797f4c1.8b059e",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 650,
"y": 200,
"wires": []
},
{
"id": "d806b960.10c92",
"type": "inject",
"z": "2797f4c1.8b059e",
"name": "获取设备列表",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 110,
"y": 260,
"wires": [
[
"c0700d94.9b2768"
]
]
},
{
"id": "c0700d94.9b2768",
"type": "http request",
"z": "2797f4c1.8b059e",
"name": "",
"method": "GET",
"ret": "json",
"paytoqs": false,
"url": "https://smthomeav.aux-home.com/app/device_bindings?getStatus=true",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"headers": {
"Authorization": "{{global.aux_token}}"
},
"x": 300,
"y": 260,
"wires": [
[
"e9d7c00d.7c4918"
]
]
},
{
"id": "e9d7c00d.7c4918",
"type": "debug",
"z": "2797f4c1.8b059e",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 480,
"y": 260,
"wires": []
},
{
"id": "a59c9b99.99962",
"type": "inject",
"z": "2797f4c1.8b059e",
"name": "控制设备",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 110,
"y": 320,
"wires": [
[
"b37c9d02.990988"
]
]
},
{
"id": "b37c9d02.990988",
"type": "function",
"z": "2797f4c1.8b059e",
"name": "构建控制请求",
"func": "let did = "d500010001e816566b4b98";\nlet pk = "00010001";\nlet action = {"temperature":295};\nmsg.payload = {\n "did": did,\n "uart": "bb00068000010f000101af2080a0002000002000000000de9b",\n "pk": pk,\n "action": action\n};\nmsg.headers = {\n "Authorization": global.get("aux_token")\n};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 300,
"y": 320,
"wires": [
[
"c17c9e14.99311"
]
]
},
{
"id": "c17c9e14.99311",
"type": "http request",
"z": "2797f4c1.8b059e",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": false,
"url": "https://smthomeav.aux-home.com/app/wechatMini/new_device_control",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"headers": {},
"x": 480,
"y": 320,
"wires": [
[
"7c9c0f01.15c28c1"
]
]
},
{
"id": "7c9c0f01.15c28c1",
"type": "debug",
"z": "2797f4c1.8b059e",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 650,
"y": 320,
"wires": []
}
]
```
**导入流程**:
- 在 Node - RED 界面中,点击菜单中的 `Import` -> `Clipboard`。
- 将上述 JSON 代码粘贴到弹出的对话框中,然后点击 `Import` 按钮,即可导入该流程。
请记住,在实际使用中要根据你的奥克斯账号和设备信息正确配置手机号、验证码、设备 `did` 和 `pk` 等参数,以确保流程能够正常运行。