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

 找回密码
 立即注册
查看: 6814|回复: 4

[流程系列] node-red通过ssh 登录设备获取信息并建立传感器,有没有成...

[复制链接]

2

主题

27

帖子

255

积分

中级会员

Rank: 3Rank: 3

积分
255
金钱
228
HASS币
0
发表于 2021-7-26 10:03:53 | 显示全部楼层 |阅读模式
我想在node-red里面建立这样一个流程:首先通过ssh登录我的华硕路由器,定期执行命令获取相应的信息,并将其储存在传感器中,最终通过hass的dashboard展现出来。不知道有没有成功的案例?


关键是node-red如何调用ssh,并执行相应的命令
回复

使用道具 举报

5

主题

68

帖子

944

积分

高级会员

Rank: 4

积分
944
金钱
876
HASS币
0
发表于 2021-7-30 17:46:05 | 显示全部楼层
exec可以执行ssh命令,免密方式ssh,如果nodered是docker方式安装的,要把home文件映射到本地,把keygen储存好,不然每次重启nodered,keygen密钥就没有了,ssh命令没法执行。读取路由器信息就比较简单了,主要解决ssh的问题
回复

使用道具 举报

1

主题

211

帖子

2291

积分

金牌会员

Rank: 6Rank: 6

积分
2291
金钱
2080
HASS币
0
发表于 2021-9-12 17:54:59 | 显示全部楼层
[{"id":"22e883a2.ad1f7c","type":"inject","z":"a2cafd78.f8ef3","name":"","topic":"","payload":"","payloadType":"date","repeat":"30","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":2620,"wires":[["fcc7c4fd.2a4ce8"]]},{"id":"fcc7c4fd.2a4ce8","type":"bigssh","z":"a2cafd78.f8ef3","name":"","commandLine":"cat /proc/dmu/temperature","commandArgs":"","minError":1,"minWarning":1,"noStdin":false,"format":"utf8","payloadIsArg":false,"myssh":"25e517c9.a34358","x":320,"y":2620,"wires":[["6632d1e5.5a218"],[],[]]},{"id":"6632d1e5.5a218","type":"function","z":"a2cafd78.f8ef3","name":"处理信息","func":"msg.topic = "/node-red/ac88ucputemp/"\n\nvar ac88ucputemp=msg.payload;\nmsg.payload=ac88ucputemp.replace(/[^0-9]/ig,"");\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":2620,"wires":[["1dc61949.db0047"]]},{"id":"1dc61949.db0047","type":"mqtt out","z":"a2cafd78.f8ef3","name":"","topic":"/node-red/ac88ucputemp/","qos":"2","retain":"","broker":"9bdb7552.c3aaa8","x":790,"y":2620,"wires":[]},{"id":"25e517c9.a34358","type":"SSH_Credentials","z":"","host":"192.168.1.1","port":"22","userlabel":"[email protected]"},{"id":"9bdb7552.c3aaa8","type":"mqtt-broker","z":"","name":"88-MQTT","broker":"192.168.1.188","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]


前两天刚刚实验成功
回复

使用道具 举报

2

主题

27

帖子

255

积分

中级会员

Rank: 3Rank: 3

积分
255
金钱
228
HASS币
0
 楼主| 发表于 2021-9-28 10:43:08 | 显示全部楼层
后来找到一个bigssh的节点,挺好用的
回复

使用道具 举报

17

主题

251

帖子

1888

积分

论坛DIY达人

积分
1888
金钱
1637
HASS币
20
发表于 2022-4-28 19:32:33 | 显示全部楼层
michlu 发表于 2021-9-28 10:43
后来找到一个bigssh的节点,挺好用的

请问可以发送命令给ESXi执行吗
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-22 04:03 , Processed in 1.455462 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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