Skynet
The house I’m renting has skylights and electric shades in every bedroom which gives you some options for how much light to let into the room at any given time. Even better, there are remote controls for opening and closing the shades. The problem is that the IR receiver for the remote controls is in the hallway along with the “manual” buttons which doesn’t do much good if you want to operate it without leaving the room.
I figured now was as good a time as any to finally set something up to make it more convenient. I ended up using a Raspberry Pi Zero W set up in the hallway to send IR commands to the receiver. It hosts a REST API and React frontend on the local network so anyone on the network can operate the skylights. All of the gory technical details can be found on GitHub.
Overall I’m very happy with how everything turned out. It was fun working in a different environment with different tools and constraints. Of course, the process was far from smooth because most of the docs around the IR shield and LIRC were out of date due to some changes in the kernel last year. I ended up not using LIRC and recorded/replayed raw IR signals using gpio-ir directly which works great for my use case but potentially not for others.
So now I had a REST API and frontend but I wanted it to be even easier to control via my phone. I discovered HTTP Request Shortcuts which allows you to configure home screen shortcuts to send HTTP requests. It was super easy to set up and has been working flawlessly ever since. Well, it was very straightforward but was still tedious to type in HTTP requests on a phone keyboard.
The final piece of the puzzle was connecting it to my phone alarm so the shade will open when my alarm goes off in the morning. My original plan was to run something on the Pi to poll for alarms from my Google account but I was unable to find an API to list alarms. As far as I know they are synced somewhere but it may be as Android application data rather than an official user facing Google API.
I instead found Tasker which is a general purpose Android automation app. Setting up the HTTP requests was straightforward just like the app shortcuts. However, I had a lot of difficulty with the alarm integration. I selected what sounded like the correct trigger for an alarm but it didn’t work. I tried a few other alarm triggers just in case but those didn’t work either.
This is where things get pretty fuzzy because I didn’t do a very deep dive on Tasker. Eventually I stumbled upon AutoAlarm which is a Tasker plugin that allows you to set a global variable with the time of the next alarm. That imported a very lengthy Tasker task to keep the variables up to date but I quickly discovered that it doesn’t unset it when the alarm is disabled. I worked around that by running the task periodically to reset things in case the alarm was disabled or an update was missed somehow. Finally, this allowed me to close the loop and open the skylight when my alarm goes off!
However, this isn’t without its shortcomings. First, while Tasker is a very full featured and flexible app, the user interface was infuriating. There were many unintuitive interactions all over the app e.g. the back button pops a Toast rather than going back so you have to find the back button on the top right of the app. All the while, there were near constant modals with tips and warnings about settings that I should change e.g. turn off battery saver, no active profiles, notifications prompting the user to disable them entirely. I understand that this is a power user app but it still makes me appreciate the polish on the apps I use day to day.
My final gripe with Tasker is that the OS constantly displays an alarm for some time in the future even when I don’t have one enabled. It’s often exactly 10 minutes in the future and updates as time ticks on which makes me think that it’s how Tasker does some of the alarm based triggers.
All of these issues gives me the feeling that it’s all held together by shoestrings and can fall apart at any time. Also, Tasker feels like a supercharged V12 engine which is significantly overpowered for my needs. I can only assume that it has negatively impacted my battery usage but I don’t have any evidence to back this up.
I’m pretty happy with how everything turned out. The Raspberry Pi was super great. Sending IR commands took some trial and error but it’s now working out very well. Setting up the REST API was super straightforward. I enjoyed using React for this project but was disappointed by several aspects of it coming from Vue. The Android alarm integration is by far the least successful part of the project so that could use some work eventually.
It’s all open source so feel free to tweak it to suit your needs!