Zehnder ComfoAir CA350 integration via serial connection (RS232) and MQTT

If you are interested I’ve taken the comfoair component created for Domoticz integration and adjusted it for Home Assistant.
It works as a standalone service which communicates with comfoair device via serial port and with Home Assistant via MQTT. In my example it utilizes MQTT Fan integration.
It is still early and quite dirty work but feel free to use and built upon. Would be great if you keep it public or directly contribute to my repo. Adding robustness would be required, occasionally serial communication fails or returns out of range data so some better error processing is needed.

2 Likes

I connected a (selfmade) cable on the RJ45(RS232) Port on the ComfoAir. On the other end I would also use a RJ45 plug and connect it to a RJ45 to USB Adapter to connect it to the Raspberry. Would this work?
Or do I need a RS232 plug and connect it to the Raspberry?

You need a RS232-USB TTL adapter, ideally with FTDI chip for example something like that: https://allegro.pl/oferta/adapter-konwerter-usb-do-rs232-com-ftdi-db9-1-5m-7708396188
On the comfoair side you can use either the RJ45 plug, you need to connect cables like that:
image
rj45 pin 2 -> rs232 pin 3 - yellow
rj45 pin 3 -> rs232 pin 2 - white
rj45 pin 8 -> rs232 pin 5 - green


You can also plug the RS232 plug to the socket in the comfoair - mine has it and I use it this way.
You also have to disconnect the Ease (or whichever you have) controller as two devices can’t be connected to RS232 at the same time.

Thanks! I am done with the RS232 connection. I saw the example of the configuration file.
As beginner, could you give me some advice, what I have to do else?

Where to save the SRC (python script)? Right now I added a folder “phyton_scripts”
(config/python_scripts/ca350) and created a file called ca350.
Where the RCD Folder? Do I need to install FreeNas on the Home Assistant? I connected the USB on the Raspberry.

I have already an MQTT Broker within Home Assistant. So that is also done.

Sorry for late reply. In essence you have to set up the python script to run as a service. It will query RS232 port on a regular basis. You have to adjust the ca350 script to reflect your configuration:

SerialPort='/dev/cuau3'            # Serial port CA350 RS232 direct or via USB TTL adapter
MQTTServer='10.144.1.103'          # IP of MQTT broker
refresh_interval=10                # Interval at which data from RS232 will be polled

The script will poll data from the ventilation unit via rs232 port you specify above at refresh interval specified above and publish the data to the mqtt server specified above. You would need to adapt the script if your mqtt server requires authentication.

Now the best is to set this script up to run as a service on your HASS host (or actually on any host that has access to the rs232 port). The example rc.d file is specific for FreeNAS (FreeBSD) - this is my NAS solution that I have my Home Assistant installed on.
It will be different on raspberry/linux - please find information on how to configure python script to run as service on raspberry/linux.

You can also check out the original scripts made for Domoticz integration, there are some examples on how to run the python script as a service in linux:

Thanks for your information. I have added and adjust the code and the two python scripts in the Home Assistant folder “python_scripts” which should be especially for this.

I can see the entity now but it seems that I don’t get any information from the device. How can I see if I get anything from the ComfoAir? I am also not sure if the scripts are working in my configuration…

grafik

I would suggest to check 2 things:

  1. run the python script in console, it is quite talkative so it will show you what it is doing, including error and information messages. The RS232 communication is not very reliable (or the script is not the best engineering) and the communication has to be repeated to get data from the unit.
  2. check if MQTT is getting data published. If it is but your home assistant entities don’t get updated check your devices configuration. If there is no messages in MQTT broker than the problem must be on the ca350 python script side

Hi,
first of all thank you @adorbis for your work :slightly_smiling_face: I am currently migrating from openhab to home assistant, one of the only things not controllable by home assistant was my (8-Year) “old” comfoair 550. So I was happy to find this topic :slightly_smiling_face:

Mainly I am working on a Lovelace Car (based on https://github.com/wichers/lovelace-comfoair) with the ability to control (Temperature & Fan Speed) as well as to see the Main Informations of the comfoair.

Currently it looks like this:

Repository: https://github.com/TimWeyand/lovelace-comfoair

What I am missing as sensors are: The ventilation rpm, is that something we can get from the serial? Or did the comfoair esphome calculate that. The Lovelace Card works with the new Pull Request Changes (MQTT Auto Discovery) which creates the entities automatically in home assistant.

1 Like

Many thanks for your contribution! It is getting much more professional now :slight_smile:
I need to give a try to the MQTT auto discovery - but will have to change my automations and scripts most probably…
Regarding the fan RPM it should be possible to get it from serial port, protocol documentation describes it in the same command as the one used to read %fan level:
image
so small change of the get_fan_status() functions should be enough to get it.

1 Like

Hello,

I would like to integrate my Zehnder Comfoair 350 into my home assistant. As an electrical engineer, I have basic knowledge in this area, but home assistant and Raspberry are completely new to me. Are a step-by-step instructions availble for this topic? Thanks for a support.

Hi adorobis, can we get in touch since I’m integrating my ComfoAir 200 base in HASS and I’m interested in your system (some questions for you). great job!
cheers
Michele

Not that I’m aware. In general, there are two ways available to integrate RS232 communication of ComfoAir with Home Assistant:

  1. the above-mentioned integration via RS232 (or RS232-USB adapter cable) directly with the HA system (can be RPi, or any other that allows HA to access the USB or serial port), python script and MQTT integration with HA
  2. the https://github.com/wichers/esphome-comfoair - protocol port for the ESPHome.io

Feel free to ask more questions if you are choosing the option 1.

Feel free to ask your questions here for the benefit of the community :slight_smile:
And one comment. The protocol documentation explicitly mentions only CA350, CA550 as compatible and “The devices WHR930 from StorkAir, G90-380 from Wernig and Santos should be largely compatible
370 DC to be from Paul”
So first check if the protocol also is correct for your device.

Dear all,

I have a lot of questions because I have never done such an integration. I just don’t want to crash this thread. I already have problems with point 1 of the installation instructions in GitHub. Where can I enter these commands? I think the topic is still too big for me or can someone help me?

I have installed HA directly, not on a docker. It is running on an RasPi4.

Thank you.

So this is the supervised installation? Or in other words the Home Assistant OS? I don’t have experience with it - you need to have access to the OS command line to implement this integration. I don’t know how to get it though. Without the command line to OS you won’t be able to install this integration in HA. You could also install a dedicated hardware to connect to comfo air - either the esphome described here: https://github.com/wichers/esphome-comfoair or another Rpi just to control the unit (a bit overkill even with tiny versions of Pi)

Hello,

yes, my System works with HA OS. My System is not very big yet, i can switch to docker version, if it makes sence.

Dedicated hardware means, a microcontroller between CA350 and RaspPi?

With HA OS you’ll have the same challenge. You need an OS where the python script will be deployed as a service and to do that you need full command line access. I don’t have experience with doing it on HA OS.
Dedicated hardware - yes, a controller on which you’ll be able to run this python service or esphome with above linked firmware code.
Additionally, an MQTT broker (which can be implemented as addon to HA or as a separate installation).

Somehow I didn’t get a notification of the replies :-/ Thank you for the Info for the RPM Informations :slightly_smiling_face:

I just created a pull request. It has some more changes then the RPM in it.

  • I exposed all “sensors” from ca350 to HA MQTT Autodiscovery
  • I had to add some helper topics to make it compatible to the climate entity, but I did not want to break existing functionality.
  • I had to make a fix on the temperature set

If I did everything right, it should only add new entities to your home assistant.

The Widget looks better now, but still lacks some things (increasing/decreasing temperature, highlight active elements). I actually throw away the first widget and build it new (but keeping the layout)

It has an configuration interface as well. If the MQTT AD entities are available - these will be used. otherwise different entities can be used.

3 Likes

I use HA OS as an VM Appliance, but the OS seems to be quite limited. Don’t get me wrong, it does what it has to do. I for one didn’t want to bother to try to get the serial inside HA OS into their docker environment.

I have an proxmox (it’s like VMware esxi) server in the rack and run HA OS standalone as VM and an Device2MQTT VM (comfoair & zigbee2mqtt) separately. raspberry would work easily for that too.

If I would have a Linux Maschine, I would probably add hacomfoairmqtt in a docker and mount the serial.

1 Like

Many thanks, great progress! I guess it will be soon ready to be included as official integration :slight_smile: But I have no idea how to do that…