After you complete the setup, using Alexa to control your squeezebox is as easy as giving her simple voice commands. Today, commands achieve simple tasks but they will become more sophisticated as the project matures.
The quick version
You say "Alexa, tell Squeeze Box to play"
Alexa passes this command to the plug-in that runs on your Logitech Media Server (LMS)
LMS starts playing the music you have queued up on your Squeezebox
The longer version
This project has several components:
- Alexa Skill
- Skill > plugin communication
- LMS plugin
1. Alexa Skill
Alexa is a voice-driven 'digital assistant'. Your Alexa hardware (echo, dot, tap) allows you to access services over an internet connection. Software developed for Alexa is called a Skill. Skills don't run on your hardware – all the action happens in the cloud. The hardware simply transmits your voice to the cloud where it is interpreted by Alexa who actions a Skill.
Therefore, you need to say "Alexa, tell Squeeze Box to play". If you just say "Alexa, play", she will play her default music channel or the last podcast you were listening to. Telling her ‘Squeeze Box’ means she directs your command to that Skill.
(though recent advances in the skill mean that now, once you have initialised the Squeeze Box skill, you can issue some commands directly, eg 'Alexa, pause', provided that 'Squeeze Box' remains your last used skill).
It’s important that Alexa only has access to your squeezebox! When you enable the Skill for the first time, you will be asked for a username and password. These are your hab-tunes credentials. Each time you use the skill, Alexa validates you and your command against the hab-tunes database of known users and commands.
3. Skill > plugin communication
The skill sends commands to your LMS using the MQTT protocol. This data is posted as a ‘topic’ on an MQTT broker server. More on the basics of MQTT here.
Topics are unique to a user (for example /habtunes/JohnJones) and, again, only accessible after verification of hab-tunes credentials.
Note: MQTT doesn’t send anything directly to your network. If it did, you would need to open your network to the internet which is a bad idea for many reasons. The plugin also supports such direct communication but this is available as a fallback and is not the recommended configuration.
4. LMS plugin
The Alexa plug-in runs on your LMS. It listens to (or is 'subscribed' to) your MQTT topic (/habtunes/JohnJones).
The plug-in pulls any changes to the topic and passes new commands along to LMS. The data posted in the topic is directly executable by LMS, so no further translation is needed, though the data is parsed and validated for security purposes.
In current testing, commands take around 1 second from voice command to LMS execution (AWS is based in Ireland for this project, with measurements taken from west coast of the US).
Once LMS has executed the command, it publishes data back to the skill over https (http if SSL is not available on LMS host platform). The return data is picked up by the skill and sent back to Alexa in the form of a speech/card response.