The Node is an audiophile streamer, that you can connect to any existing stereo system. That's the advantage, as you can use whatever your setup you so much painstakingly put together, adding modern, high quality streaming. However, the convenience is hampered by the need to switch on/off the amplifier. This automates the task, by detecting when the Node is playing or not and accordingly switching the amplifier. Additionally, I added some simple commands for Amazon's Alexa to be able to pause the music, skip to the next song, or back.
This project builds on and enhances on previous projects I did, and please refer to those for detailed explanations and instructions:
- The Alexa serial controller https://www.hackster.io/saka/alexa-voice-control-for-almost-any-amplifier-tv-cd-dvd-87fff1
- Sonos controller https://www.hackster.io/saka/sonos-controller-with-wemo-switch-and-alexa-echo-speech-16a794
I have an amplifier with 3 inputs:
- turntable
- Node
- Alexa (for convenience, when it is more important for me to quickly ask to play something than quality).
I have built a controller for the amplifier, see the description of the project under the link I posted in the intro. The controller helps me with functions like turning on the amplifier, changing volume, etc. through Alexa voice control. However, I realized that when using the Node, even if I don't have to look anymore for the remote, still there are two separate functions I need to do perform: ask Alexa to turn on the amp and use the BlueOS app to select the music I want to stream. Previously, I built a Sonos controller and using some principles and modified code from that project, I was able to completely automate the functionality; now it's enough for me to start playing a song on the Node and the amp turns on automatically. While I was at that I also added some simple voice control, I can ask Alexa to e.g. skip to next song.
Bluesound apparently does not support APIs. However, I found a post on a forum with quite detailed description: https://helpdesk.bluesound.com/discussions/viewtopic.php?f=4&t=2293
I did not test them all, and seems there are some changes (e.g. at least when playing on Spotify, the status is "stream" not "play". Overall, just works for for the purpose of the scope of this project.
Changes to LambdaThis project relies mainly on firmware in the Particle, which is documented in the next section. In principle, one could not touch at all the Alexa functionality, as this project could be thought as orthogonal to that one (apart from controller hardware, that's shared). However, if you want to kill two birds with one stone the cherry on the cake is the ability to use Alexa for few simple commands, like going to the next song. With such evocation, the Lambda code triggers a new function on the Particle ("Node").
else if (namespace === "Alexa.PlaybackController") {
krellSerialCommand = event.directive.header.name
name = krellSerialCommand;
funcName = "Node";
}
In order for the above to work, it is necessary to also modify the device discovery by adding the Playback controller:
{
"type": "AlexaInterface",
"interface": "Alexa.PlaybackController",
"version": "1.0",
"supportedOperations" : ["Play", "Pause", "Stop", "Next", "Previous"]
}
I have additionally done a change, where instead of creating one device, I effectively copied the discovery for each input on the amplifier, with different names ("Record Player", "Music Player, "Stereo"). This is a small twist but again enables to save one step by evoking a specific device, the amplifier input is also accordingly adjusted. That change is in turn utilized in the Particle firmware (where instead of just passing the command for on/off, I append to which device it refers to (e.g. "1PWRZbluesoundOn"). This is however optional, so I'm not copying the Lambda code for it.
Particle firmwareThe full code is saved in this project. Few explanations.
byte nodeIP[] = { 192, 168, 1, 182 }; //put your Node_IP_address
Here you need to change to the IP address of your Node. You can find it in the BlueOS app under Settings/ Diagnostics. You also need to go to your router and make sure you assign the address as a static one; each router would have different menu for it but likely you find it under DHCP settings.
Otherwise, main routine it to check every 1 second what's the status on the Node. The controller send the inquiry http://192.168.1.182:11000/Status, and looks at the response between <state> and </state>. If it detects a change to a previous states, it acts accordingly, by e.g. switching on the amp if the state changed to "stream".
The function controlNode:
int controlNode(String command)
{
if (command != NULL) {
if (command == "Play") nodeCommand(nodePlay);
else if (command == "Pause") nodeCommand(nodePause);
else if (command == "Stop") nodeCommand(nodePause);
else if (command == "Next") nodeCommand(nodeSkip);
else if (command == "Previous") nodeCommand(nodeBack);
return 1;
}
else return -1;
}
Is the one called by the Lambda function, triggered by Alexa (as described in the previous chapter).
Comments
Please log in or sign up to comment.