GeoTherminator, remote UI for Thermia geothermal heat pumps

We have geothermal heating at home, using a Thermia Calibra 7 pump. The pump has an online feature, but the UI is not really optimal for seeing the status of several sensors at a glance. So at my company’s hacking weekend this year, I decided to write such a UI. It’s very rough around the edges (of which there are many) and very minimal, but I had such fun making it that I wanted to share it.

The code is at Mikko Ahlroth / GeoTherminator · GitLab. It uses Phoenix LiveView to basically render a big SVG (that I drew in diagrams.net) and live update it with the new data. It also has two friendly buttons for changing the target room temperature (which are slow as molasses due to the online service being slow to access the pump). The UI is very “engineer”, I’m no designer. :003: Here’s an example:

I have it running on a Raspberry Pi at home, with an old phone serving as the display:

(Not final placement, just some prototyping.)

The Thermia online service has no public APIs that I know of, so I reverse engineered the HTTP calls sent by the browser. Sadly that also means the app requires a username/password pair to grab the authentication token. I could refactor it to only ask for the username/password on startup via the UI and not store it anywhere, but that’s something for the future as I don’t mind it myself.

In the future I might add some informative graphs, but that would require getting a bigger display. If I can score a small HDMI display somewhere, I can run it directly off the Raspberry without having a phone in the middle.

Disclaimer

Your pump and home are at risk! Do not trust anyone with your account username and password. If you do not understand all the code contained in this software, do not use it. If you do not understand how to compile and deploy Elixir projects, do not use this. Honestly, just use the online service. That way you can’t break your pump and void your warranty.

9 Likes

Oh, an interesting thing I bumped into while writing it. The Mojito HTTP client would add a transfer-encoding: chunked header to the request behind the scenes. This made the Thermia API barf a 502 error for everything except the login endpoint. Really took me a long time to find out as I couldn’t see that header by inspecting my request, I had to install mitmproxy to debug what was going over the wire (now thinking back, I could have probably IEx.Pry’d it somehow?).

In the end I switched to Finch which didn’t send that header and everything started working again. :man_shrugging:

1 Like

This is very cool Mikko! Tho I am not sure what is cooler, that you did this in Elixir or that you have geothermal heating :003: Bravo on both counts :023:

1 Like

Geothermal heating is more and more popular here because it uses a lot less electricity than resistive electric heating and you’re not tied to the district heating network.

It’s good to note that it’s not the kind of geothermal where heat just bubbles out of the ground and comes from the Earth’s core like in Iceland. Here you would have to go kilometers deep to get that. Our thermal well is 140 meters deep and it’s instead the sun’s heat that is absorbed into the ground during the summer that is then used with the pump during winter. So it’s essentially indirect solar energy. I guess sometimes it’s called ground heating?

1 Like

nice one!

you could even try to run everything on the android using elixir-desktop · GitHub

2 Likes

Agree on that, really cool.
Reminds me of the biggest heat pump fan in youtube

1 Like

My Raspberry Pi that I used to host this app on just ate another memory card. So I decided to adapt it to an elixir-desktop app that I could run directly on the phone. Just ran it the first time: https://twitter.com/AmNicd/status/1563253296101756929

Thanks to @dominicletz for the awesome library. :heart: Now I need to clean it up and commit to git.

5 Likes

I’ve finally refactored the code a bit to ask for the user credentials instead of them being built into the APK. It also has CubDB for storing credentials and what view to restore the app to when it restarts (very dirty implementation).

Here it is deployed in the target environment:

3 Likes

Some time ago, the Thermia Online API was changed and this broke GeoTherminator. The login API was changed from an easy one to a devil’s Azure B2C API. Since I had to fix the app anyway, I thought I might as well learn Gleam while I’m at it.

So GeoTherminator is now running as a mixed Gleam and Elixir application! I just got the first working build running on my phone. I guess elixir-desktop could be renamed beam-desktop now, @dominicletz. :wink:

You can still find the sources at Mikko Ahlroth / GeoTherminator · GitLab, but be warned, the Gleam code is quite undocumented and probably unidiomatic, as I’m a total newbie there. On the Elixir side, all I had to do was replace some structs with records and type up their defrecords to match the Gleam data types.

I plan to continue gleamifying the rest of the core code. Then I might take a stab at seeing how far into the Phoenix web stuff I could reach into with Gleam, but I can’t promise too much because I already have other things in the pipeline (and a long Steam backlog!).

If you have any questions, I’d be happy to hear them!

5 Likes