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

This looks like the connection is not sending anything. Give it a try and send below command from a windows tool:
https://files.waveshare.com/upload/b/b3/Sscom5.13.1.zip
(taken from support page of a rs232 - eth module https://www.waveshare.com/wiki/RS232/485/422_TO_POE_ETH_(B)#:~:text=and%20check%20again.-,Examples,-TCP%20Communication )
You can send there a command:

\x07\xf0\x00\xdd\x00\x8a\x07\x0f

and the response should be something similar to:

[18:42:21.990]IN¡û¡ô07 F3 07 F0 00 DE 14 00 23 16 01 CF 3C 00 2F AE 04 02 00 00 A8 9A 2A 6A 00 00 4B E8 07 0F 

If this does not work, most likely the cable connection is not correct. I’m using entry through the RJ45 socket that is available in the comfoair unit. There is also a screw terminal which might be easier to play with.
Could be that the pinout on the DB9 port is not a standard one.
Here is example for my setup:

No, the one in green is used to connect to the second board in the unit (and is already occupied). The screw terminal I’ve marked in blue is the one you can use:

It is actually marked - you need to use just the GND, RX and TX terminals.
Look at one of the first posts to see which pins need to be connected (not sure if you’ll have standardized cable colours in your cable - just cut it to the length that you’ll need).

Once you are sure it works you can also end it with RJ45 plug if there is such socket on your board (it is right below the screw terminal - it connects to the same tracks. Not sure from the picture you’ve provided).

1 Like

Ah, and btw, you can’t have both the ethernet-RS232 gateway and the Comfoair controller (e.g. CCEase) connected at the same time. RS232 is a point-to-point interface and can only have 2 devices connected at the same time.

1 Like

Thank You Yery Much, It Works!!! :grinning:

Great to hear that! So what was the problem? Cable or the Comfoair controller connected in parallel? Or both?

The Cable was the Problem. :grin:

1 Like

I’m trying to create an automation to control ha_climate_mode. Unfortunately, I can’t find the entity. Does anyone have an example of how to increase or decrease the fan speed?

Here is an example:

action: climate.set_fan_mode
data:
  fan_mode: low
target:
  entity_id: climate.ca350_climate

possible fan modes are: off, low, medium, high
Btw, for CA350 off is not really off, it is more an “away” mode as the vent is not really turned off, rather is put on the lowest speed. You can’t have such setup for climate entity in HA.

It Works!!! :clap:

1 Like

I need some help with the installation.
My setup: HaOS on Rasp5 and Waveshare RS232/485 to WiFi and Ethernet.

ca350.py:
26-02-2025 09:37:34 WARNING: Opening serial port exception:
26-02-2025 09:37:34 WARNING: (<class ‘serial.serialutil.SerialException’>, SerialException(2, “could not open port /dev/cuau3: [Errno 2] No such file or directory: ‘/dev/cuau3’”), <traceback object at 0x7fa6a99540>)

There is no virtual serial port…

How are you running the script? Have you followed the wiki for HAOS installation? If yes, you need to somehow create the virtual port on HAOS, you can take example from the docker startup script and do something similar for HAOS:

Mainly have a look at this line:
/usr/bin/socat -d -d pty,link="$SERIAL_PORT",raw,group-late=dialout,mode=660 tcp:"$COMFOAIR_IP":"$COMFOAIR_PORT"
You’ll have to either modify the ca350runner.py program or create a separate one just for the virtual serial port. Not sure if there is a better way of achieving it on HAOS.

I finally got a connection to my comfoair via serial connection RS232 using the docker container. I would like to share what I changed in my docker-compose.yml to get it working.
Maybe you want to add it to the documentation on github:

services:    
  comfoair:
    image: adorobis/hacomfoairmqtt:latest
    container_name: comfoair
    devices:
      - "/dev/ttyS0:/dev/comfoair350"
    environment:
      - SOCAT=False
      #- COMFOAIR_IP=192.168.1.50
      #- COMFOAIR_PORT=502
      - SERIAL_PORT=/dev/comfoair350
      - 
      -
    restart: always

So I receive mqtt data now which is visible in mqtt explorer as well as in home-assistant.
There is one issue left though. The TimWeyand Lovelace-comfoair Card is not working. When trying to add the card to the dashboard I only get this:

Does anyone have an idea how to solve this problem?

Michael

1 Like

Edit the card in yaml mode and make sure that the entity names are correct there.

sorry, I still see the issue with the card, any ideas on how to fix it?

I tryed to Update the js card, same problem

https://github.com/mweimerskirch/lovelace-hacomfoairmqtt/blob/4ac38413a35aa20aaa065e09eccb9f2a9f877d02/dist/hacomfoairmqtt-card.js

I think that’s the problem, there is nothing. Do I have to add everything manually?

Did I do something wrong in the configuration regarding the naming?

Don’t know. But you can just copy paste the config from the github page of the card and update to correct entity names.

I have had the problem for some time that the connection to the MQTT broker is cancelled after a few days. The connection could only be re-established by restarting the Homeasisstant.
About my configuration. I connected the CA350 directly to the Home Assistant via a USB TTL adapter and set up the whole thing there according to the instructions. Home · adorobis/hacomfoairmqtt Wiki · GitHub MQTT Broker is an add-on in the Homeassistant.
A few days ago I completely lost the connection. Does anyone have the same problem or any idea what the problem could be?

Is it just the connection from the CA350 script to MQTT broker or HA is loosing connection to the MQTT completely? The script has a reconnection mechanism implemented so it is reconnecting automatically. If it can’t reconnect you’d need to figure out what’s wrong there, maybe something in the MQTT addon logs that would tell what the problem is?

Thanks for your fast replay.
I have some other devices which are connected to the mqtt broker. They work fine. So I guess it is something between the CA350 and the broker. May you can see something more than me in the log:

[09:37:11] INFO: Starting NGINX for authentication handling...
s6-rc: info: service legacy-services successfully started
[09:37:12] INFO: Starting mosquitto MQTT broker...
2025-03-19 09:37:12: Warning: Mosquitto should not be run as root/administrator.
2025-03-19 09:37:12: mosquitto version 2.0.20 starting
2025-03-19 09:37:12: Config loaded from /etc/mosquitto/mosquitto.conf.
2025-03-19 09:37:12: Loading plugin: /usr/share/mosquitto/go-auth.so
2025-03-19 09:37:12:  ├── Username/password checking enabled.
2025-03-19 09:37:12:  ├── TLS-PSK checking enabled.
2025-03-19 09:37:12:  └── Extended authentication not enabled.
2025-03-19 09:37:12: Opening ipv4 listen socket on port 1883.
2025-03-19 09:37:12: Opening ipv6 listen socket on port 1883.
2025-03-19 09:37:12: Opening websockets listen socket on port 1884.
2025-03-19 09:37:12: mosquitto version 2.0.20 running
2025-03-19 09:37:12: New connection from ::1:52314 on port 1883.
2025-03-19 09:37:12: Client <unknown> disconnected due to protocol error.
[09:37:12] INFO: Successfully send discovery information to Home Assistant.
[09:37:13] INFO: Successfully send service information to the Supervisor.
2025-03-19 09:37:17: New connection from 172.30.32.1:36055 on port 1883.
2025-03-19 09:37:17: New client connected from 172.30.32.1:36055 as 5gxzIdHpoWRj9oS5LEwHB9 (p2, c1, k60, u'mqttuser').
2025-03-19 09:37:18: New connection from 192.168.178.64:54372 on port 1883.
2025-03-19 09:37:18: New client connected from 192.168.178.64:54372 as Strommessung (p2, c1, k30, u'mqttuser').
2025-03-19 09:37:37: New connection from 192.168.178.81:64096 on port 1883.
2025-03-19 09:37:37: New client connected from 192.168.178.81:64096 as Strom_allg (p2, c1, k10, u'mqttuser').
2025-03-19 09:38:05: New connection from 172.30.32.2:47700 on port 1883.
2025-03-19 09:38:05: Client <unknown> closed its connection.
2025-03-19 09:40:05: New connection from 172.30.32.2:44768 on port 1883.
2025-03-19 09:40:05: Client <unknown> closed its connection.
2025-03-19 09:42:05: New connection from 172.30.32.2:48024 on port 1883.
2025-03-19 09:42:05: Client <unknown> closed its connection.
2025-03-19 09:44:05: New connection from 172.30.32.2:45800 on port 1883.
2025-03-19 09:44:05: Client <unknown> closed its connection.
2025-03-19 09:46:05: New connection from 172.30.32.2:40964 on port 1883.
2025-03-19 09:46:05: Client <unknown> closed its connection.
2025-03-19 09:48:05: New connection from 172.30.32.2:49252 on port 1883.
2025-03-19 09:48:05: Client <unknown> closed its connection.
2025-03-19 09:50:05: New connection from 172.30.32.2:51650 on port 1883.
2025-03-19 09:50:05: Client <unknown> closed its connection.

In the past, I copied the logs when the connection was ok and when I no longer had a connection.

When I have connection:

2024-10-04 22:28:57: Client CA350 closed its connection.
2024-10-04 22:29:13: New connection from 192.168.178.43:50175 on port 1883.
2024-10-04 22:29:13: New client connected from 192.168.178.43:50175 as CA350 (p2, c1, k45, u'comfoair').
2024-10-04 22:30:00: New connection from 172.30.32.2:40012 on port 1883.
2024-10-04 22:30:00: Client <unknown> closed its connection.
2024-10-04 22:30:40: Client CA350 closed its connection.
2024-10-04 22:30:56: New connection from 192.168.178.43:45429 on port 1883.
2024-10-04 22:30:56: New client connected from 192.168.178.43:45429 as CA350 (p2, c1, k45, u'comfoair').
2024-10-04 22:32:00: New connection from 172.30.32.2:33732 on port 1883.
2024-10-04 22:32:00: Client <unknown> closed its connection.
2024-10-04 22:34:00: New connection from 172.30.32.2:37078 on port 1883.
2024-10-04 22:34:00: Client <unknown> closed its connection.
2024-10-04 22:36:00: New connection from 172.30.32.2:47338 on port 1883.
2024-10-04 22:36:00: Client <unknown> closed its connection.
2024-10-04 22:38:00: New connection from 172.30.32.2:37302 on port 1883.
2024-10-04 22:38:00: Client <unknown> closed its connection.

When the connection ist lost:

2024-10-04 22:16:00: New connection from 172.30.32.2:56790 on port 1883.
2024-10-04 22:16:00: Client <unknown> closed its connection.
2024-10-04 22:16:20: New connection from 192.168.178.43:43079 on port 1883.
2024-10-04 22:16:20: Client CA350 already connected, closing old connection.
2024-10-04 22:16:20: New client connected from 192.168.178.43:43079 as CA350 (p2, c1, k45, u'comfoair').
2024-10-04 22:17:48: Client CA350 has exceeded timeout, disconnecting.
2024-10-04 22:18:00: New connection from 172.30.32.2:48650 on port 1883.
2024-10-04 22:18:00: Client <unknown> closed its connection.
2024-10-04 22:18:00: New connection from 192.168.178.43:57233 on port 1883.
2024-10-04 22:18:00: New client connected from 192.168.178.43:57233 as CA350 (p2, c1, k45, u'comfoair').