inkyFrame + golang for TFL API and Home Assistant info

Search for a command to run...

No comments yet. Be the first to comment.
I wanted to write a blog post about XTRadio for a very long time. I finally have the time, so let's start with a short but sweet post which explains how everything works, how it all fits together. What is XTRadio XTRadio is an online radio station wh...

I’ve continued to play around with the K3S Beta cluster from Civo Cloud (you can request to join the beta), the aim was to also try out the new Traefik V2 which was released some time ago. In this post we will: Update the default traefik install on ...

This article is out of date. In this post I wanted to showcase how you can get the traefik dashboard enabled on the default civo cloud kubernetes k3s cluster. (It’s currently in beta, you can request access here). I must add, I’ve only played around ...

Just a small snipet on how to send data to TuneIn’s AirAPI from golang. This way you can update your metadata information directly from your API, if you wish. import ( "fmt" "net/http" "net/url" "time" ) func tuneinAPI(artist string,...
It’s good to know when the next bus is coming, what the weather is like, what’s your next calendar event, etc.
it’s also cool to not look at your phone all the time (at least for me it is).
Enter InkyFrame!
A 5.7” E Ink display from Pimoroni - product page.
The InkyFrame runs micropython as it has a Pico W board integrated into it, with this you can manipulate any type of data you get. Official example repository to see some bits.
Fun fact, it takes ~30 seconds to render the display, this needs to be factored in, it will never be real time data you’re displaying.
For those who have done this before, the answer on what you do next is fairly standard, you need an API to call, to work out what you need from the API and you render it on the display. Pico W has a wireless chip as well, so all the data goes via your 2.4GHz WiFi.
Pulling down a load of data from various APIs, who knows how many, may become problematic on a Pico W, memory is a problem, but you do have an SD Card, so you can store data on a local disk and iterate over that.
But, I’ve seen something interesting over at https://github.com/jinglemansweep/inky-frame-web - basically it’s a photo slideshow solution for inkyframe, so I started thinking, what if I create an image with the information I need and then I just need to download the image and render it. This would allow me to have a separate piece of software where I can iterate over the information I need, I don’t need to constantly deploy to the InkyFrame (and connect it via USB every time I need to do this).
So that’s what I set out to do.
I’ll be honest, I wanted to write some golang, which made this decision even better for me personally. The idea would be:
Create a golang web app
Create an image
Overlay all the information from the APIs on the image
Serve the image
Pull the image from InkyFrame and render it
I was insipred by https://github.com/daniruizcamacho/image-generation-example as I’ve never done image generation before.
I started with the London TFL API which is a REST API, it was not easy understanding how I can get the exact information I need, but I was basically going for:
Next up was some weather information, given I’m already running Home Assistant, I do have weather data, so all I needed to do is understand how to call the Home Assistant REST API.
The last piece of information was calendar events, since this is also integrated into Home Assistant, it’s the same mechanism.
The web app is a docker container hosted within my network, so I can easily get to Home Assistant APIs and also the InkyFrame can download the image as well.
It’s rough, it’s ugly, but it works. Here’s a rendered image:

I’ve added a timestamp at the bottom so we always know what was the last update time.
The rendering runs on a 5 minute loop, it takes around 30 seconds to render the image, so you always need to factor that in.
On the device it looks like this:

I wanted to use something other than github for this piece of work (and for some of my future bits), so I decided I’ll give codeberg a try, I highly recommend it for any open source work you may want to do. It can store your packages too, so it also serves as my container registry.
Repository: https://codeberg.org/puck/inkyframe-golang-web
Oh boy, where do I start, here’s some of the things in my head:
Actually try and see if I can loop over a JSON API via micropython as then I have some cool built in options to render the text
Start using the 5 buttons on the inkyFrame for different views
Add more information from Home Assistant
Rework the code and write tests
Implement auto-deployments
If something fails, write the error message on the inkyFrame display (things can go wrong once in a while)