So, for some time I had an idea for automating the restarting of my router via Alexa. The normal solution of a cheap, off-the-shelf product to add a relay onto the router won't work. As the Alexa voice processing happens in the cloud, as soon as the relay turns off the router, the Echo device will no longer be able to issue commands to the relay device. You can't say the subsequent "Alexa, turn on the router" after you've turned it off.
Hardware
My solution was to use one of my Raspberry Pi's capabilities to run a local script to control a relay. I originally was going to use a two-relay board to have one outlet for my router & one for my Sony Blueray player. The Blueray player is used primarily to watch Amazon Prime & Netflix & regularly misbehaves needing a hard boot (unplugging it). However, since my initial concept, my requirements have changed. Important to the relay options is the fact that I moved to AT&T Gigabit Fiber. This is NOT a review of that service so I won't go into details. There are things I'm happy about with it (the speed) & things I'm not (the hardware). As with many branded routers from carriers, it has its issues still needing occasional reboots. That is fine, but I now have a media converter on my wall to convert the fiber coming into the house to copper to connect to the router. This, though rarely, also has needed occasional power cycling. I needed more relays than two & upgrade to this
basic 8-relay unit I found on Amazon. (Not an affiliate link) It works perfectly with my Pi so has been a breeze.
 |
| My old Raspi B+ in the background & my messy desk. |
Software
Secondly as far as my circumstances go, I've gotten tired of the instabilities of my old Raspberry Pi B+ & moved to my Raspberry Pi 3 B+ AND Python 2 has pretty much been discontinued for Python 3. Now, I have to admit that I went the quick & easy route on this project & utilized the
n8henrie's Fauxmo project. This project that I linked to is a fork of the original
Maker Musings Fauxmo Project that migrates it to Python 3. Fauxmo is so named as it emulates the Wemo communications protocols for the Belkin Wemo line of home automation devices. Eventually, for practice & adding security, I'll migrate to a custom Alexa App, but for now, this allows me to get the project up & running quickly.
I essentially used the Fauxmo JSON config file to point to a local custom script written in Python 3 to execute my commands. The entries in the config file are only the active entries & their names match up to a Python dictionary in my local script to reference the appropriate GPIO pin corresponding to each individual relay. For now, there are just the entries of "router," "blueray," & "gpio18" in the JSON config file while the local script has the following:
gpio_ports = {'router':3,
'mediaConverter':5,
'blueray':7,
'blrySignal':8,
'gpio18':10,
'gpio19':11,
'gpio20':12,
'gpio21':13}
As you can see, each entry points to the gpio port in use for the corresponding relay. The "blrySignal" was a test idea that didn't work out so, I haven't renamed it yet but it will be going back to a gpio reference. I'll put up more information on this build shortly. The hardware is basic though I plan on building a very nice (hopefully) enclosure, but I'll go into more details about the software setup.
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete