Volumio controlled by amazon alexa

i found a much easyer way to control volumio with alexa.
No need for plugins, extra hardware and other hacks.

Basicly i use the IFTTT and the rest api from volumio.
First if you login to alexa.amazon.com an you get send to .co.uk go to amazon.com and set region to US with some us address and postalcode (ny postal code 10001 will work fine). if you now login to alexa.amazon.com you should see the .com url.
For some reason .co.uk is not working on ifttt, and it’ll keep telling your command it not in iftt.

portforward port 80 in your router to the interal ip of your volumio (we’ll get to security later on).
so if you surf on an external computer to yourip/ you should see the Volumio interface.
(make sure not to map from a different port e.g. yourip:8000 , Webhook does not seem to like adding ports to the url)

Create an IFTTT account; create an applet (you now have to allow IFTTT into amazon alexa, a pop up shows up)
IF: search for alexa and tell it to use the e.g. phrase “music on
Then: select webhook and fill in the portforwarded url of volumio eg. http://yourip/api/v1/commands/?cmd=play

Another one could be:
IF: Alexa phrase " music volume up"
Then: webhook: http://yourip/api/v1/commands/?cmd=volume&volume=plus

You can find all api commands here: volumio.github.io/docs/API/REST_API.html
i’ve made commands for: play, stop, next, volume up, volume down, volume 20, volume 40 etc.
so in case of our alexa 1 phrase is 1 command (ifttt doesn;t mind :slight_smile:
in the google home you’d be able to send variables along, alexa ifttt can’t do that (yet)

So…just yell" ALEXA TRIGGER VOLUME UP" works like a charm!

for security there can be 2 things done. I logged the webhook get ip numbers vor a while and added that to the allowed source ip in my firewall.
what i would like to do is add a password in the webservice of volumio so i can send a user & password in the string: e.g. user:password@http://yourip/api … /?cmd=play.

I’ll have to dive into that later on (anyone ever set a password for non local ip’s on volumio like Domoticz has??? )
e.g something like:

AuthUserFile /path/to/.htpasswd
AuthName “Restricted Access”
AuthType Basic
require user [username]
satisfy any
deny from all
allow from 192.168.1.

tip: For “yourip” you could ofcouse better use an dynamic dns like volumio.no-ip.biz if you are familiar with that.
alexa.png

just brillant !

:smiley: :smiley:
Soon time for me to invest in a Alexa!

A voice control of my Volumios would be a really nice feature and a deal breaker and maybe a surrlotion to my real problem some one to help me to discipline my Irobot “Grazynia” :laughing:

You’re genius!
Something must have changed as far as ports handling is concerned, as I successfully managed to set up webhooks with a specified port number (I run a web server so using port no 80 for controlling Volumio with Alexa was out of the question).
I googled IP addresses used by webhooks and added firewall rules. Works like a charm :slight_smile:

Thanks very much!

Thanks very much for this!

I wanted to improve the security so here is what I did:

I happened to have another (old) rpi on my network and figured it could be used as a proxy to add https to the volumio rest api requests.
I got it working really quickly using node js and express.
I followed these instructions:
Setting up an express server: http://www.robert-drummond.com/2013/05/08/how-to-build-a-restful-web-api-on-a-raspberry-pi-in-javascript-2/
Making it run on boot: https://www.instructables.com/id/Nodejs-App-As-a-RPI-Service-boot-at-Startup/
Using https with express: https://timonweb.com/posts/running-expressjs-server-over-https/

Currently the proxy just adds https, later on I plan to start using POST for the requests and add an authentication key to make it even more secure as in this example: https://www.francoisdelport.com/2018/04/integrating-google-home-and-ifttt-webhooks/

Here is my express server code (in e.g. index.js):

[code]var express = require(‘express’);
var fs = require(‘fs’);
var https = require(‘https’);
var request = require(‘request’);
var url = require(‘url’);
var app = express();

app.get(’/’, function(req, res) {
res.send(‘Volumio Restful API Proxy’);
});

app.get(’/volumio/api/commands’, function(req,res) {
var urlParts = url.parse(req.url, true);
var query = urlParts.query;
res.send(sendRequest(query));
});

function sendRequest(query) {
var apiurl = ‘http://192.168.0.2/api/v1/commands’;
console.log('Sending query: ');
console.log(query);
request({url: apiurl, qs: query}, function(error,response,body) {
console.log(body);
return body;
});
}

https.createServer({
key: fs.readFileSync(‘server.key’),
cert: fs.readFileSync(‘server.cert’)
}, app)
.listen(8080, function() {
console.log(‘Volumio Restful API listening on port 8080! Go to https://localhost:8080/’);
});[/code]

In this example volumio ip is 192.168.0.2 and proxy is running on port 8080. So your firewall needs to forward requests coming to this port to the proxy. The calls from e.g. ifttt should go to https://{your external ip}:8080/volumio/api/commands
The proxy only forwards the request query string to the commands endpoint, which covers most of the Volumio rest API functionality and that was enough for my needs. Adding functions for ‘listplaylists’ and ‘getstate’ would be quite trivial.

I hope this helps someone! :slight_smile:

Limealot, brilliant.
What about jumping on board with us and helping on myvolumio? If you’re interested send me a mail at info at volumio dot org :wink:

Great, got it to work in a few minutes with my Google Home mini !

Hi !

I can’t seem to get this working? (I have limited knowledge on networking.)

I have set Volumio to a Static IP on my router & tried to set port forwarding but when trying to connect to Volumio on my phone using data the page will not load. I tried setting “Service Name” to Volumio, “Port Range” to 80, “Local IP” to the static IP of volumio & setting “Protocol” to BOTH. What am I doing wrong here?!

Capture.PNG

FIY, we are now in the process of certifying an official integration of Alexa and myvolumio…

OH, Really?! Thats great news… I know devs hate this question but any rough ETA?

Thanks! Been subscribed to MyVolumio since the early beta!

Send me an email and we’ll invite you to the beta :wink: (info at volumio dot org)

Basically, it’s ready. But we don’t know the ETA since it depends from Amazon speed of reviewing our skill…

Will there be Google home integration too?

Sent from my Pixel 2 using Tapatalk