Bedside Pi: Hue Light Controller with 7″ Touchscreen

A couple of years ago, I built a little Kubernetes cluster using 4 Raspberry Pis. While I learned tons about K8s doing it, the cluster wasn’t reliable over the longer term. I only budgeted for one SSD (for the cluster master), and the SD cards in the other 3 Pis started to become unreliable after a few months. While I started cannibalising some of the hardware, the Pis themselves were gathering dust. Well, only 3 of them are now…

I bought a 7″ touchscreen (which seem to be in very short supply at the moment), and paired it with the matching enclosure which is linked to on the official site. I decided that I wouldn’t try to design my own model for 3D printing, having made a bit of a mess of it the first time round.

I’ve spent the last few evenings writing some code for it based around the CustomTkInter library, which is really nice. The ability to put things on the event loop using .after() is perfect for light control – e.g., polling the light state every 10 seconds to check for something other than the UI having switched them on or off.

I repurposed the same code I used for the eInk display to have persistent access to Google Calendar. I’ve not seen this widely documented but it’s pretty straightforward:

  • Create a project in the Google Console.
  • Create a service account
  • Export the private key of the service account. Given my day job, I feel obliged to say this is not good practice, but the alternatives rely on using some industrial authentication infrastructure which really isn’t going to be a whole lot of fun to run at home.
  • Add the service account to have access to your calendar.

While my choice of RSS feeds and button names is unlikely to be wildly interesting, the code is here.