Webradio with MPD server and Node-red

Here is a simple way to get to play your favorite webradios.

This project is in the continuation of this one with a Rhasspy websocket: https://community.rhasspy.org/t/un-exemple-en-francais-avec-node-red/1944?u=kart-able
You just need to add the intent PlayStation in the switch and a link out node.

Of course, you will have to install MPD and MPC first.
Then install the MPD in and out nodes in the Node-red palette.
Complete your sentence.ini file with someting like

[PlayStation]
play radio (xxx:1 | xxx:2 | xxx:3 |xxx:4){station}

Add your stations in /var/lib/mpd/playlists in a m3u file and you are done.

The flow:
[{"id":"37773327.14bd4c","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"fc20831f.f2f2e","type":"mpd in","z":"37773327.14bd4c","name":"","topic":"","server":"1528854e.e49d6b","x":110,"y":300,"wires":[["df0f1db2.b9e7e","13fc025e.93d8ae","344dda92.111ce6"]]},{"id":"7ea37d6c.6aae04","type":"mpd out","z":"37773327.14bd4c","name":"","topic":"","server":"1528854e.e49d6b","x":422,"y":553,"wires":[["36797b6a.bf0f04"]]},{"id":"36797b6a.bf0f04","type":"debug","z":"37773327.14bd4c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":674,"y":554,"wires":[]},{"id":"dfec792e.8cca18","type":"inject","z":"37773327.14bd4c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"playlistinfo","payloadType":"str","x":142,"y":533,"wires":[["7ea37d6c.6aae04"]]},{"id":"fa8d4826.35efe8","type":"inject","z":"37773327.14bd4c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"listplaylist radio","payloadType":"str","x":162,"y":593,"wires":[["7ea37d6c.6aae04"]]},{"id":"41f54ec9.e6e54","type":"inject","z":"37773327.14bd4c","name":"clear the queue","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"clear","payloadType":"str","x":164,"y":473,"wires":[["7ea37d6c.6aae04"]]},{"id":"7693b19c.6142","type":"comment","z":"37773327.14bd4c","name":"load the playlist with \"mpc load radio\"","info":"then click on \"playlistinfo\" to get msg.payload populated\n\nIds are reset when mpd restarts (on boot or with \"sudo /etc/init.d/mpd restart\")","x":211,"y":655,"wires":[]},{"id":"344dda92.111ce6","type":"ui_dropdown","z":"37773327.14bd4c","name":"","label":"","tooltip":"","place":"Select option","group":"775b80ec.71b82","order":6,"width":0,"height":0,"passthru":false,"multiple":false,"options":[{"label":"Fip","value":"play 1","type":"str"},{"label":"Radio Meuh","value":"play 2","type":"str"},{"label":"Jazz Radio","value":"play 3","type":"str"},{"label":"Radio Grenouille","value":"play 4","type":"str"},{"label":"Radio Classique","value":"play 5","type":"str"},{"label":"France Musique","value":"play 6","type":"str"}],"payload":"","topic":"","x":222,"y":193,"wires":[["2d8e8724.943858"]]},{"id":"2d8e8724.943858","type":"exec","z":"37773327.14bd4c","command":"mpc","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":683,"y":413,"wires":[["7ea37d6c.6aae04"],[],[]]},{"id":"c60401bf.c89dc","type":"ui_text","z":"37773327.14bd4c","group":"775b80ec.71b82","order":7,"width":0,"height":0,"name":"","label":"Station :","format":"<h1>{{payload.currentsong.Name}}</h1>","layout":"row-left","x":482,"y":253,"wires":[]},{"id":"98991ae6.8f39f8","type":"comment","z":"37773327.14bd4c","name":"dashboard","info":"","x":118,"y":236,"wires":[]},{"id":"7e78e242.4d33fc","type":"comment","z":"37773327.14bd4c","name":"playlist management","info":"","x":148,"y":407,"wires":[]},{"id":"cf75da53.592d58","type":"ui_slider","z":"37773327.14bd4c","name":"","label":"","tooltip":"","group":"775b80ec.71b82","order":5,"width":0,"height":0,"passthru":false,"outs":"all","topic":"","min":0,"max":"100","step":1,"x":612,"y":254,"wires":[["439d75e5.dc8d0c"]]},{"id":"439d75e5.dc8d0c","type":"template","z":"37773327.14bd4c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"setvol {{payload}}","output":"str","x":749,"y":254,"wires":[["7ea37d6c.6aae04"]]},{"id":"4087712.bd3509","type":"ui_button","z":"37773327.14bd4c","name":"","group":"775b80ec.71b82","order":1,"width":"1","height":"1","passthru":false,"label":"","tooltip":"","color":"","bgcolor":"","icon":"fa-backward","payload":"prev","payloadType":"str","topic":"","x":372,"y":194,"wires":[["2d8e8724.943858"]]},{"id":"87b86b80.d2dd08","type":"ui_button","z":"37773327.14bd4c","name":"","group":"775b80ec.71b82","order":2,"width":"1","height":"1","passthru":false,"label":"","tooltip":"","color":"","bgcolor":"","icon":"fa-play","payload":"play","payloadType":"str","topic":"","x":512,"y":194,"wires":[["2d8e8724.943858"]]},{"id":"bac11e73.27c51","type":"ui_button","z":"37773327.14bd4c","name":"","group":"775b80ec.71b82","order":3,"width":"1","height":"1","passthru":false,"label":"","tooltip":"","color":"","bgcolor":"","icon":"fa-stop","payload":"stop","payloadType":"str","topic":"","x":652,"y":194,"wires":[["2d8e8724.943858"]]},{"id":"af7d5924.58e728","type":"ui_button","z":"37773327.14bd4c","name":"","group":"775b80ec.71b82","order":4,"width":"1","height":"1","passthru":false,"label":"","tooltip":"","color":"","bgcolor":"","icon":"fa-forward","payload":"next","payloadType":"str","topic":"","x":788,"y":195,"wires":[["2d8e8724.943858"]]},{"id":"e220eb10.f344f8","type":"comment","z":"37773327.14bd4c","name":"Speech to text","info":"intent PlayStation from Rhasspy","x":128,"y":105,"wires":[]},{"id":"df0f1db2.b9e7e","type":"ui_text","z":"37773327.14bd4c","group":"775b80ec.71b82","order":7,"width":0,"height":0,"name":"","label":"Titre : ","format":"{{payload.currentsong.Title}}","layout":"row-left","x":472,"y":300,"wires":[]},{"id":"13fc025e.93d8ae","type":"change","z":"37773327.14bd4c","name":"","rules":[{"t":"change","p":"payload.currentsong.Name","pt":"msg","from":"fip-midfi.mp3","fromt":"str","to":"FIP","tot":"str"},{"t":"change","p":"payload.currentsong.Name","pt":"msg","from":"Radiomeuh.com","fromt":"str","to":"Radio Meuh","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":302,"y":253,"wires":[["c60401bf.c89dc"]]},{"id":"82e5cc9c.aa844","type":"change","z":"37773327.14bd4c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"slots.station","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":453,"y":103,"wires":[["78fa7bd4.4f00f4"]]},{"id":"78fa7bd4.4f00f4","type":"template","z":"37773327.14bd4c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"play {{payload}}","output":"str","x":657,"y":103,"wires":[["2d8e8724.943858"]]},{"id":"918c129f.4cb06","type":"link in","z":"37773327.14bd4c","name":"","links":["91154ed0.101de"],"x":270,"y":103,"wires":[["82e5cc9c.aa844"]]},{"id":"1528854e.e49d6b","type":"mpd-server","host":"localhost","port":"6600"},{"id":"775b80ec.71b82","type":"ui_group","name":"webradio","tab":"23cd7a71.311de6","order":1,"disp":true,"width":"10","collapse":false},{"id":"23cd7a71.311de6","type":"ui_tab","name":"Radio/Music","icon":"dashboard","order":1}]

5 Likes