Sometimes you just want to get something done. Something for yourself.
You do not intend it to be reused, or even pretty.
You build a tool.
My tool was a photoframe with some basic overlays. I wanted the family calendar, some weather information (current temperature + forecast), time, and the next bus heading for the train station.
To make this acceptable in a home environment, I built it as a photoframe. You can find the sources in the hassframe-ui repository on my github.
A hidden feature is that if you tap the screen, a home automation control panel slides up. That way you can control all the lights, as well as heat in the garage and an AC in the bedroom. Very convenient.
All this is built using QML. Three somewhat useful models are available:
- IcalModel, taking a URL and parsing whatever it gets back as ICAL data. It is a very naive parser and does not care about things such as time zones and other details.
- YrWeatherModel, uses yr.no‘s public APIs to pull out a weather forecast for a given location.
- ButStopModel, uses the APIs from resrobot to look for departures to the train station from two bus stops close to my home and then merge the results into a model.
I also have a bunch of REST calls to my local home assistant server. Most of these reside in the HassButton class, but I also get the current temperature from there. These are hardcoded for my local network, so needs refactoring to be used outside of my LAN.
All of these interfaces require API keys of one kind or another – be it a proper key, or a secret URL. These are pulled from environment variables in
main.cpp and then exposed to QML. That way, you can reuse the components without having to share your secrets.
All in all the code is quite hacky. Especially
main.qml. I refactor out parts from there now and then, but the photoframe works, so its not anything that I prioritize.
Currently it runs on a Raspberry Pi on top of Raspbian. I want to build an optimized Yocto image making it less hacky and more pre-packaged. Perhaps there will be a rainy day this summer and I’ll get around to it. Burkhard has prepared the instructions needed over at embedded use.