Volumio - How to play specified files or playlist or shuffle songs?

Hi,

My first post here. A few details of my current setup.

Installed Home Assistant using Pi AIO on R-Pi3.
Set up most basic things including 2 Pi-1s (an original B, and a B+ with 40 GPIO) with Volumio. Media stored on QNAP NAS.

Latest version of HA installed.

I would like to be able to set up the following functions for the players:

Play a specified song / playlist and shuffle library. From documentation I’m unsure if the functions are possible and if so how to set this up. The devices show up in Views for the rooms they are in but only play and stop are available from the front end currently.

If Volumio is not a good option for this, then what is? I don’t want to invest in new hardware for the job as the players work reasonably well in their current state. The libraries are large but Volumio copes well and the web interface functions satisfactorily.

Are there other software options capable of running on the 2 R-Pis I have that would have the ability to carry out these functions? I have scoured the web but have come up empty so far with a solution for Volumio so perhaps someone out there can help me.

Thanks in advance for any assistance or advice.

Nick

I’m new to Home Assistant and came across the iFrame which I thought would be useful and provide more functionality than that currently shown in Home Assistant. The problem is I’m using SSL and from what I’ve read that’s an issue. I’m aware it can be circumvented in certain browsers (Chrome) but not an ideal solution.

Is MPD, Music Player Daemon, a good place to start looking for the functionality above? There just doesn’t seem to be many people using Volumio on here from what I can see.

As before I’d appreciate any help or even to be pointed in the right direction.

Many thanks!

After lots of reading and trial and error I’ve got Volumio to play in the dev services and have made some progress. The thing I’m struggling with is how to select a playlist. Unsure if it actually can be done.

Hey there,

have you tried to call the REST API?
https://volumio.github.io/docs/API/REST_API.html

It offers an endpoint to play a playlist by name:
volumio.local/api/v1/commands/?cmd=playplaylist&name=Rock

And also one to list all playlists. It probably would be possible to load them into an input_select .

As for the shuffle toggle, it does not seem to be available via REST: However, you could create a script that opens a web socket connection to your volumio instance to trigger that command:
https://volumio.github.io/docs/API/WebSocket_APIs.html

Hope this helps
Jochen

Hi Jochen,

Many thanks for your help. I’ll have a look at this. I’m very new to Home Assistant so this may take me a while to figure out.

I have some time this afternoon to give this a go. I had HA set up with the PI AIO installer so have just moved over to Hassbian so I could update to 0.59. I’ll post my progress here when I get it going or not and hopefully you can help steer me in the right direction if I run into problems.

Thanks again.

Nick

Okay - I should have gone to bed hours ago but…

I have tried the command:

tailored to my entities in a browser. volumio.local didn’t seem to work so I used the IP address of the player instead and it returns some JSON, an array with the playlists present.

First question - how do I send this in HA? Do I use rest_command? How do I get and use what’s returned?

Apologies - as you can probably tell I have a lot to learn! I tend to approach things by getting things working a bit at a time. I am a bit stuck however.

I haven’t used input_select until very recently. I have two volumio players so I made a input_select as follows to select the player:

  select_volumio_player:
    name: Select Volumio Player
    options:
     - Lounge
     - Bedroom
    initial: Lounge
    icon: mdi:music-circle

And also hardcoded the names of two playlists available as follows:

  select_playlist:
    name: Select Playlist
    options:
     - Select a playlist
     - ADF
     - Dave Gahan
    initial: Select a playlist
    icon: mdi:playlist-check

So now i need to send:

volumio_ip_address/api/v1/commands/?cmd=playplaylist&name=ADF

to play the “ADF” playlist. I’ve written an automation just to send to the volumio_bedroom as follows:

- alias: Play selected playlist
    trigger:
      - platform: state
        entity_id: input_select.select_playlist
    action:
      - service: media_player.play_media
        data_template:
          entity_id: >
            {% if is_state("input_select.select_playlist", "ADF") %}
              media_player.volumio_bedroom
            {%-elif is_state("input_select.select_playlist", "Dave Gahan") %}
              media_player.volumio_bedroom
            {% else %}
              none
            {% endif %}

I don’t know if this works as it’s late and the kids are in bed so I’ll test tomorrow.

This isn’t exactly what I want to do but I’m starting small and working through it bit by bit.

So this is what I still need to accomplish…

  1. Make the player the playlist is played on dynamic according to the option in input_select.

  2. Obtain the playlists stored on each player and populate an input_select with them.

  3. Then the shuffle toggle using websocket api.

I’ve still got a long way to go and it’s hurting my head! :confused:

Thank you in advance for any help or pointers.

I’m not sure whether there is an easier way, but I’ve used a shell command for that calling cURL.

Here is an example from my config where I call my Panasonic 5.1 system via HTTP to set the volume based on an input_number (value):

shell_command:
  set_panasonic_volume: 'curl -i -H "user-agent: MEI-LAN-REMOTE-CALL" -X POST --data "cCMD_EXEC.x=100&cCMD_EXEC.y=100&cVOLUME={{value}}" http://192.168.178.28/WAN/dvdr/dvdr_volume_ctrl.cgi'

You can, for example, call it in an automation that triggers when you change your playlist combobox or when you hit a script’s start button in the ui.

The automation action would look like this:

 action:
    service: shell_command.set_panasonic_volume
    data_template:
      value: '{{ states.input_number.panasonic_volume.state | int }}'

For a setup similar to what you’re building have a look at the chromecast component here:

Hi Jochen,

Thanks so much for your help.

I have a very bad hangover today :nauseated_face: but have tried out the shell command using ssh and in dev and got one of the volumio players responding. So progress…

I have learned a lot.

Still need to call the shell command successfully in HA but once the hangover clears I’ll get on with it!!

Thanks for pointing the way. I’ll post where I’m up to in the next few days.

Hi,

i’m running hassio and i’d like to call a simple script to play a volumio playlist. I didn’t get it working using CLI and the mpc commands, thus i tried the rest api.

with chrome on my mac, every command works fine. but when i try to call the commands with terminal on my mac, only the play/stop command works.
for example, when i try to play a playlist with the following command it doesn’t work :frowning:

curl http://volumio.local/api/v1/commands/?cmd=playplaylist&name=FM4

Actually, i don’t know how to use the curl-command properly…
Can someone help me?

Maybe the websocket_API is better? But like iNick i’m a beginner and try to teach myself step by step and with trial and error…

Hi,

you are probably on the right track. I’d assume that it works if you replace volumio.local with the IP address of volumio or even just “volumio” instead of “volumio.local”. I think that “.local” stuff is related to the bonjour service that is available on Macs and Windows but not on other devices such as Raspberry. I quite frankly didn’t care enough to investigate further - I just use “http://volumio” as entry point on my android device and the IP in HA.

Btw, once you have the request going you can add a “-s” parameter to execute it silently in case that disturbs anything.

1 Like

Yes! Thanks a lot! A command like the following one works perfect!
curl 192.168.0.185/api/v1/commands/\?cmd\=playplaylist\&name\=Fat%20Freddys%20Drop

One last question:
I’d like to call this command with a script or at least with a single button, not a switch. Is there a way how i can realize this?

Did u just try to use mpd component ? Works fine for me. BTW.playlist is not supported for mpd

yes, i tried it but as you said playlists are not supported.
right now i’m trying the RESTful command

Sure, you can put it in a shell command in HA config like this:

shell_command:
  set_panasonic_volume: 'curl -i -H "user-agent: MEI-LAN-REMOTE-CALL" -X POST --data "cCMD_EXEC.x=100&cCMD_EXEC.y=100&cVOLUME={{value}}" http://192.168.188.10/WAN/dvdr/dvdr_volume_ctrl.cgi'

Here I am doing a POST request with a plain text body. The {{value}} placeholders are replaced during the call, e.g. from an automation:

- alias: ChangePanasonicVolumeBasedOnSlider
  trigger:
    platform: state
    entity_id: input_number.panasonic_volume
  action:
    service: shell_command.set_panasonic_volume
    data_template:
      value: '{{ states.input_number.panasonic_volume.state | int }}'

With these examples you should be able to build something to change your playlists, e.g. based on a input_select field or something.

Great! Thanks so much jo-me! You made my day! :slight_smile: Works perfect with these commands:

shell_command:
  volumio_fatfreddys: 'curl 192.168.0.185/api/v1/commands/\?cmd\=playplaylist\&name\=Fat%20Freddys%20Drop'

and

volumio_playlist1:
  alias: Fat Freddys Drop
  sequence:
    - service: shell_command.volumio_fatfreddys

Btw: For everyone who wants to toggle shuffle for Volumio, this is the command i’m using:

curl 192.168.0.185/api/v1/commands/?cmd=random

It isn’t documented in the Volumio Manual, but i found it out by myself :slight_smile:

2 Likes

Hello,
I am a novice. I do not know much about coding and development. I have installed hass.io on a rpi3. I also have another rpi3 with volumio2 to install. I do not know how to control my volumio2 in my home-assistant.
Which method to use?
How to do it? I added
media_player:

  • platform: volumio
    host: http: // my-ip
    port: 3000
    In configuration.yaml. I see volumio2 in the home, but no answer.
    And after ?
    A step-by-step method will help me a lot!
    thank you very much in advance
    jp

Hi jppmedia,

can you format the code, so it is displayed properly? (like in my post above)

What do you want to do exactly? And what do you mean with “I see volumio2 in the home”?
In HA, my volumio-mediaplayer is displayed like this (i clicked on the three dots before taking the screenshot):

(Sorry for my English, I’m French it’s google translating)
I meant in “Home Preview” as in the previous screenshot.

The same thing as you ! play, stop, pause, playlist, photo, name of artist, etc …

does your configuration.yaml looks like this?

media_player:
  - platform: volumio
    host: 192.168.0.185
    port: 3000

I really wonder, why you don’t have any controls…
but you can access the volumio web-gui at http://volumio.local/?

thank you ! it works ! it was not necessary to put “http: //” in front of my ip. Great, thank you !