Hi everyone,
today I managed to integrate my Aerosmart m fresh air heating system into hassio. Here is a picture of the device that takes care of pretty much every task required to keep my house up and running, like providing warm water, warm air in the winter to keep us comfy and cool air during summertime.
Unfortunately, the heating system is not capable of providing its various system variables through either a cloud environment or any other webservice based apis. This is particularily bad when you want to be notified of situations when it is not functioning properly or I did some mistake when switching the air filtering system for summer or winter.
So i started to investigate on the internet to possibly find a workaround for this issue. Please keep in mind, i have zero knowledge of serial interfaces and such. I did find some pages on Github itself that gave me some insight on how the communication with the heating system could be established. For example here, describing an implementation for FHEM.
The manufacturer, Drexel and Weiss, makes some documents available in their download center explaining various technical aspects and also what values can be extracted from their modbus interface.
Funny thing, they provide an addon hardware for Loxone home automation based on a RS232 Adapter.
Overall, everything was too complicated for me and i do not plan to invest into Loxone either. So i made a plan, without knowing whether it would work out or not.
So I had the following parts at home:
Next step was to setup the pi zero with the newest buster image (light version).
I then connected the USB-A cable with the serial port of the heating system and gave it a spin. The zero booted without an issue and i now had the possibility to access via SSH.
Coming back to the python 2 code i found on Github, i played around for quite a while to make these scripts work for my purposes. However, i did not succeed and thought about another alternative. At this stage i was already a bit frustrated. My advise to everyone, stay on it!
A few days before i added a few air quality sensors to hassio that use the MQTT broker and Node-Red addon to distribute the data to hassio and an influx database, running on my synology nas.
By looking through the node red capabilities in the configuration ui, i noticed that there was also a serial in module available. That looked interesting.
So would it be possible to install node red on the pi zero and access the serial interface from there? This would be awesome, then i would just need to post the values through MQTT to hassio. Guess what!? Of course you can. There is even a nice script available that does it for you. You can find it here:
https://nodered.org/docs/getting-started/raspberrypi So i ran the script and in very short time i had a running node red client running on my zero.
I dragged the serial in module into the config canvas and specified the properties.
By attaching a debug node, i was then able to see what values the heating system actually transmits.
Awesome! First step was done. Some of the values where a bit cryptical and i had to look up the official documentation (pdf specified above) to make some sense of them. After all, now the flows look like this, forwarding the extracted, and sometimes formed values to hassio mqtt addon.
Here is an example of some JS code that transforms a temperature value coming through the serial port. Please dont judge me on my code. It’s freestyle, quick and dirty to make it work.
var array = msg.payload;
var type = array[0];
var modbusID = array [1];
var value = array[2];
var jsonString = {};
//Aktuelle Innentemperatur
if (type == 120 && modbusID == 200) {
var measurementObject = {};
measurementObject.measurement = "temperature";
measurementObject.type = type.trim();
var temperatureValue = value.trim();
temperatureValue = temperatureValue.slice(0,2) + "." + temperatureValue.slice(2)
temperatureValue = parseFloat(temperatureValue);
measurementObject.value = temperatureValue;
jsonString= JSON.stringify(measurementObject);
var newMsg = { payload: jsonString };
node.send(newMsg);
}
It is by far not all of them, but i still need some investigation time. For now i focused on the values i was able to make sense of and that i would be interested in, like temperatur and rotational speed of the circulation fans etc.
Using an MQTT out node was also very simple, by just specifying the hassio mqtt broker and the topic that should be used for that value.
I have a little helper tool, MQTT Explorer for Mac, that i use to see which measurements are actually received by the hassio mqtt broker. As you can see, they have arrived there nicely.
Now i can make use of these values with the capabilities hassio gives me. Either create a mqtt sensor or store the values (sometimes in addition to the sensor) in my influx database.
Creating a sensor is fairly easy and looks like this. How creating sensors and the use of templates work can be found here. Mine looks like this:
- platform: mqtt
state_topic: "Home/Aerosmart/AktuelleInnenTemperatur"
name: "AerosmartPi Innentemperatur"
unit_of_measurement: "°C"
value_template: "{{ value_json.value }}"
Once the sensor is up and running, you can use it in Lovelace UI or in automations etc.
To store the values in my influxdb, i use the node-red addon available for hassio. Here is a flow that illustrates how this can be done.
There is an influxdb-out node available to take care of this task.
Grafana looks nice with the values from my heating system.
I hope this can be useful for somebody in a similar context. Because I’m very happy achieving this by using tools that you guys make available to us, being not so fluent with writing code, i thought I share my experience.
Now comes the fun part, tweaking and tuning it. Please let know know if you have any ideas to improve the setup.
Thanks. Ike.