Pi Garage V1.8.0
Pi Garage version 1.8.0 has been released. In this version the mobile app has been given the ability to have multiple configurations saved.
The main driver for this was so that other people who had a Pi Garage could simply give you the configuration details and you could add this as a second (or even tenth). Before this you would have to destructively edit your existing configuration which would be a pain if you had a complex API key.
GCP Ubuntu VM Freezing on Auto Updates
Upon migrating my blog to a Google Cloud Compute Engine VM (this very blog) I had a strange issue where it would freeze and become unresponsive. Only “Resetting” the VM would bring the blog back.
The findings were so interesting I thought I would share them.
Issue
It’s worth noting what the instance is (and importantly what resources it has been allocated) as it probably would not be an issue with a larger (and more expensive) instance. As of writing the instance is set to a “e2-micro” instance located in “us-central1”. The reason for this is you get one free instance in this region when using Google Cloud.
Pi Garage Relay Lock Up
After initial release with the Home Assistant mobile app performing the opening and closing it was observed that quick button presses (from my daughter pressing the button rapidly🤣) that this could cause a lock up of the hardware in a weird way.
You could see the lights on the relay change to show that the control signal to change the relay state was working however you could not hear the “click” of the relay. Other relays worked as expected, it was as though the relays themselves or something got “latched” in the changed state.
Open Source Repository Challenges
Making the project Open Source is a good thing as it allows others to learn from it but also to so that people can be assured that there is no nasty other software that is installed with the application.
However as anyone on the internet can view the source code this introduces complexities that you do not have with a private repository.
One main issue is that you cannot store configuration or credentials in the repository. Every configuration item (say an app store identifier) and credential item (Google Play Store publish token or API key) MUST come from repository secrets.
Pi Garage Realtime Communication
Pi Garage worked well for a while, however there was one thing that bugged me. When you would have 2 devices open on the home screen (in the mobile app) and you would open the door on one device the state would change from “closed” to “opening” to “open” but on the other phone it would still say “closed”.
This annoyed me as to get the latest state you constantly had to “swipe to refresh” to ensure that you had the latest state of the garage door. Not a big deal in the scheme of things but it was a good problem to solve.
Pi Garage Mobile App
Along with the backend part of Pi Garage I really wanted to have a mobile app (both iOS and Android) so that it would be easy for users to use Pi Garage without having to configure a 3rd party app (like Home Assistant) or via an API page (like Swagger).
I have had experience with React Native and found the experience akin to fingernails on chalkboard. I wanted to use something that had a better developer (and maintainer) experience.
Pi Garage Deployment
The next decision to make was how to deploy the backend application. I had many different ways that I could release the application. However there were some key considerations to make.
- Ease of deployment (especially for target audience)
- Versioned releases
- Ease of rollback?
This lead me to consider the following.
NPM Package
As the backend is built in Node.JS it would be easy to just push the built packages to npm. Although this would get versioning and rollback I thought that this would be a pretty 💩 experience to deploy and run it.
Pi Garage Backend App Framework
As I had chosen to use a Raspberry Pi for the hardware this allows me to use any language and framework that I want as long as the Raspberry Pi supports it. To view the current Open Source code can see it here on GitHub.
I new that I wanted to write the app in Node.JS (my favourite) and to make my life easier I commonly use the application framework NestJS. This opinionated framework which is heavily inspired by Angular and it’s structure (and cli) allows you to build all sorts of applications quickly and easily.
Pi Garage Interface Board
For interfacing with the garage door I knew (from my one) that there was the ability to add a wired push switch to the garage door to “toggle” it. However I had no idea what voltage/current this used as it was not listed in the manual. I also knew that other garage doors would potentially have varying specifications regarding this. This meant I needed to find someway of using a relay with the Raspberry Pi instead of just using the GPIO straight to the garage door (in case of blowing up the Raspberry Pi).