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

 找回密码
 立即注册
楼主: 恐别倾城

[教程系列] 智能门锁-优智云家连接ha

  [复制链接]

17

主题

187

帖子

1781

积分

金牌会员

Rank: 6Rank: 6

积分
1781
金钱
1594
HASS币
0
发表于 2024-2-23 12:19:06 | 显示全部楼层
yx262514 发表于 2024-2-23 09:28
我试过了,我获取到的消息都是did,没有具体的人的id

你实时情况这个节点的状态是不是已连接,这样开锁后会得到如下一条信息,箭头所指的就是用户ID,红框是你争对该ID设置的名称,有了这个不是可以争对不同的人设置自动化了么?
微信截图_20240223121513.png



回复

使用道具 举报

0

主题

34

帖子

150

积分

注册会员

Rank: 2

积分
150
金钱
116
HASS币
0
发表于 2024-2-23 14:00:38 | 显示全部楼层
csl0524 发表于 2024-2-22 16:22
你的问题信息太少无法具体回答,开锁需要配置如下开锁信息:

再向https://h5.kiwik.cn/restapi/users/XX ...

方便分享一下你整个flow文件吗?因为我是用的楼主的flow已连接成功,你的方法可能和他略有差异,我对照研究学习下。若方便的话麻烦发一下,感谢感谢!
   TRANSLATE with  x
    English

  
      
   

  TRANSLATE with
    COPY THE URL BELOW  
    [url=][/url]
  [url=][/url] Back
   
   EMBED THE SNIPPET BELOW IN YOUR SITE [url=][/url]
   
Enable collaborative features and customize widget: Bing Webmaster Portal
Back

  

回复

使用道具 举报

0

主题

34

帖子

150

积分

注册会员

Rank: 2

积分
150
金钱
116
HASS币
0
发表于 2024-2-23 14:02:13 | 显示全部楼层
tianya2002 发表于 2024-2-2 20:43
已成功接入,感谢大佬分享!

你实现门铃-远程开锁的功能了吗?
回复

使用道具 举报

6

主题

98

帖子

610

积分

高级会员

Rank: 4

积分
610
金钱
512
HASS币
0
发表于 2024-2-23 15:22:22 | 显示全部楼层
csl0524 发表于 2024-2-23 12:19
你实时情况这个节点的状态是不是已连接,这样开锁后会得到如下一条信息,箭头所指的就是用户ID,红框是你 ...

获取到的是这种
下载.png
回复

使用道具 举报

0

主题

34

帖子

150

积分

注册会员

Rank: 2

积分
150
金钱
116
HASS币
0
发表于 2024-2-23 20:56:49 | 显示全部楼层

兄弟 你实现门铃-远程开锁了吗
回复

使用道具 举报

17

主题

187

帖子

1781

积分

金牌会员

Rank: 6Rank: 6

积分
1781
金钱
1594
HASS币
0
发表于 2024-2-23 21:38:27 | 显示全部楼层
a5234338 发表于 2024-2-23 14:00
方便分享一下你整个flow文件吗?因为我是用的楼主的flow已连接成功,你的方法可能和他略有差异,我对照研 ...
[
    {
        "id": "bf211734494823b3",
        "type": "link out",
        "z": "ee8f68611c51951f",
        "name": "link out 2",
        "mode": "link",
        "links": [
            "1cb87640132f0b42",
            "89c4097ee41fd798"
        ],
        "x": 955,
        "y": 140,
        "wires": []
    },
    {
        "id": "2e9960d3586b145f",
        "type": "function",
        "z": "ee8f68611c51951f",
        "name": "开锁参数",
        "func": "var open_token = msg.payload.access_token\nmsg.payload = { \n    "header": { \n        "namespace": "Iot.Device", \n        "name": "Ctrl", \n        "messageId": generateUUID(), \n        "payloadVersion": 1, \n        "secureToken": open_token \n        }, \n    "payload": { \n        "did": "XXXXXXXX", \n        "verify": "true", \n        "data": "XXXXXXXXXXXXXXX" \n        } \n        }\n\nfunction generateUUID() {\n    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n        var r = Math.random() * 16 | 0,\n            v = c === 'x' ? r : (r & 0x3 | 0x8);\n        return v.toString(16);\n    });\n}\nmsg.custom = true; //必不可少\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 800,
        "y": 140,
        "wires": [
            [
                "bf211734494823b3"
            ]
        ]
    },
    {
        "id": "8912748fee7415aa",
        "type": "http request",
        "z": "ee8f68611c51951f",
        "name": "获取开锁 Token",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://h5.kiwik.cn/restapi/users/XXXXXXX/mfa/tokens",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 620,
        "y": 140,
        "wires": [
            [
                "2e9960d3586b145f"
            ]
        ]
    },
    {
        "id": "01f15ff965a699c7",
        "type": "function",
        "z": "ee8f68611c51951f",
        "name": "开锁信息",
        "func": "msg.headers = { \n    "Content-Type": "application/json", \n    "X-Kiwik-Client-Id": "XXXXXXXXXX" \n    };\nmsg.payload = { \n    "auth_type": "secure_password", \n    "credential": "XXXXXX" \n    };\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 140,
        "wires": [
            [
                "8912748fee7415aa"
            ]
        ]
    },
    {
        "id": "8b649ee0eb541afc",
        "type": "inject",
        "z": "ee8f68611c51951f",
        "name": "开锁",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "5",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 190,
        "y": 100,
        "wires": [
            [
                "01f15ff965a699c7"
            ]
        ]
    },
    {
        "id": "879aa44438ba4c48",
        "type": "change",
        "z": "ee8f68611c51951f",
        "name": "设置全局变量",
        "rules": [
            {
                "t": "move",
                "p": "payload.access_token",
                "pt": "msg",
                "to": "token",
                "tot": "global"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 760,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "b5235468c69cfca9",
        "type": "function",
        "z": "ee8f68611c51951f",
        "name": "处理参数",
        "func": "\n\nmsg.url = "wss://wsapi.kiwiot.com/"\nmsg.token = msg.payload.access_token;\nmsg.pingMsg = {\n  "header": {\n    "namespace": "Iot.Application",\n    "name": "Ping",\n    "messageId": generateUUID(),\n    "payloadVersion": 1\n  }\n};\nmsg.interval = 30000;\n\nfunction generateUUID() {\n    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n        var r = Math.random() * 16 | 0,\n            v = c === 'x' ? r : (r & 0x3 | 0x8);\n        return v.toString(16);\n    });\n}\n\n\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 760,
        "y": 260,
        "wires": [
            [
                "306695d96b0d062e"
            ]
        ]
    },
    {
        "id": "80f5d4d360317b3f",
        "type": "switch",
        "z": "ee8f68611c51951f",
        "name": "是否登录",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "hask",
                "v": "access_token",
                "vt": "str"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 600,
        "y": 260,
        "wires": [
            [
                "b5235468c69cfca9",
                "879aa44438ba4c48"
            ],
            [
                "0d49a323af311317"
            ]
        ]
    },
    {
        "id": "d8ed0625f1743ae4",
        "type": "http request",
        "z": "ee8f68611c51951f",
        "name": "登录",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://h5.kiwik.cn/restapi/auth/tokens",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "other",
                "keyValue": "x-kiwik-client-id",
                "valueType": "other",
                "valueValue": "XXXXXXXXXXXXXXX"
            }
        ],
        "x": 470,
        "y": 260,
        "wires": [
            [
                "80f5d4d360317b3f"
            ]
        ]
    },
    {
        "id": "364baedc8d1c34b8",
        "type": "function",
        "z": "ee8f68611c51951f",
        "name": "登陆信息",
        "func": "\nmsg.payload = {\n    "identifier": "+XXXXXXXX",\n    "credential": "XXXXXXXX",\n    "auth_type": "password"\n};\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 320,
        "y": 260,
        "wires": [
            [
                "d8ed0625f1743ae4"
            ]
        ]
    },
    {
        "id": "7f8fb26508d9b8a5",
        "type": "inject",
        "z": "ee8f68611c51951f",
        "name": "登录",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "18000",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 170,
        "y": 260,
        "wires": [
            [
                "364baedc8d1c34b8"
            ]
        ]
    },
    {
        "id": "0d49a323af311317",
        "type": "debug",
        "z": "ee8f68611c51951f",
        "name": "登录失败",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 320,
        "wires": []
    },
    {
        "id": "306695d96b0d062e",
        "type": "live",
        "z": "ee8f68611c51951f",
        "name": "",
        "url": "",
        "token": "",
        "ping": "",
        "interval": "30000",
        "x": 820,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "89c4097ee41fd798",
        "type": "link in",
        "z": "ee8f68611c51951f",
        "name": "link in 3",
        "links": [
            "bf211734494823b3"
        ],
        "x": 645,
        "y": 360,
        "wires": [
            [
                "306695d96b0d062e"
            ]
        ]
    }
]


回复

使用道具 举报

17

主题

187

帖子

1781

积分

金牌会员

Rank: 6Rank: 6

积分
1781
金钱
1594
HASS币
0
发表于 2024-2-23 21:41:13 | 显示全部楼层

呃,你这情况没有碰到过,你的流贴出来看下
回复

使用道具 举报

0

主题

34

帖子

150

积分

注册会员

Rank: 2

积分
150
金钱
116
HASS币
0
发表于 2024-2-23 21:49:12 | 显示全部楼层

论坛编辑器有问题。复制倒入到node-red里头报错,无法导入。还得麻烦兄弟导出json文件贴上来。
回复

使用道具 举报

17

主题

187

帖子

1781

积分

金牌会员

Rank: 6Rank: 6

积分
1781
金钱
1594
HASS币
0
发表于 2024-2-24 13:34:06 | 显示全部楼层
a5234338 发表于 2024-2-23 21:49
论坛编辑器有问题。复制倒入到node-red里头报错,无法导入。还得麻烦兄弟导出json文件贴上来。 ...

flows.rar (1.74 KB, 下载次数: 36)
回复

使用道具 举报

0

主题

34

帖子

150

积分

注册会员

Rank: 2

积分
150
金钱
116
HASS币
0
发表于 2024-2-24 23:27:03 | 显示全部楼层
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-22 09:26 , Processed in 0.329705 second(s), 33 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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