NR控制Volumio

  1. 起因

近日在做Volumio音乐播放器,遇到一个很小、但也很实际的障碍:无法远程关闭Volumio客户端,仅能通过断电关闭。
在Homeassistant中可以通过media组件接入,但仍不支持关闭功能。
在NR中查找,有volumio节点,遂安装、调试。

  1. 实现及作用

Volumio安装、NR节点安装、设置IP等都很简单,略过。

1.JPG
该节点与HA media组件的区别,是可以调用更多的api接口(如睡眠等)、实现更多的功能;详细的websocket api可以参考官方文档,其列出的api均可调用。
2.JPG
[mw_shl_code=applescript,true]{“id”:“b1509528.23b768”,“type”:“volumio event”,“z”:“ec0b3231.4baca”,“server”:“423bd89d.5877f8”,“event”:“pushState”,“x”:180,“y”:120,“wires”:“a1fe5d60.84a9e”]]},{“id”:“c29e1835.638668”,“type”:“inject”,“z”:“ec0b3231.4baca”,“name”:"",“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:170,“y”:220,“wires”:“133e90c2.cd096f”]]},{“id”:“133e90c2.cd096f”,“type”:“function”,“z”:“ec0b3231.4baca”,“name”:“pause”,“func”:“msg.payload = {}\nmsg.payload.event= ‘pause’\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:220,“wires”:“860c8ddd.effff”]]},{“id”:“e11c8c61.97bbf”,“type”:“function”,“z”:“ec0b3231.4baca”,“name”:“play”,“func”:“msg.payload = {}\nmsg.payload.event= ‘play’\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:300,“wires”:“860c8ddd.effff”]]},{“id”:“ef9a5e3b.80dd”,“type”:“inject”,“z”:“ec0b3231.4baca”,“name”:"",“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:160,“y”:300,“wires”:“e11c8c61.97bbf”]]},{“id”:“d52881b7.8780a”,“type”:“function”,“z”:“ec0b3231.4baca”,“name”:“volume 50”,“func”:“msg.payload = {}\nmsg.payload.event= ‘volume’\nmsg.payload.data= 50\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:390,“y”:400,“wires”:“860c8ddd.effff”]]},{“id”:“c29785f0.87f698”,“type”:“inject”,“z”:“ec0b3231.4baca”,“name”:"",“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:160,“y”:400,“wires”:“d52881b7.8780a”]]},{“id”:“58e9469f.53a918”,“type”:“function”,“z”:“ec0b3231.4baca”,“name”:“sleep”,“func”:“msg.payload = {}\nmsg.payload.event= “setSleep”\nmsg.payload.pushEvent= “pushSleep”\nmsg.payload.data= {}\nmsg.payload.data.enabled= true\nmsg.payload.data.time= ‘00:01’\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:480,“wires”:“860c8ddd.effff”]]},{“id”:“305ef955.108f26”,“type”:“inject”,“z”:“ec0b3231.4baca”,“name”:"",“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:160,“y”:480,“wires”:“58e9469f.53a918”]]},{“id”:“860c8ddd.effff”,“type”:“volumio command”,“z”:“ec0b3231.4baca”,“server”:“423bd89d.5877f8”,“x”:780,“y”:340,“wires”:]]},{“id”:“a1fe5d60.84a9e”,“type”:“debug”,“z”:“ec0b3231.4baca”,“name”:"",“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“false”,“x”:430,“y”:120,“wires”:]},{“id”:“423bd89d.5877f8”,“type”:“volumio-server”,“z”:"",“host”:“192.168.19.5”,“port”:“3000”}][/mw_shl_code]
3. 参考资料


[https://flows.nodered.org/node/node-red-contrib-volumio](https://flows.nodered.org/node/node-red-contrib-volumio)
[https://volumio.github.io/docs/API/WebSocket_APIs.html](https://volumio.github.io/docs/API/WebSocket_APIs.html)