Volumio music player integration

Has anyone tried to write an integration app/driver for Volumio? Similar to the HEOS integration, it would be convenient to trigger devices/modes based on the state of a Volumio player. I know Volumio has an API, though I have no idea what's involved in utilizing it. https://volumio.github.io/docs/API/API_Overview.html


UPDATE: I ended up writing a driver to interface with the Volumio REST API. I couldn't get the webSocket version to work, but this does what I needed it to do.

Driver updated to use the Volumio push notification system instead of polling.

1 Like

At this simplest level, you should be able to trigger the commands identified under the REST API using Rule Machine. Hopefully others can provide specifics.

I would need a custom driver to communicate with the Volumio server and make it visible as a device, though, right? Then I'd be able to interact with it using rule machine, etc.

I'm no expert (understatement) but I was wondering if you could send the necessary commands, to the REST API using ordinary http statements.

This thread may help: Consuming Rest API - #5 by erktrek

One of the first things I did on Hubitat was to setup motion sensors to trigger cameras that were connected to an iSpy server. I was able to do this by using Rule Machine to send http strings to the iSpy server (these included a command, like "snapshot", and a camera identifier (number)). It worked great but it was quite a few years ago and I have forgotten the details. This seems like a similar case.

Neat. I'll look into that.

My main thing is I want to have Hubitat push a URL to some tablets around the house when Volumio starts playing.

Update - I figured out how to query the Volumio REST API. Unfortunately, it returns data formatted as JSON, and Hubitat is unable to store or parse JSON data into a string. I tried using both variables and local files, but both refuse to store anything. I'm continuing to investigate, but any suggestions would be appreciated.

Updated the OP with a driver link.

Hi there - any idea how I would play a radio station from my web radios. I assume I need the URI but not sure how to get that. Thanks for making this driver - very handy.

The Volumio API is capable of processing browse, search, and play commands, but I haven't implemented any of those into the driver. Feel free to fork the driver, or I can try implementing them when I have some free time.

Are you wanting to use a Hubitat rule to start playback on your Volumio device? Or are you just looking for easy control of Volumio from a wall tablet without having to launch the Volumio app every time?

If it's the latter, I've had good success using the Volumio plug-in called "Now Playing". This runs a small webserver on the Volumio box with a simplified UI that displays well on small screens and gives access to all of the playback features, including browsing.

The former. I want to be able to automate the start and stop of the player. So when I select Zone 4 in the house, Hubitat can tell Volumio to start playing one of the radio stations.

However, the latter is interesting as well. Won't solve the first problem but it would provide me with a way to expose the interface to folks in the house through the touchscreens and provide them with other options. So thanks for suggesting it.

I'll see if I can update the driver for that use case. Might take a bit though.

Thanks.

EDIT: please see the pull request on github

I'm pretty excited to find this, thank you for writing the up driver. I just found this thread this morning and I'm eagerly awaiting getting home to set up and test it.

However, i would like to ask if, ideally, i could setup time based events to tell volumio to play a specific playlist or switch to an internet radio station saved in the volumio favorites.

Does the driver support actions like this yet or is it just basic play/pause skip actions?

I'm hoping to set different soundtracks and lighting themes throughout the day.

@simon4 @Ashrond
v1.04 of the Volumio Integration driver is live.

This version adds the ability to play a specific track using the track URI. I also added the URI for the current track as an attribute in Current States to make it easy to find. Use "Play Track" to replace the existing queue and play automatically, or "Set Track" to add a track to the end of the current queue. For both commands, enter the URI or use rule machine to call the command with a variable. This also works for Spotify playlist URI's, but does not work for Youtube for some reason.

The driver also now retrieves a list of Volumio playlists (thanks for the pull request Ashrond) and shows them in current states. Also added a command to play a specific playlist. Note that rule machine is not able to see device state variables, so in order to pass the list of playlists to it, I had to put the list in a device attribute.

I did some basic experimenting with rule machine. It is able to retrieve the list of playlists from the device attributes, chop it up into local variables using tokens and pass one of them back to the Set Playlist command. This is obviously basic, but should be usable in Mode rules or other automations too.

Let me know if you find any issues with the new version.

Naturally, as soon as I hit "submit", I find an issue. 1.05 is now live.

Play Track and Set Track now work for Youtube and also web radio. I added a required field for music service to these commands, because apparently Volumio can figure out the correct music service for Spotify, but not for other music services. The music service was already being reported, so all you have to do is have rule machine grab it alongside the URI.

The title field is optional. For Youtube, Spotify, etc, it will be over-ridden, but for web radio, it won't show the station name in the queue unless you type it in. Side benefit - you can make the title of web radio stations anything you want.

These commands also work for Youtube playlists, btw.

Thank you for putting that together,
Would you mind giving me a high level on how you got rule machine automations setup to switch playlists? i am having some issues with getting the playlist change automations setup. my best attempt in rule machine resulted in an error on missing method exception and wanted to verify my methods before i start digging into directions i might not need to.

thanks!

Can you send me a screenshot of the exception from the log? Also, what music service are you using within your playlist?

This works for me with no java exceptions in the log.

thank you for the pic, it was enough to get me to take a second look at how i was configuring the rule, I was not using the correct type. before I was trying to use "set track" and populating the playlist name as a value, which was generating the error.

now i am running the following, which seems to be working with one issue;

how do I set it to randomize the playlist when setting it to play?

also, I might have found a bug, maybe...
I previously had a "beta" version of the driver I had continued to modify after the gitpull request was submitted. among other things, it populated a dropdown list with the playlist data (which I think we should pull into this driver) but I noticed that when I switched the device driver to your new 1.05 version, it was populating playlist names here;

however, I had the idea to rename my playlists for (REASONS!) to make sorting them into times easier. I noticed that the populated playlists did not update after the changes were made in volumio. So I removed and re-added the device, with a reboot of the hubitat in between. re-added the device, initialized and refreshed ect. still no playlists being displayed. I am not sure if this is an actual bug, or if it is an artifact of my previous beta driver, or something else. However, it would seem to be more usefull to have the playlists displayed in the driver either written out or in a drop down, so I thought to mention it to you, even though i am unsure of the root cause at this moment.

all I can say is that for the time being, short of not having the playlists randomized (prevents monotony), the automation to change playlists is working beautifully so far today, thank you very much! :smile:

Looking through the Volumio API guide, randomizing a playlist before it plays doesn't seem to be possible.

I tried setting randomize on before calling setPlaylist, but it still starts the list with the first track in the playlist. I also tried calling setPlaylist, immediately followed by nextTrack and by pause, then nextTrack, but it's not fast enough and still starts playback on the first track for a half-second before switching. There doesn't seem to be a documented API command to add the contents of a playlist to the queue without automatically playing it.

A less than elegant way to do this would be to always start your playlists with a 2 second track of dead air so that would begin playback first, then have rule machine set random on and call nextTrack. The effect for the listener would be to play a random track from the playlist with a short delay. The downside would be sometimes the dead air track would play as the playlist progresses.

I'll change the toggleRandom and toggleRepeat functions to accept a parameter of "on" or "off" so the state won't be ambiguous to rule machine.

1 Like