So I imagine many people connect their Echo to a modern Bluetooth speaker which achieves the convenience of always being on and the eco-friendliness of not using much energy when idle. Well, I haven’t got one of those. I have an old JVC stereo which you have to power on manually. Luckily I also have a Raspberry Pi which, as you will know, is able to solve pretty much any real world problem.
I do not want to have to press the power button on the HiFi to hear the Echo.
So you’ve plugged the Echo into your hi-fi (and not even bothered to remove the Airplay device which you never wanted but couldn’t afford Sonos), now what?
You need to use the awesome power of the Raspberry Pi to….control an infrared LED. I admit that controlling a single LED seems a waste of the Pi’s abilities but at least it’s cheaper than forking out for a Logitech Harmony hub.
Don’t have an infrared LED? No problem. Just desolder one from a remote control.
Then follow some instructions on how to get your Raspberry Pi transmitting IR signals.
If you can’t find the Lirc codes for your remote then you can use Lirc to record the signals from your remote. Of course you’ll need an IR receiver to do that. Don’t have one? Just desolder one from a set-top box.
Eventually, you’ll end with something that looks like this:
I should stress that electronics is not my forté.
I followed Amazon’s tutorial on how to create a Smart Home Skill. If you want to do it in Java and need some inspiration then look in my GitHub repository. I’ve even started creating the domain model which doesn’t seem to exist in the Alexa skill jar. ProTip™: When using Java in an AWS Lambda start an instance with a lot of memory so it loads faster.
I did have a problem enabling the skill from the Alexa app on my phone. In the end, I got it to work by using Firefox and pre-logging into my Amazon account (it took quite a few attempts though).
The last piece of the puzzle is to “web-enable” the IR functions of your Raspberry Pi so that the AWS Lambda function can call it. To get going quickly I used a Python project from this guy. You’ll need to create a hole in your home network by mapping a port to the Pi. I will deal with this security issue another day (I don’t want China turning on and off my home electronics).
At this point, I can now say “Alexa, turn on the kitchen hifi”. Convenience achieved.
Bit of delay switching on the hi-fi as the AWS Lambda takes time to start.
I have also considered attaching a PIR sensor to the Pi so that it turns on the hi-fi when you walk in the room.
I often forget to turn off electronics when I go to bed – I don’t want to leave the HiFi on all night
Now that all the hard work has been done this part is pretty simple. The simplest approach I could think of was to use systemd timers to schedule a curl call late at night. One minor issue being that I wouldn’t know whether the HiFi was currently on or off. Luckily sending the ‘AUX INPUT’ command over the infrared switches on the HiFi. So I can guarantee that the HiFi will be off by first sending this command followed by the ‘POWER’ command a few seconds later. This means the HiFi will briefly be turned on even if it was already off but that’s acceptable.
Another way might be to set up an Alexa “scene” so that I can turn off lots of electronics when I go to bed.
For my next project, I need to buy another Echo and another Raspberry Pi so I can control my TV. If a can control my Roku then hopefully I can make Alexa play a movie from my:- Netflix; Amazon; Now TV; Plex services.