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

 找回密码
 立即注册
查看: 15338|回复: 10

[教程系列] 海康C6CN-MQTT控制,自动更新accessToken

[复制链接]

1

主题

5

帖子

49

积分

新手上路

Rank: 1

积分
49
金钱
44
HASS币
0
发表于 2020-11-17 01:52:24 | 显示全部楼层 |阅读模式
本帖最后由 pigareyou 于 2020-11-17 20:44 编辑

新手第一帖,咸鱼入手萤石C6CN摄像头,根据@dodojie教程接入,因为accessToken7天过时,所以修改为自动更新,永不过时。
删除了预置位相关,C6CN不支持该功能~~

设备配置及报警功能正在尝试对接微信,有结果了再来。加油
微信推送由bizwetchat实现,IOB上有很详细的教程,简单的关键字触发抓图、报警等功能,含“截图”、“报警”即可,祖安话什么的不要在意。


附推送部分json
[
    {
        "id": "12d2257c.231dab",
        "type": "json",
        "z": "b7e92987.caed38",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 810,
        "y": 260,
        "wires": [
            [
                "978def59.ad1ea"
            ]
        ]
    },
    {
        "id": "29fd81f5.642cae",
        "type": "http request",
        "z": "b7e92987.caed38",
        "name": "获取报警列表",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://open.ys7.com/api/lapp/alarm/list",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 640,
        "y": 260,
        "wires": [
            [
                "12d2257c.231dab"
            ]
        ]
    },
    {
        "id": "978def59.ad1ea",
        "type": "function",
        "z": "b7e92987.caed38",
        "name": "获取最新报警图片地址",
        "func": "var newMsg = {\n    "url": msg.payload.data[0].alarmPicUrl,\n    "user": msg.user\n}\n\nreturn newMsg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1000,
        "y": 260,
        "wires": [
            [
                "78bbabf6.14edd4"
            ]
        ]
    },
    {
        "id": "3f33a303.47f1bc",
        "type": "json",
        "z": "b7e92987.caed38",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 810,
        "y": 360,
        "wires": [
            [
                "b4bd3814.4d1f38"
            ]
        ]
    },
    {
        "id": "818e2a52.ded688",
        "type": "http request",
        "z": "b7e92987.caed38",
        "name": "抓图",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://open.ys7.com/api/lapp/device/capture",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 610,
        "y": 360,
        "wires": [
            [
                "3f33a303.47f1bc"
            ]
        ]
    },
    {
        "id": "b4bd3814.4d1f38",
        "type": "function",
        "z": "b7e92987.caed38",
        "name": "获取图片地址",
        "func": "var newMsg = {\n    "url": msg.payload.data.picUrl,\n    "user": msg.user\n}\n\nreturn newMsg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 980,
        "y": 360,
        "wires": [
            [
                "97cf1f0d.ce723"
            ]
        ]
    },
    {
        "id": "a5c10f22.3e4e9",
        "type": "bizwechat-push",
        "z": "b7e92987.caed38",
        "name": "",
        "bizwechat": "aa873cc1.e2df2",
        "x": 1380,
        "y": 300,
        "wires": [
            []
        ]
    },
    {
        "id": "97cf1f0d.ce723",
        "type": "function",
        "z": "b7e92987.caed38",
        "name": "推送图片",
        "func": "var newMsg = {\n    "payload": {\n        "touser": msg.user,\n        "msgtype": "news",\n        "news": {\n            "articles":[\n               {\n                   "title": "抓图", \n                   "description": "实时抓图照片",\n                   "url": msg.url,\n                   "picurl": msg.url\n                }\n            ]    \n        }\n    }\n}\n\nreturn newMsg;\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1200,
        "y": 360,
        "wires": [
            [
                "a5c10f22.3e4e9"
            ]
        ]
    },
    {
        "id": "35224e0f.236bb2",
        "type": "bizwechat-input",
        "z": "b7e92987.caed38",
        "name": "微信应用",
        "bizwechat": "aa873cc1.e2df2",
        "x": 80,
        "y": 300,
        "wires": [
            [
                "d564e397.42614"
            ]
        ]
    },
    {
        "id": "78bbabf6.14edd4",
        "type": "function",
        "z": "b7e92987.caed38",
        "name": "推送图片",
        "func": "var newMsg = {\n    "payload": {\n        "touser": msg.user,\n        "msgtype": "news",\n        "news": {\n            "articles":[\n               {\n                   "title": "最新报警", \n                   "description": "报警照片",\n                   "url": msg.url,\n                   "picurl": msg.url\n                }\n            ]    \n        }\n    }\n}\n\nreturn newMsg;\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1200,
        "y": 260,
        "wires": [
            [
                "a5c10f22.3e4e9"
            ]
        ]
    },
    {
        "id": "d564e397.42614",
        "type": "file in",
        "z": "b7e92987.caed38",
        "name": "读取accessToken",
        "filename": "acctoken",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "encoding": "utf8",
        "x": 270,
        "y": 300,
        "wires": [
            [
                "7be6af49.51fd7"
            ]
        ]
    },
    {
        "id": "7be6af49.51fd7",
        "type": "function",
        "z": "b7e92987.caed38",
        "name": "命令解析",
        "func": "var newMsg = {\n    "headers": {\n        "Content-Type" : "application/x-www-form-urlencoded"\n    },\n    "payload": "",\n    "user": msg.message.FromUserName\n}\n\nnewMsg.payload = {\n    "accessToken" : msg.payload,\n    "deviceSerial" : "自行修改",\n    "channelNo" : 1\n}\n\nvar cmd = msg.message.Content;\nif(cmd.indexOf("截图") != -1)\n{\n    return [null, newMsg]\n}\nif(cmd.indexOf("报警") != -1)\n{\n    return [newMsg, null]\n}",
        "outputs": 2,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 460,
        "y": 300,
        "wires": [
            [
                "29fd81f5.642cae"
            ],
            [
                "818e2a52.ded688"
            ]
        ]
    },
    {
        "id": "aa873cc1.e2df2",
        "type": "bizwechat-configurator",
        "z": "",
        "name": "home",
        "port": "1881",
        "corpid": "xxx",
        "agentid": "xxx",
        "corpsecret": "xxx-5w",
        "url": "http://1.2.3.4:55084/",
        "token": "123",
        "aeskey": "123",
        "client_id": "",
        "client_secret": ""
    }
] 




Screenshot_20201117_204259.png
1605616357128.jpg

C6CN.zip

1.72 KB, 下载次数: 77

回复

使用道具 举报

1

主题

5

帖子

49

积分

新手上路

Rank: 1

积分
49
金钱
44
HASS币
0
 楼主| 发表于 2020-11-17 01:54:07 | 显示全部楼层
不会上传图片。。。


                               
登录/注册后可看大图


22.png
回复

使用道具 举报

2

主题

431

帖子

2639

积分

金牌会员

Rank: 6Rank: 6

积分
2639
金钱
2208
HASS币
0
QQ
发表于 2020-11-17 10:35:27 | 显示全部楼层
厉害了 我的哥
回复

使用道具 举报

8

主题

318

帖子

2172

积分

论坛技术达人

积分
2172
金钱
1844
HASS币
70
发表于 2020-11-18 08:55:20 | 显示全部楼层
厉害!!感谢楼主分享!!
回复

使用道具 举报

2

主题

94

帖子

1341

积分

金牌会员

Rank: 6Rank: 6

积分
1341
金钱
1247
HASS币
0
发表于 2021-1-6 14:58:31 | 显示全部楼层
厉害!感谢分享!
回复

使用道具 举报

0

主题

7

帖子

70

积分

注册会员

Rank: 2

积分
70
金钱
63
HASS币
0
发表于 2021-1-8 11:18:28 | 显示全部楼层
厉害了!最好给开个讲座讲讲,新手看不懂。。。。
回复

使用道具 举报

6

主题

257

帖子

1453

积分

金牌会员

Rank: 6Rank: 6

积分
1453
金钱
1196
HASS币
0
发表于 2021-1-28 19:16:09 | 显示全部楼层
正好需要接入  学习一下
回复

使用道具 举报

16

主题

331

帖子

2408

积分

金牌会员

Rank: 6Rank: 6

积分
2408
金钱
2077
HASS币
0
发表于 2021-6-27 14:36:21 | 显示全部楼层
能不能把遮蔽和自动巡防也加入啊?
回复

使用道具 举报

16

主题

331

帖子

2408

积分

金牌会员

Rank: 6Rank: 6

积分
2408
金钱
2077
HASS币
0
发表于 2021-6-28 13:08:04 来自手机 | 显示全部楼层
大佬关心一下呗
回复

使用道具 举报

16

主题

331

帖子

2408

积分

金牌会员

Rank: 6Rank: 6

积分
2408
金钱
2077
HASS币
0
发表于 2021-6-28 13:27:49 来自手机 | 显示全部楼层
大佬关心一下呗
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-21 22:11 , Processed in 0.255819 second(s), 35 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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