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

AerisNext (this is the same as ComfoAir Q) is not compatible with serial / RS232 connection. You can’t control it with this integration. Also ComfoNet is not a serial protocol (not sure exactly what it is, probably something like modbus). To integrate this with HA you need the network interface ( ComfoConnect LAN C) and the official integration:

It looks like CAN BUS or NMEA2000 which is also modification of CAN BUS. I will try to arrange CAN interface for PC and try to research something. Thanks.

Hey everyone,
I found this guide searching for a way to integrate my Zehnder CA550 (non-Q) into my HA.
However, I can’t find the mentioned RJ45 plug on my unit.
I found an empty RS232-port, but the only RJ45 port I could find was connected to (what looks like) a daughterboard. The RS232 port is labeled with RS232 - KFB.
So can I just plug the RS232 directly from the unit into the RS232-USB adapter in the Pi?
Thanks!

That is how I do it. Just use the RS232 port on comfoair unit connected to RS232 of my server.

1 Like

Sounds good, I’ll try that. Thanks!

Hi!
I have just started to work on hooking up to my CA350, but I think I’m hitting some of the cable-related issues here but not sure :frowning:
SETUP

  1. I am using a Pi4 with a renkforce RS232 board:
    image
  2. I connected this DIRECTLY to the RS232 port in the top of the unit (so no RJ45 or USB involved anywhere!)
    image

STATUS:

  1. When starting the comfoair2mqtt service I sometimes get SOME data (but usually nothing). I was able to see some temperature sensors once and some filter status…
  2. What usually happens is after a while I get following errors:
Feb 16 22:11:40 raspberrypi python3[534]: 16-02-2022 21:11:40 WARNING: get_ventilation_status function could not get serial data
Feb 16 22:11:40 raspberrypi python3[534]: 16-02-2022 21:11:40 WARNING: Serial command write and read exception:
Feb 16 22:11:40 raspberrypi python3[534]: 16-02-2022 21:11:40 WARNING: (<class 'serial.serialutil.SerialException'>, SerialException('write failed: [Errno 5] Input/output error'), <traceback object at 0x7f8d9b0d40>)
Feb 16 22:11:40 raspberrypi python3[534]: 16-02-2022 21:11:40 WARNING: get_filter_status function could not get serial data
Feb 16 22:11:40 raspberrypi python3[534]: 16-02-2022 21:11:40 WARNING: Serial command write and read exception:
Feb 16 22:11:40 raspberrypi python3[534]: 16-02-2022 21:11:40 WARNING: (<class 'serial.serialutil.SerialException'>, SerialException('write failed: [Errno 5] Input/output error'), <traceback object at 0x7f8d9b0c80>)
Feb 16 22:11:40 raspberrypi python3[534]: 16-02-2022 21:11:40 WARNING: function get_filter_weeks could not get serial data
Feb 16 22:11:40 raspberrypi python3[534]: 16-02-2022 21:11:40 WARNING: Serial command write and read exception:
Feb 16 22:11:40 raspberrypi python3[534]: 16-02-2022 21:11:40 WARNING: (<class 'serial.serialutil.SerialException'>, SerialException('write failed: [Errno 5] Input/output error'), <traceback object at 0x7f8d9b0d40>)
pi@raspberrypi:~ $
  1. It seams that I have to keep my ComfoSense connected! Otherwise the status of the comfoair MQTT payload remains “offline”
  2. I don’t know if I’m using the correct path to specify my serial port (assuming /dev/ttyS0)

I would appreciate any help to get this working!

Those errors for sure mean you don’t have a connection with the serial port. Please check if you are using the right one. I don’t have experience with those rpi extension boards, I think it should work.

Can I connect the serial cables from Pi directly to the comfoair rs232 port? (without any board)?

Most likely not as the voltage on RPi pins is 3.3V and RS232 operates on 12V. In best case it won’t work, in the worst case you’ll burn your RPi

OK, so I have made the connection through an FT232 board like this one:

and connected only the 3 pins RX/TX/GND (without the VCC).
As I understand, the output from the ComfoAir350 serial port is 12V on the VCC pin - but the FTT232 VCC only accepts 3.5 or 5V on it’s VCC so I am NOT connecting it as it will fry the board.

So, the question is - should this work with only 3 pins connected or do I need to come up with a way to step down the VCC (12v from CA350) down to 5V (acceptable by the FT232 converter)?

Regards,
Pawel.

So, I’m connecting my Pi through USB => FT232 board => serial pins (RX/TX/GDN) => RJ45 to the CA350.

image

Still no luck :frowning:
What can I do?

I believe you are connecting it to the wrong connector. Open the one on top of the unit and connect it there… At least that’s how I do it :slight_smile:

I’ve been connecting everything I have lying around and the closest I got was when I connected the above mentioned RS232 extension board (the red one).
It seems it’s working - …sometimes. I got some initial data, e.g.:
image

but then it just stops updating anything. Also, I’m not able to control anything.
Basically it looks as if the connection is super unstable :frowning:

So, I tried FT232 with FTDI, some USB UART, etc. but now I’m just thinking would it be ok to connect the 3 pins mentioned in the pictures above (without the Vcc pin - as it’s 12v so would potentially fry my Raspbery Pi)?

Otherwise, could You detail what kind of connector should I get? In the picture is talks about “DB9 (RS232) / USB adaptor” and then DB0 (RS232) / RJ45 adaptor" but are these with any chips inside them like FTDI or MAX3232, etc. Could You maybe show some exact cable i can get?

Thanks for Your help!

Try to run the script from command line e.g. python3.8 ca350. It is quite talkative so you’ll see what’s happening. If it starts to work I would stick to that setup, RS232 should rather be quite stable although this specific hardware is not the most reliable (or maybe it is a question of knowing the serial protocol better). I’m using just straight serial cable with rs232 connectors on both ends so won’t help you much with selecting the one that should work. Other people are usually using RS232-USB adapters or cables.

OK, I have went back and re-did everything trying to test each step:

  1. Re-installed raspi Pi4 OS (Raspbian)
  2. Tested that serial port is working correctly
    → I have connected the RS232 plug, connected pins 2&3 (Tx/Rx) together and verified that I was seeing the text entered into the terminal. In other words, I created a loopback between Tx and Rx so that whatever I typed in was also being received.
  3. I have followed the following steps to install hacomfoairmqtt:
sudo apt-get install python3-pip python3-yaml python3-serial
sudo pip3 install paho-mqtt python-etcd
sudo mkdir /usr/local/share/mytmp
sudo mkdir /usr/local/share/ca350
sudo git clone https://github.com/adorobis/hacomfoairmqtt/ /usr/local/share/mytmp/
sudo mkdir /usr/local/share/ca350/bin
sudo cp /usr/local/share/mytmp/src/ca350 /usr/local/share/ca350/bin/
cd /usr/local/share/mytmp
sudo cp src/config.ini.dist /usr/local/share/ca350/bin/config.ini

Updated the params:

[DEFAULT]
# Serial port CA350 RS232 / RS485 direct or via USB TTL adapter
SerialPort=/dev/serial0
# Select RS232 or RS485 protocol
RS485_protocol=False
# Interval in seconds at which data from RS232 will be polled
refresh_interval=10
# automatically enable PC Mode (disable comfosense)
enablePcMode=True
debug=False

[MQTT]
# MQTT broker - IP
MQTTServer=192.168.12.xxx
# MQTT broker - Port
MQTTPort=1883
 # MQTT broker - keepalive
MQTTKeepalive=45
# MQTT broker - user - default: empty (disabled/no authentication)
MQTTUser=xxx
# MQTT broker - password - default: empty (disabled/no authentication)
MQTTPassword=xxx

NOTE: I have tried with both settings:
enablePcMode=True
&
enablePcMode=False
and with both ComfoSense connected and disconnected.

Each time I have started the script using:

sudo python3 /usr/local/share/ca350/bin/ca350

Every execution produces the same result:

*****************************
* CA350 MQTT Home Assistant *
*****************************

21-02-2022 09:46:35 WARNING: Changing the RS232 mode went wrong
21-02-2022 09:46:35 INFO: Home Assistant MQTT Autodiscovery Topic Set: homeassistant/sensor/ca350_[nametemp]/config
21-02-2022 09:46:37 WARNING: get_temp function could not get serial data
21-02-2022 09:46:38 INFO: Home Assistant MQTT Autodiscovery Topic Set: homeassistant/climate/ca350_climate/config
21-02-2022 09:46:38 INFO: Successfull subscribed to the comfoair/comforttemp/set topic
21-02-2022 09:46:38 INFO: Successfull subscribed to the comfoair/ha_climate_mode/set topic
21-02-2022 09:46:38 INFO: Successfull subscribed to the comfoair/ha_climate_mode/fan/set topic
21-02-2022 09:46:38 INFO: Successfull subscribed to the comfoair/reset_filter topic
21-02-2022 09:46:38 INFO: Successfull subscribed to the comfoair/filterweeks topic
21-02-2022 09:46:39 WARNING: function get_fan_status could not get serial data
21-02-2022 09:46:41 WARNING: get_ventilation_status function could not get serial data
21-02-2022 09:46:43 WARNING: get_filter_status function could not get serial data
21-02-2022 09:46:45 WARNING: function get_filter_weeks could not get serial data
21-02-2022 09:46:47 WARNING: function get_filter_hours could not get serial data
21-02-2022 09:46:49 WARNING: function get_bypass_status could not get serial data

… and it goes on forever.

  1. Is there a way to enable a more verbose (debug mode) to check why is the script not able to send/receive anything on the serial port?

  2. Is there a way to verify if the script is producing correct traffic in serial port?

Test Example:

  1. Connect RS232 connector
  2. Short pins 2&3
  3. Start ca350 script
  4. start minicom with:
    sudo minicom -D /dev/serial0 -b 9600
Welcome to minicom 2.8

OPTIONS: I18n 
Port /dev/serial0, 10:52:36

Press CTRL-A Z for help on special keys
       ¸ðÍzðÙðÉvðÝðßðáðD
ðLðÑ~ð

→ Should I be seeing some “normal” characters here?

  1. Is there and communication on the ComfoAir RS232 port that is happening automatically or do we need to poll it each time we want to check a value?

  2. Could You suggest a terminal command I can use to send to serial port and expect a given return?

I am completely stuck at this stage and really don’t know where to look for an issue anymore :frowning:

Edit: Not sure id this matters but on latest Raspbian the python version used is 3.9:
lrwxrwxrwx 1 root root 9 Apr 5 2021 /usr/bin/python3 → python3.9

Those warnings are quite normal, this connection is not stable and it takes sometimes a few attempts to get data from comfoair. But it should get it eventually more often than fails. Do you get anything on MQTT?
Another comment: comfosense has to be disconnected and RS232 is a point to point connection and only two devices can co-exist - this was my experience at least, never managed to get it working with comfosense connected.
And try to enable the debug mode - it will be much more talkative so you’ll see what’s happening.

  1. Yes, MQTT works fine (I can see the entity being created)
  2. Comfosense is completelly disconnected.
  3. I have been waiting for few hours - but the values never get updated…

Is there a way to “snif” the serial port communication - to see if the traffic is actuall happening correctly between devices?

Oh wow - it seems it just started to work!!! :slight_smile:

No idea what has caused it though… but I’m starting to think that but having minicom opened - I was in effect blocking the serial communication?

BTW: What parameters can I actually control with this other than fan speed? What is Summer mode for example?

Out of the box you can control the speed, the “comfort temperature” - this one indirectly controls the bypass when the unit is in Summer mode. You can also reset the filter status and configure the number of weeks after which it will show filter status not ok (requires replacement/cleaning).
And the rest is up to your invention on how to automate it based on time of the day, presence at home, humidity etc.
There is some backlog of things to be done, especially to configure fan speeds for each of the preset speeds (away, low, medium and high). Also in theory the unit allows to control the bypass manually but I haven’t managed to make it work for my unit - maybe it is restricted to summer mode only?

I have been looking into that - you need to create a splitter cable which should allow to listen to rx and tx lines on another port of your computer/rpi - you have to google that out. In case you’ll do that there is one function that is not documented in the protocol documentation: the comfosense allows to select which fan is running: only exhaust, only intake or both - but it is not documented what message has to be sent to the unit.