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

 找回密码
 立即注册
查看: 4101|回复: 6

[流程系列] 关于http in/http response节点,求大佬指点迷津....

[复制链接]

15

主题

253

帖子

2137

积分

金牌会员

Rank: 6Rank: 6

积分
2137
金钱
1884
HASS币
0
发表于 2021-9-28 21:44:02 | 显示全部楼层 |阅读模式
本帖最后由 s450586793 于 2021-9-28 21:45 编辑

起因是看了L大这篇文章:qBittorrent下载完成TTS播报 - 『Node-RED』综合讨论区 - 『瀚思彼岸』» 智能家居技术论坛 - Powered by Discuz! (hassbian.com)

想着稍加修改,就可以让qb下载完成后发送消息给企业微信了

调试了一天的http in 跟 http respense了,然而在docker的qb下载完成后调用wget时,docker日志提示:
Connecting to 192.168.0.233:1880 (192.168.0.233:1880)
wget: server returned error: HTTP/1.1 404 Not Found
-------------------------------------------------------------------------------------------
然后用浏览器直接输入wget http://node-red用户:node-red密码@192 ... omplete?category=%L\&size=%Z -O temp.tmp &&rm temp.tmp

这个链接,永远是回复Cannot GET /download_complete



并且在http in节点后面挂了msg输出.完全没有动静,感觉就是这个链接没有触发ode的http in

求大佬指点.....




下面是我的flow

[{"id":"21596348b99296a4","type":"http in","z":"3c397a342b1c9915","name":"下载完成","url":"/download_complete","method":"get","upload":false,"swaggerDoc":"","x":100,"y":100,"wires":[["1b1df969100b1275","b8350fd9bbba7c96"]]},{"id":"b8350fd9bbba7c96","type":"function","z":"3c397a342b1c9915","name":"推送内容","func":"var name_dict = {\"Movie\":\"电影\",\"TV\":\"电视剧\",\"Adult\":\"未知\",\"video\":\"视频\"};\nvar size = (msg.payload.size/1.0e9).toFixed(2);\nvar message = `${name_dict[msg.payload.category]}下载完成,本次共计下载${size}GB`;\nmsg.payload = {};\nmsg.payload.data = {\"message\":message,\"miai_num\":\"0\"};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":100,"wires":[["2689dfbdfc192f31"]]},{"id":"adc68c3a726e9169","type":"http response","z":"3c397a342b1c9915","name":"返回操作状态","statusCode":"200","headers":{},"x":600,"y":100,"wires":[]},{"id":"2689dfbdfc192f31","type":"template","z":"3c397a342b1c9915","name":"HTML","field":"payload","fieldType":"msg","format":"json","syntax":"plain","template":"{\"msg\":\"ok\"}","output":"str","x":430,"y":100,"wires":[["adc68c3a726e9169"]]},{"id":"1b1df969100b1275","type":"debug","z":"3c397a342b1c9915","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":290,"y":160,"wires":[]}]




回复

使用道具 举报

77

主题

1391

帖子

2万

积分

元老级技术达人

积分
24293
金钱
22862
HASS币
290
发表于 2021-9-29 00:44:22 | 显示全部楼层
最近在整R1音箱的node-red劫持控制设备,其中用到了 http in 节点。花了很长时间才搞定。
新版本(应该也已经很久了)节点的链接为:http://node-red的IP:1880/endpoint/download_complete…… http node用户名密码要通过 header的base64来请求,如果是http request节点来请求可以通过基本认证中填写。
注意 路径中要加上 /endpoint
回复

使用道具 举报

15

主题

253

帖子

2137

积分

金牌会员

Rank: 6Rank: 6

积分
2137
金钱
1884
HASS币
0
 楼主| 发表于 2021-9-29 10:18:49 | 显示全部楼层
dscao 发表于 2021-9-29 00:44
最近在整R1音箱的node-red劫持控制设备,其中用到了 http in 节点。花了很长时间才搞定。
新版本(应该也已 ...

搞了2天,谢谢大佬,搞定了
回复

使用道具 举报

17

主题

153

帖子

1559

积分

金牌会员

Rank: 6Rank: 6

积分
1559
金钱
1406
HASS币
0
发表于 2021-9-29 14:24:57 | 显示全部楼层
s450586793 发表于 2021-9-29 10:18
搞了2天,谢谢大佬,搞定了

怎么搞定的,发个流看下,还有,qB里面怎么填写
回复

使用道具 举报

15

主题

253

帖子

2137

积分

金牌会员

Rank: 6Rank: 6

积分
2137
金钱
1884
HASS币
0
 楼主| 发表于 2021-9-29 19:57:50 | 显示全部楼层
fpsonic 发表于 2021-9-29 14:24
怎么搞定的,发个流看下,还有,qB里面怎么填写

[{"id":"21596348b99296a4","type":"http in","z":"3c397a342b1c9915","name":"下载完成","url":"/download_complete","method":"get","upload":false,"swaggerDoc":"","x":100,"y":100,"wires":[["1b1df969100b1275","b8350fd9bbba7c96"]]},{"id":"b8350fd9bbba7c96","type":"function","z":"3c397a342b1c9915","name":"推送内容","func":"var name_dict = {\"Movie\":\"电影\",\"TV\":\"电视剧\",\"Adult\":\"未知\",\"video\":\"视频\"};\nvar size = (msg.payload.size/1.0e9).toFixed(2);\n//var message = `${name_dict[msg.payload.category]}下载完成,本次共计下载${size}GB`;\nvar message = `${name_dict[msg.payload.category]}{msg.payload.name}下载完成,本次共计下载${size}GB`;\nmsg.payload = {\n   \"touser\" : \"WuXiaoBin\",\n   \"msgtype\" : \"text\",\n   \"text\" : {\n       \"content\" : message\n   },\n   \"safe\":0\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":100,"wires":[["fe7ed752143d2215"]]},{"id":"adc68c3a726e9169","type":"http response","z":"3c397a342b1c9915","name":"返回操作状态","statusCode":"200","headers":{},"x":700,"y":100,"wires":[]},{"id":"2689dfbdfc192f31","type":"template","z":"3c397a342b1c9915","name":"HTML","field":"payload","fieldType":"msg","format":"json","syntax":"plain","template":"{\"msg\":\"ok\"}","output":"str","x":550,"y":100,"wires":[["adc68c3a726e9169"]]},{"id":"1b1df969100b1275","type":"debug","z":"3c397a342b1c9915","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":290,"y":160,"wires":[]}]
上面是流程
下面是我自己改了以下的qb的运行外部程序
wget http://username:[email protected] ... category=%L&size=%Z
回复

使用道具 举报

3

主题

223

帖子

3047

积分

元老级技术达人

积分
3047
金钱
2819
HASS币
10
发表于 2021-9-30 14:35:06 | 显示全部楼层
qb的我是真不敢报
回复

使用道具 举报

15

主题

253

帖子

2137

积分

金牌会员

Rank: 6Rank: 6

积分
2137
金钱
1884
HASS币
0
 楼主| 发表于 2021-9-30 17:28:11 | 显示全部楼层
blindlight 发表于 2021-9-30 14:35
qb的我是真不敢报

哈哈,我改成了微信通知
而且可以分类,然后再node里进行判断,adult一类就不发通知
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-21 22:34 , Processed in 1.441915 second(s), 29 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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