UNRAIDHomeKit

UNRAID搭建 Node-RED 将小米电视4C接入 HomeKit

2021-10-28 11690字 8,149

安装过程

1. 拉取 Node-RED 镜像

sudo docker image pull nodered/node-red:latest

2. 创建 Node-RED 容器

sudo docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered --restart=always --net=host nodered/node-red:latest

3. 安装npm包redmatic-homekit

进入docker的shell命令执行脚本

# 设置为国内镜像
npm config set registry http://registry.npm.taobao.org

# 安装 redmatic-homekit
npm i redmatic-homekit

# 重启 Node-RED 容器

4. 在路由器中绑定MAC与IP

进入路由器后台,绑定电视机的MAC地址和IP,否则IP发生变化会失效

5. 导入配置文件

点击右上角三个横杠,点击导入,把上面的内容粘贴进去,选择新流程,点击导入即可。

[{"id":"2dedfb2072ce4dce","type":"tab","label":"小米电视","disabled":false,"info":""},{"id":"4b6282dfe5a3df2c","type":"debug","z":"2dedfb2072ce4dce","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":420,"wires":[]},{"id":"644f278c81db5eec","type":"switch","z":"2dedfb2072ce4dce","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"PowerModeSelection","vt":"str"},{"t":"eq","v":"InputSource","vt":"str"},{"t":"eq","v":"Active","vt":"str"},{"t":"eq","v":"VolumeSelector","vt":"str"},{"t":"eq","v":"RemoteKey","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":810,"y":300,"wires":[["0de80a2e6302d568"],["fcc7b41ff68e0d4d"],["57e4013a62141b6c"],["f38c56683a9dedfe"],["794923f19f9803d5"]]},{"id":"57e4013a62141b6c","type":"switch","z":"2dedfb2072ce4dce","name":"开关机","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":1010,"y":260,"wires":[["ad728370104f53d4"],["6becfd0de8e8468f"]]},{"id":"fcc7b41ff68e0d4d","type":"switch","z":"2dedfb2072ce4dce","name":"输入源","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"主页","vt":"str"},{"t":"eq","v":"群辉播放器","vt":"str"},{"t":"eq","v":"电视家2.0","vt":"str"},{"t":"eq","v":"无线投屏","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":1010,"y":200,"wires":[["34f5e3cb48cd71dc"],["1629faf95a252bd8"],["3e9944b96b270d7b"],["22d9ee12f0f4558d"]],"outputLabels":["","","","爱奇艺"]},{"id":"794923f19f9803d5","type":"switch","z":"2dedfb2072ce4dce","name":"功能键","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"PLAY_PAUSE","vt":"str"},{"t":"eq","v":"SELECT","vt":"str"},{"t":"eq","v":"BACK","vt":"str"},{"t":"eq","v":"INFORMATION","vt":"str"},{"t":"eq","v":"ARROW_RIGHT","vt":"str"},{"t":"eq","v":"ARROW_LEFT","vt":"str"},{"t":"eq","v":"ARROW_UP","vt":"str"},{"t":"eq","v":"ARROW_DOWN","vt":"str"}],"checkall":"true","repair":false,"outputs":8,"x":1010,"y":520,"wires":[["6d911230035245e5"],["6d911230035245e5"],["6685726ee5de3d49"],["2b7a7935950761b8"],["5eb1cdc42e3417e2"],["291d439af88b643f"],["0dd7a6cc414632d2"],["4f5114aff77d199b"]],"outputLabels":["暂停","确认","返回","信息","向右","向左","向上","向下"]},{"id":"0dd7a6cc414632d2","type":"http request","z":"2dedfb2072ce4dce","name":"上","method":"GET","ret":"txt","paytoqs":false,"url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=up","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":600,"wires":[[]]},{"id":"4f5114aff77d199b","type":"http request","z":"2dedfb2072ce4dce","name":"下","method":"GET","ret":"txt","paytoqs":false,"url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=down","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":640,"wires":[[]]},{"id":"291d439af88b643f","type":"http request","z":"2dedfb2072ce4dce","name":"左","method":"GET","ret":"txt","paytoqs":false,"url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=left","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":560,"wires":[[]]},{"id":"5eb1cdc42e3417e2","type":"http request","z":"2dedfb2072ce4dce","name":"右","method":"GET","ret":"txt","paytoqs":false,"url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=right","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":520,"wires":[[]]},{"id":"2b7a7935950761b8","type":"http request","z":"2dedfb2072ce4dce","name":"菜单","method":"GET","ret":"txt","paytoqs":false,"url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=menu","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":480,"wires":[[]]},{"id":"6685726ee5de3d49","type":"http request","z":"2dedfb2072ce4dce","name":"返回","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=back","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":440,"wires":[[]]},{"id":"6d911230035245e5","type":"http request","z":"2dedfb2072ce4dce","name":"确定","method":"GET","ret":"txt","paytoqs":false,"url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=enter","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":400,"wires":[[]]},{"id":"ad728370104f53d4","type":"http request","z":"2dedfb2072ce4dce","name":"电源","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=power","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":240,"wires":[["be1de219e23e8492"]]},{"id":"99344bb5d9e03d07","type":"change","z":"2dedfb2072ce4dce","name":"设定电视 IP","rules":[{"t":"set","p":"ip","pt":"msg","to":"192.168.50.42","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":500,"wires":[["644f278c81db5eec","938ccdc4be464de9"]]},{"id":"0e137052605f052b","type":"redmatic-homekit-tv","z":"2dedfb2072ce4dce","name":"小米电视","username":"AB:22:3D:40:49:AD","pincode":"886-50-223","port":"50335","inputsources":[{"name":"主页","type":1},{"name":"群辉播放器","type":10},{"name":"电视家2.0","type":10},{"name":"无线投屏","type":8}],"x":440,"y":460,"wires":[["99344bb5d9e03d07","4b6282dfe5a3df2c"]]},{"id":"b1d74aab299ac161","type":"http request","z":"2dedfb2072ce4dce","name":"切换应用","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{ip}}}:6095/controller?action=startapp&type=packagename&packagename={{{app}}}","tls":"","persist":false,"proxy":"","authType":"basic","x":1440,"y":40,"wires":[[]]},{"id":"34f5e3cb48cd71dc","type":"change","z":"2dedfb2072ce4dce","name":"主页","rules":[{"t":"set","p":"app","pt":"msg","to":"com.mitv.tvhome","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":80,"wires":[["b1d74aab299ac161"]]},{"id":"7322a509e3e4427a","type":"inject","z":"2dedfb2072ce4dce","name":"状态","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":0.1,"topic":"Active","payload":"false","payloadType":"bool","x":170,"y":340,"wires":[["fa4a7455eb32c326"]]},{"id":"699d49aff1fbf2dc","type":"http request","z":"2dedfb2072ce4dce","name":"检查状态","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{ip}}}:6095/request?action=isalive","tls":"","persist":false,"proxy":"","authType":"basic","x":260,"y":420,"wires":[["9519ff9e9cd936c9"]]},{"id":"fa4a7455eb32c326","type":"change","z":"2dedfb2072ce4dce","name":"设定电视 IP","rules":[{"t":"set","p":"ip","pt":"msg","to":"192.168.50.42","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":380,"wires":[["699d49aff1fbf2dc"]]},{"id":"9519ff9e9cd936c9","type":"function","z":"2dedfb2072ce4dce","name":"","func":"var code=msg.statusCode;nif( code != 200 )n{nmsg.payload=false;n}nelsen{nmsg.payload=truen n}nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":460,"wires":[["0e137052605f052b"]]},{"id":"1629faf95a252bd8","type":"change","z":"2dedfb2072ce4dce","name":"群辉播放器","rules":[{"t":"set","p":"app","pt":"msg","to":"com.synology.dsvideo","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1230,"y":120,"wires":[["b1d74aab299ac161"]]},{"id":"3e9944b96b270d7b","type":"change","z":"2dedfb2072ce4dce","name":"电视家2.0","rules":[{"t":"set","p":"app","pt":"msg","to":"com.elinkway.tvlive2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":160,"wires":[["b1d74aab299ac161"]]},{"id":"6becfd0de8e8468f","type":"http request","z":"2dedfb2072ce4dce","name":"返回","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=back","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":280,"wires":[[]]},{"id":"22d9ee12f0f4558d","type":"change","z":"2dedfb2072ce4dce","name":"无线投屏","rules":[{"t":"set","p":"app","pt":"msg","to":"com.xiaomi.mitv.smartshare","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":200,"wires":[["b1d74aab299ac161"]]},{"id":"0de80a2e6302d568","type":"change","z":"2dedfb2072ce4dce","name":"系统设置","rules":[{"t":"set","p":"app","pt":"msg","to":"com.xiaomi.mitv.settings","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":40,"wires":[["b1d74aab299ac161"]]},{"id":"938ccdc4be464de9","type":"http request","z":"2dedfb2072ce4dce","name":"查看app名称","method":"GET","ret":"txt","paytoqs":false,"url":"http://{{{ip}}}:6095/controller?action=getinstalledapp&count=999&changeIcon=1","tls":"","persist":false,"proxy":"","authType":"basic","x":830,"y":680,"wires":[["9c9fbf4577cf8fd8"]]},{"id":"b614fed37c3f31ac","type":"inject","z":"2dedfb2072ce4dce","name":"查询 APP 名称","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":420,"y":540,"wires":[["99344bb5d9e03d07"]]},{"id":"9c9fbf4577cf8fd8","type":"json","z":"2dedfb2072ce4dce","name":"","property":"payload","action":"","pretty":false,"x":850,"y":720,"wires":[["f83fd709fa3aaae3"]]},{"id":"f83fd709fa3aaae3","type":"debug","z":"2dedfb2072ce4dce","name":"获取 APP 名称","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":920,"y":760,"wires":[]},{"id":"f38c56683a9dedfe","type":"switch","z":"2dedfb2072ce4dce","name":"音量","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"VOLUMEUP","vt":"str"},{"t":"eq","v":"VOLUMEDOWN","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1010,"y":340,"wires":[["5f26dfe43e4b344b"],["d5269d1ef6f9581e"]]},{"id":"5f26dfe43e4b344b","type":"http request","z":"2dedfb2072ce4dce","name":"音量 +","method":"GET","ret":"txt","paytoqs":false,"url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=volumeup","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":320,"wires":[[]]},{"id":"d5269d1ef6f9581e","type":"http request","z":"2dedfb2072ce4dce","name":"音量 -","method":"GET","ret":"txt","paytoqs":false,"url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=volumedown","tls":"","persist":false,"proxy":"","authType":"basic","x":1210,"y":360,"wires":[[]]},{"id":"e8784fdcdbb99d9c","type":"http request","z":"2dedfb2072ce4dce","name":"电源","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{ip}}}:6095/controller?action=keyevent&keycode=power","tls":"","persist":false,"proxy":"","authType":"basic","x":1510,"y":240,"wires":[[]]},{"id":"be1de219e23e8492","type":"delay","z":"2dedfb2072ce4dce","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":1360,"y":240,"wires":[["e8784fdcdbb99d9c"]]}]

6. 修改配置中的电视机IP

找到其中两个名为“设定电视 IP”的节点,双击,将IP地址改为你电视机的IP地址,两个节点都这么处理。然后点击右上角“部署”来保存。

7. 导入HomeKit

设置netbridge模式,Homekit无法连接,疑50335端口未开放,未再次确认;
设置过程中,小米电视节点,无法点击展示homekit二维码,可以手动添加,然后输入固定的短码:886-50-223

参考

使用树莓派开启HomeKit智能家居系统 篇十二:Docker 下安装 Node-RED

将小米电视通过 Node-RED 接入 HomeKit

版权声明:Shire 发表于 2021-10-28
转载请注明: UNRAID搭建 Node-RED 将小米电视4C接入 HomeKit | Shire

评论

该文章已经关闭评论