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

 找回密码
 立即注册
查看: 2957|回复: 8

[流程系列] NodeRed + Surveillance Station Web API + goCQhttp 监控动检自动推送图...

[复制链接]

7

主题

70

帖子

410

积分

中级会员

Rank: 3Rank: 3

积分
410
金钱
340
HASS币
0
发表于 2023-5-26 21:37:50 | 显示全部楼层 |阅读模式
本帖最后由 s1711880582 于 2023-5-26 21:45 编辑

实现的功能,Surveillance动检之后,通过webHook发送信息给NodeRed,NodeRed调用Surveillance API截图 并将截图发送给QQ


先上干货 NodeRed流程图

NodeRed.png
NodeRed导出的流程图 需要修改才能使用
[
    {
        "id": "674356d4acd058ab",
        "type": "ha-webhook",
        "z": "4f2e767432fb3000",
        "name": "出租屋动检",
        "server": "e71b8837bc864386",
        "version": 1,
        "outputs": 1,
        "webhookId": "PCH3rdMNIzaGDsTNZMmjOXfWDqTP2Rgk",
        "outputProperties": [
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            },
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "data"
            }
        ],
        "payloadLocation": false,
        "payloadLocationType": false,
        "headersLocation": false,
        "headersLocationType": false,
        "x": 270,
        "y": 280,
        "wires": [
            [
                "c69f8e01de570c8b"
            ]
        ]
    },
    {
        "id": "c69f8e01de570c8b",
        "type": "debug",
        "z": "4f2e767432fb3000",
        "name": "接收到Sur动检告警",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 470,
        "y": 300,
        "wires": []
    },
    {
        "id": "912e6cf4155468e0",
        "type": "www-request",
        "z": "4f2e767432fb3000",
        "name": "登录取sid",
        "method": "GET",
        "ret": "obj",
        "url": "http://192.168.1.68:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=6&account=修改此处为你的用户名&passwd=修改此处为你的密码&session=SurveillanceStation&format=sid",
        "follow-redirects": true,
        "persistent-http": true,
        "tls": "",
        "x": 440,
        "y": 400,
        "wires": [
            [
                "2dc4e10728414abc"
            ]
        ]
    },
    {
        "id": "2dc4e10728414abc",
        "type": "function",
        "z": "4f2e767432fb3000",
        "name": "url_snapshot",
        "func": "var sid;\nsid = msg.payload.data.sid;\nmsg.url = 'http://192.168.1.68:5000/webapi/entry.cgi?version=9&id=32&api=%22SYNO.SurveillanceStation.Camera%22&method=%22GetSnapshot%22&profileType=0&_sid='+sid;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 400,
        "wires": [
            [
                "4c1546eccfaec3e8"
            ]
        ]
    },
    {
        "id": "4c1546eccfaec3e8",
        "type": "www-request",
        "z": "4f2e767432fb3000",
        "name": "得到实时截图",
        "method": "GET",
        "ret": "bin",
        "url": "",
        "follow-redirects": true,
        "persistent-http": true,
        "tls": "",
        "x": 800,
        "y": 400,
        "wires": [
            [
                "cc63aae2755c199f",
                "c649e6c9e9afd69f"
            ]
        ]
    },
    {
        "id": "cc63aae2755c199f",
        "type": "image viewer",
        "z": "4f2e767432fb3000",
        "name": "",
        "width": 160,
        "data": "payload",
        "dataType": "msg",
        "active": false,
        "x": 710,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "ef1b1457f984d90c",
        "type": "inject",
        "z": "4f2e767432fb3000",
        "name": "手动测试",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 280,
        "y": 440,
        "wires": [
            [
                "c69f8e01de570c8b",
                "912e6cf4155468e0"
            ]
        ]
    },
    {
        "id": "9e23495c29e8f18d",
        "type": "jimp-image",
        "z": "4f2e767432fb3000",
        "name": "将图片保存",
        "data": "payload",
        "dataType": "msg",
        "ret": "img",
        "parameter1": "/data/CuZuWu_tmp.jpg",
        "parameter1Type": "str",
        "parameter2": "",
        "parameter2Type": "msg",
        "parameter3": "",
        "parameter3Type": "msg",
        "parameter4": "",
        "parameter4Type": "msg",
        "parameter5": "",
        "parameter5Type": "msg",
        "parameter6": "",
        "parameter6Type": "msg",
        "parameter7": "",
        "parameter7Type": "msg",
        "parameter8": "",
        "parameter8Type": "msg",
        "sendProperty": "payload",
        "sendPropertyType": "msg",
        "parameterCount": 1,
        "jimpFunction": "write",
        "selectedJimpFunction": {
            "name": "write",
            "fn": "write",
            "description": "Write to file. NOTE: You can specify an alternative file extension type to change the type. Currently support types are jpg, png, bmp.",
            "parameters": [
                {
                    "name": "filename",
                    "type": "str",
                    "required": true,
                    "hint": "Name of the file",
                    "defaultType": "str"
                }
            ]
        },
        "x": 590,
        "y": 500,
        "wires": [
            [
                "7bb3e8cd21882f08"
            ]
        ]
    },
    {
        "id": "c649e6c9e9afd69f",
        "type": "base64",
        "z": "4f2e767432fb3000",
        "name": "",
        "action": "",
        "property": "payload",
        "x": 440,
        "y": 500,
        "wires": [
            [
                "9e23495c29e8f18d"
            ]
        ]
    },
    {
        "id": "7bb3e8cd21882f08",
        "type": "http request",
        "z": "4f2e767432fb3000",
        "name": "发送消息给QQ",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://修改此处为你的CQ IP地址:5700/send_private_msg?user_id=修改此处为你的QQ号&message=[CQ:image,file=file:///volume1/docker/NodeRED/CuZuWu_tmp.jpg]",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 800,
        "y": 500,
        "wires": [
            []
        ]
    },
    {
        "id": "e71b8837bc864386",
        "type": "server",
        "name": "群晖",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": false,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    }
]



测试接口.png

Surveillance_Station_Web_API.pdf

2.34 MB, 下载次数: 23

售价: 1 金钱  [记录]

官方API文档

评分

参与人数 2金钱 +20 收起 理由
aiqienanguatou + 10 高手,这是高手!
隔壁的王叔叔 + 10 论坛有你更精彩!

查看全部评分

回复

使用道具 举报

7

主题

70

帖子

410

积分

中级会员

Rank: 3Rank: 3

积分
410
金钱
340
HASS币
0
 楼主| 发表于 2023-5-26 21:42:56 | 显示全部楼层
参考的帖子:
https://docs.go-cqhttp.org/cqcode/#%E5%9B%BE%E7%89%87

参考的文件:
Surveillance_Station_Web_API.pdf (2.34 MB, 下载次数: 7, 售价: 1 金钱)

写的API测试文件,使用ApiFox导入查看,或者其他的什么
群晖SurveillanceStationAPI.openapi.rar (38.74 KB, 下载次数: 9, 售价: 1 金钱)


回复

使用道具 举报

26

主题

304

帖子

1670

积分

金牌会员

Rank: 6Rank: 6

积分
1670
金钱
1366
HASS币
0
发表于 2023-5-27 11:53:02 | 显示全部楼层
收藏了,有待折腾
回复

使用道具 举报

3

主题

121

帖子

1601

积分

金牌会员

Rank: 6Rank: 6

积分
1601
金钱
1480
HASS币
0
发表于 2023-5-27 13:02:19 | 显示全部楼层
5000/webapi/entry.cgi?version=9&id=32&api=%22SYNO.SurveillanceStation.Camera%22&method=%22GetSnapshot%22&profileType=0&_sid='+sid;

请问这个链接除了改IP,还要改哪些位置?我截图不成功。麻烦告诉一下
回复

使用道具 举报

8

主题

871

帖子

5224

积分

论坛元老

Rank: 8Rank: 8

积分
5224
金钱
4353
HASS币
0
发表于 2023-5-28 00:08:14 | 显示全部楼层
学习学习,谢谢分享,赞
回复

使用道具 举报

7

主题

70

帖子

410

积分

中级会员

Rank: 3Rank: 3

积分
410
金钱
340
HASS币
0
 楼主| 发表于 2023-5-29 13:17:20 | 显示全部楼层
jole 发表于 2023-5-27 13:02
5000/webapi/entry.cgi?version=9&id=32&api=%22SYNO.SurveillanceStation.Camera%22&method=%22GetSnapsho ...

id=32,这里的ID是摄像机ID  在摄像机文件存储目录的设置文件有ID
回复

使用道具 举报

3

主题

121

帖子

1601

积分

金牌会员

Rank: 6Rank: 6

积分
1601
金钱
1480
HASS币
0
发表于 2023-5-29 21:54:10 | 显示全部楼层
s1711880582 发表于 2023-5-29 13:17
id=32,这里的ID是摄像机ID  在摄像机文件存储目录的设置文件有ID

谢谢,后来截图抓包找到id了,有些摄像头电脑浏览器播放不了好像也不能截图。
回复

使用道具 举报

16

主题

382

帖子

2650

积分

金牌会员

Rank: 6Rank: 6

积分
2650
金钱
2268
HASS币
10
发表于 2023-6-3 20:59:28 | 显示全部楼层
大佬,这几个值能弄么小白不是很明白怎么获得mp4事件
QQ截图20230603205712.png
QQ截图20230603205757.png

回复

使用道具 举报

0

主题

58

帖子

269

积分

中级会员

Rank: 3Rank: 3

积分
269
金钱
211
HASS币
0
发表于 2023-12-5 20:55:52 | 显示全部楼层
大佬取sid出现错误code 407 ,一直取不到sid,这个是怎么回事?
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-22 12:12 , Processed in 0.128344 second(s), 35 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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