Compile and use executable to control heatpump through HA

Hi,
Im trying to to control my heatpump through HA. No integration exist but there is a project on github with source for an executable that will connect to the heat pump (GitHub - strandborg/AlsavoCtrl: Alsavo Heat Pump control application).

Is the any way to compile the program inside the virtualbox where HA is running? or what is the easiest way to build this executable?

I run Home assistant OS in a virtualbox on an old windows10 computer.

/Kasper

+1 on this functionality!

That program is written in C++, so it first has to be converted into Python, after which it has to be converted to a Home Assistant Integration: Creating your first integration | Home Assistant Developer Docs

I have been researching if an existing integration is actually a rebranded Zealux heatpump. If so, that integration should also work with any other Alsavo Pro-compatible heatpump. But so far I haven’t been able to find one :frowning: .

Thanks for replying.
Converting to Python is far beyond my non-existing programming skills. But it got me thinking.
Im hoping to compile it as a ubuntu executable and have home assistant send commands using command line sensor: Command line Sensor - Home Assistant

My next experiment is to try to install ubuntu + whatever needed in a virtual machine and compile it there, then copy the executable to the HA server (also running in ubuntu virtualbox on windows).

I will get back with results from the experiment.

I got it compiled and working on Ubuntu. However, I thought it would be possible to execute the program from the HA bash shell. But its not.

Any ideas for how to run an ubuntu executable in the HA somehow?

I helped a friend to compile alsavoctrl on home assistant OS a month ago. Here’s my notes, which might help you.

  1. Log in to the home assistant shell
  2. Check out the source code (or copy the files to a folder)
  3. Edit loguru.cpp: change LOGURU_STACKTRACES in line 97 to 0
  4. apk add cmake make musl-dev build-base linux-headers curl-dev
  5. cmake --clean-first -DCMAKE_EXE_LINKER_FLAGS="-static -Os" .
  6. make

This should produce the binary that can be used in home assistant OS.

2 Likes

Thanks a lot!
I followed your steps and it worked like a charm.

Checkout from GitHub:
git clone https://github.com/strandborg/AlsavoCtrl.git

Usage:
./AlxavoCtrl -s serial -l pass [conf_idx] [value]

Value is temp in celcisus X 10, so 39 degrees celsius is value: 390

To set temp to 39 degrees:
./AlxavoCtrl -s serialnr -l password 1 390

1 Like

Why would you need to change LOGURU_STCKTRACES? It is commented out, so it’s not used anyway.

Where is LOGURU_STACKTRACES commented out?

Ah, nevermind. I am used to seeing Python and C code, not C++. So when I saw the # in front I interpreted that as a line that was commented out, but I see now this is a feature of C++.

1 Like

Hi, I am not skilled enough for fully implementing all this. But I am thinking, wouldn’t it be easier, in a first step to have it running on a docker container, and have it publish and listen via mqtt as suggested here MQTT publish and listen · Issue #7 · strandborg/AlsavoCtrl · GitHub ?

I would love to help as much as I can on that…

Then it is reltively easy to run a container as an add-on through HA supervisor and even add HA mqtt autodiscovery. But that is more the icing on the cake.

Thanks a lot for the pointer. Ill get back after looking into this.

1 Like

Great. I have a lot more handle on the mqtt broker and home assistant side of things if you need help. I see this could potentially take a very similar form as lordmikes work here: GitHub - LordMike/MBW.BlueRiiot2MQTT: Utility to map between Blue Riiots pool API, and Home Assistant MQTT

Hi,
Went great all through 4. But then at 5. I get:
CMake Error: The source directory "/root/--clean-first" does not exist.

I suspect this is basic linux, and I am ignorant. Please let me know if there is an obvious reason for that ?

Check that you are in the the AlsavoCtrl directory when executing the commands?
I just tested in a new dir (i use vim to edit the file):

mkdir test
cd test
git clone https://github.com/strandborg/AlsavoCtrl.git
cd AlsavoCtrl/
vim loguru.cpp
apk add cmake make musl-dev build-base linux-headers curl-dev
cmake --clean-first -DCMAKE_EXE_LINKER_FLAGS="-static -Os" .
make

Hope this helps.

1 Like

I see now you miss a [.] in the end of the line.
it has to be:
[cmake --clean-first -DCMAKE_EXE_LINKER_FLAGS="-static -Os" .]

copy everything between the [ ]

1 Like

Yup… worked perfect then thanks ! Now I can run AlsavoCtrl just fine. Thanks a lot !

Glad you got it working.

I havent managed to run the command from home assistant as a command line sensor or shell_command.

But, I got Node-RED to execute the command using the exec function. So i have a flow that sets heatpump temp to 40 degrees if the water temp is below threshold and set the heatpump temp to 34 degrees if not. Works well and stops the heatpump from overshooting the target when just filtering the water.

Now I need to find a way to parse the data from the heatpump. I believe Node-RED can help, but havent tried yet.

Great idea with Node Red !! I manged to run the command as well and parsed the string in individual JSON items which I am now sending every x seconds to MQTT.

Then from them I will create template MQTT sensors and a climate device.
I need to work more on the subscribing of MQTT to control from home assistant, but should be feasible !

Thanks again for this idea

Quick question, what command will turn on/off the heatpump ? Like how does one use the bitmask 1 and 2 ?

you can turn it off using
./AlsavoCtrl -s xxxxx -l yyyy 4 5

turn on:
./AlsavoCtrl -s xxxxx -l yyyy 4 51 (turn on in auto mode)
./AlsavoCtrl -s xxxxx -l yyyy 4 52 (turn on in cool mode)
./AlsavoCtrl -s xxxxx -l yyyy 4 53 (turn on in heat mode)