找回密码
 立即注册
查看: 73|回复: 2

[求助] 群晖摄像头推送图片到企业微信,上传临时素材报错404

[复制链接]

2

主题

54

回帖

203

积分

中级会员

积分
203
金钱
147
HASS币
0
发表于 2025-3-27 17:17:05 | 显示全部楼层 |阅读模式
导出json如下,我是抄的网上的作业,大致逻辑流程是,群晖摄像头获取sid—获取截图——上传临时素材——高级推送
在上传临时素材那里,我查AI提示需要把二进制流转换为Base64 字符串,因此使用了function函数——msg.imageBase64 = msg.payload.toString('base64');
折腾好多天了,求大佬指导下。企业微信代理应该是可行的,用的node-red-contrib-bizwechat,传输文本消息成功的,所以我认为是传输数据格式问题,导致了404报错的情况


[
    {
        "id": "a07703f3752fc82a",
        "type": "tab",
        "label": "抓取群晖摄像头推送到企业微信",
        "disabled": false,
        "info": ""
    },
    {
        "id": "3902801a557a738e",
        "type": "www-request",
        "z": "a07703f3752fc82a",
        "name": "获取sid",
        "method": "GET",
        "ret": "obj",
        "url": "",
        "follow-redirects": true,
        "persistent-http": true,
        "tls": "",
        "x": 780,
        "y": 320,
        "wires": [
            [
                "cabd07b9c918bd13"
            ]
        ],
        "inputLabels": [
            "输入"
        ],
        "outputLabels": [
            "输出"
        ]
    },
    {
        "id": "6e7a90e85b1d736b",
        "type": "change",
        "z": "a07703f3752fc82a",
        "name": "设置群辉用户名、密码、摄像头ID",
        "rules": [
            {
                "t": "set",
                "p": "dsm_account",
                "pt": "msg",
                "to": "username",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "dsm_passwd",
                "pt": "msg",
                "to": "pasword",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "dsm_camera_id",
                "pt": "msg",
                "to": "2",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "dsm_domain",
                "pt": "msg",
                "to": "192.168.0.117",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "dsm_port",
                "pt": "msg",
                "to": "5000",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 440,
        "y": 240,
        "wires": [
            [
                "c18d4fe0633037a4"
            ]
        ]
    },
    {
        "id": "833f9be33b550d84",
        "type": "www-request",
        "z": "a07703f3752fc82a",
        "name": "GetSnapshot",
        "method": "GET",
        "ret": "bin",
        "url": "",
        "follow-redirects": true,
        "persistent-http": true,
        "tls": "",
        "x": 850,
        "y": 460,
        "wires": [
            [
                "45ea4313512d68a6",
                "cbedd98e2bd48552"
            ]
        ]
    },
    {
        "id": "c18d4fe0633037a4",
        "type": "function",
        "z": "a07703f3752fc82a",
        "name": "url_sid",
        "func": "msg.url = `http://${msg.dsm_domain}{msg.dsm_port}/webapi/auth.cgi?api=SYNO.API.Auth&method=login&version=3&account=${msg.dsm_account}&passwd=${msg.dsm_passwd}&session=SurveillanceStation&&format=cookie`;\nconsole.log(msg)\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 670,
        "y": 240,
        "wires": [
            [
                "3902801a557a738e"
            ]
        ]
    },
    {
        "id": "f3df28b20f02dd3e",
        "type": "function",
        "z": "a07703f3752fc82a",
        "name": "url_snapshot",
        "func": "var sid;\nsid = msg.payload.data.sid;\nmsg.url = `http://${msg.dsm_domain}{msg.dsm_port}/webapi/entry.cgi?version=9&id=${msg.dsm_camera_id}&api=\"SYNO.SurveillanceStation.Camera\"&method=\"GetSnapshot\"&profileType=0&_sid=${sid}`;\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 650,
        "y": 460,
        "wires": [
            [
                "833f9be33b550d84"
            ]
        ]
    },
    {
        "id": "cabd07b9c918bd13",
        "type": "switch",
        "z": "a07703f3752fc82a",
        "name": "",
        "property": "payload.error.code",
        "propertyType": "msg",
        "rules": [
            {
                "t": "nnull"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 630,
        "y": 380,
        "wires": [
            [
                "3902801a557a738e"
            ],
            [
                "f3df28b20f02dd3e"
            ]
        ],
        "inputLabels": [
            "输入"
        ]
    },
    {
        "id": "dcb9b48e6b3c1fee",
        "type": "inject",
        "z": "a07703f3752fc82a",
        "name": "手动触发",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 180,
        "wires": [
            [
                "6e7a90e85b1d736b"
            ]
        ]
    },
    {
        "id": "45ea4313512d68a6",
        "type": "image",
        "z": "a07703f3752fc82a",
        "name": "",
        "width": "360",
        "data": "payload",
        "dataType": "msg",
        "thumbnail": false,
        "active": true,
        "pass": false,
        "outputs": 0,
        "x": 1080,
        "y": 140,
        "wires": []
    },
    {
        "id": "02fe4781ca3fbb7b",
        "type": "http in",
        "z": "a07703f3752fc82a",
        "name": "/camera",
        "url": "/camera",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 180,
        "y": 340,
        "wires": [
            [
                "6e7a90e85b1d736b",
                "fb5663502a675986"
            ]
        ]
    },
    {
        "id": "fb5663502a675986",
        "type": "http response",
        "z": "a07703f3752fc82a",
        "name": "",
        "statusCode": "200",
        "headers": {
            "code": "0"
        },
        "x": 600,
        "y": 680,
        "wires": []
    },
    {
        "id": "8cc0f81167333cb2",
        "type": "function",
        "z": "a07703f3752fc82a",
        "name": "",
        "func": "var media_id = msg.payload.media_id;\nvar cam = msg.cam\nmsg = {};\nvar info = '';\nif(cam == 1){\n    info = '正门侦测到运动';\n}else if(cam == 2){\n    info = '后门侦测到运动';\n}else{\n    info = '侦测到运动';\n}\nmsg.payload = {\n  \"msgtype\": \"mpnews\",//消息类型\n  \"touser\": \"@all\",\n  \"agentid\": 1000003,//这里填你自建应用的AgentId\n  \"mpnews\": {\n    \"articles\": [{\n      \"title\": \"Surveillance 通知\",\n      \"thumb_media_id\": media_id,\n      \"content\": \"无正文\",\n      \"digest\": info\n    }]\n  }\n}\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 890,
        "y": 720,
        "wires": [
            [
                "412f92b38684129f"
            ]
        ]
    },
    {
        "id": "412f92b38684129f",
        "type": "bizwechat-push",
        "z": "a07703f3752fc82a",
        "name": "",
        "bizwechat": "76b3014e8447e9a4",
        "x": 1120,
        "y": 700,
        "wires": [
            []
        ]
    },
    {
        "id": "26508d2d4d929786",
        "type": "bizwechat-input",
        "z": "a07703f3752fc82a",
        "name": "",
        "bizwechat": "76b3014e8447e9a4",
        "x": 190,
        "y": 560,
        "wires": [
            []
        ]
    },
    {
        "id": "71c88f5efe465b47",
        "type": "bizwechat-upload",
        "z": "a07703f3752fc82a",
        "name": "",
        "bizwechat": "76b3014e8447e9a4",
        "x": 880,
        "y": 640,
        "wires": [
            [
                "8cc0f81167333cb2"
            ]
        ]
    },
    {
        "id": "cbedd98e2bd48552",
        "type": "function",
        "z": "a07703f3752fc82a",
        "name": "function 1",
        "func": "msg.imageBase64 = msg.payload.toString('base64'); \nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 880,
        "y": 560,
        "wires": [
            [
                "71c88f5efe465b47",
                "3fc7b2738d1b6b55"
            ]
        ]
    },
    {
        "id": "3fc7b2738d1b6b55",
        "type": "debug",
        "z": "a07703f3752fc82a",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1110,
        "y": 540,
        "wires": [],
        "info": "msg.fileInfo = {\r\n    path: msg.filePath,\r\n    exists: fs.existsSync(msg.filePath),\r\n    size: fs.statSync(msg.filePath).size\r\n};\r\nreturn msg;"
    },
    {
        "id": "76b3014e8447e9a4",
        "type": "bizwechat-configurator",
        "name": "企业微信",
        "port": "3001",
        "corpid": " ",
        "agentid": " ",
        "corpsecret": " ",
        "url": "",
        "token": "",
        "aeskey": "",
        "proxyWx": " ",
        "client_id": " ",
        "client_secret": " ",
        "stt": ""
    }
]

流程图

流程图
回复

使用道具 举报

1

主题

39

回帖

537

积分

高级会员

积分
537
金钱
497
HASS币
0
发表于 2025-3-31 21:09:01 | 显示全部楼层
base64有一个专门的节点,在getsnapshot后面连上base64,在后面接上change节点,把msg.img设定为msg.payload。你试试
回复

使用道具 举报

2

主题

54

回帖

203

积分

中级会员

积分
203
金钱
147
HASS币
0
 楼主| 发表于 2025-3-31 21:16:32 | 显示全部楼层
chenchun022 发表于 2025-3-31 21:09
base64有一个专门的节点,在getsnapshot后面连上base64,在后面接上change节点,把msg.img设定为msg.payloa ...

谢谢了,不是这个问题,解决了
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2025-5-1 06:36 , Processed in 0.112292 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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