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

ComfoAir 350 Luxe with Trendnet TU-S9 USB 2.0 > RS232 converter to Pi ZeroW.

When I connect my device to the heat recovery ventilator, readings appear, but after a moment, they disappear, and the Raspberry Pi continuously connects and disconnects from MQTT in a loop. When it is not connected to the heat recovery ventilator, it stays connected to MQTT the whole time, and the entities remain active.
Raspberry Pi 3B+

Turn on debug mode in the config file and share the log file. If you have configured to run the script as a daemon the log file should be in /var/log directory.

I reinstalled everything from scratch, and it seems to have started working. I have entities in Home Assistant that don’t turn off, but it seems that the messages look strange after running the ca350.py file.

27-01-2025 17:40:27 INFO: Changed RS232 mode to 0
27-01-2025 17:40:29 INFO: Changed the fan levels
27-01-2025 17:40:44 INFO: Home Assistant MQTT Autodiscovery Topic Set: homeassistant/sensor/ca350_[nametemp]/config
27-01-2025 17:40:46 INFO: Home Assistant MQTT Autodiscovery Topic Set: homeassistant/climate/ca350_climate/config
27-01-2025 17:40:46 INFO: Successfull subscribed to the comfoair/comforttemp/set topic
27-01-2025 17:40:46 INFO: Successfull subscribed to the comfoair/ha_climate_mode/set topic
27-01-2025 17:40:46 INFO: Successfull subscribed to the comfoair/ha_climate_mode/fan/set topic
27-01-2025 17:40:46 INFO: Successfull subscribed to the comfoair/reset_filter topic
27-01-2025 17:40:46 INFO: Successfull subscribed to the comfoair/filterweeks topic
27-01-2025 17:40:46 INFO: Successfull subscribed to the comfoair/ewtlowtemp topic
27-01-2025 17:40:46 INFO: Successfull subscribed to the comfoair/ewthightemp topic
27-01-2025 17:40:46 INFO: Successfull subscribed to the comfoair/ewtspeedup topic
27-01-2025 17:40:46 INFO: Successfull subscribed to the comfoair/fancontrol/set topic
27-01-2025 17:41:08 WARNING: Expected return not found
27-01-2025 17:41:08 WARNING: function set_ewt could not get serial data, retrying in 2 seconds
27-01-2025 17:41:12 WARNING: Expected return not found
27-01-2025 17:41:12 WARNING: EWT Settings out of range, correcting to minimal temperature values
comfoair/ha_climate_mode/fan/set is high (speed 40)
FanLevel 4
27-01-2025 17:42:54 WARNING: Expected return not found
27-01-2025 17:42:54 WARNING: function get_filter_hours could not get serial data
27-01-2025 17:42:55 INFO: Changed the ventilation to 4
27-01-2025 17:42:56 WARNING: Expected return not found
27-01-2025 17:42:56 WARNING: function get_bypass_status could not get serial data
27-01-2025 17:42:57 WARNING: Expected return not found
27-01-2025 17:42:57 WARNING: get_ventilation_status function could not get serial data
27-01-2025 17:42:58 WARNING: Expected return not found
27-01-2025 17:42:58 WARNING: function get_preheating_status could not get serial data
27-01-2025 17:42:59 WARNING: Expected return not found
27-01-2025 17:42:59 WARNING: function get_fan_status could not get serial data
27-01-2025 17:43:00 WARNING: get_analog_sensor function could not get serial data
comfoair/ha_climate_mode/fan/set is high (speed 40)
FanLevel 4
27-01-2025 17:43:15 WARNING: Expected return not found
27-01-2025 17:43:15 WARNING: get_temp function could not get serial data
27-01-2025 17:43:16 INFO: Changed the ventilation to 4
27-01-2025 17:43:17 WARNING: Expected return not found
27-01-2025 17:43:17 WARNING: function get_fan_status could not get serial data
27-01-2025 17:43:19 WARNING: Expected return not found
27-01-2025 17:43:19 WARNING: get_ventilation_status function could not get serial data
27-01-2025 17:43:21 WARNING: Expected return not found
27-01-2025 17:43:21 WARNING: function get_fan_status could not get serial data
27-01-2025 17:43:21 WARNING: get_filter_status function could not get serial data
comfoair/ha_climate_mode/fan/set is medium (speed 30)

reviously, while the script was running, individual records kept coming in constantly; now nothing moves at all. Only when I change the fan speed does something new appear.

How can I switch from winter mode to summer mode using the integration? I only see a sensor

If you don’t have the debug mode enabled in general it should keep silent.
On the other hand this RS232 interface is somewhat strange - those warninig messages are showing that the communication is not working very well, sometimes it needs to read data a few times before the response is correctly received. I’m not a serial communicaiton expert so I’m not sure what might be causing that.
The key question is: does it work now? Do you get the sensor readings e.g. for temperature sensors? Does it react to changing the fan levels properly?
Here is my log example, as you can see there is nothing most of the time, sometimes it gets those warning messages. And nothing more since 7:09 today morning.

comfoair/ha_climate_mode/fan/set is low (speed 20)
FanLevel 2
27-01-2025 06:30:01 WARNING: Expected return not found
27-01-2025 06:30:01 WARNING: get_filter_status function could not get serial data
27-01-2025 06:30:02 INFO: Changed the ventilation to 2
27-01-2025 06:30:03 WARNING: Expected return not found
27-01-2025 06:30:03 WARNING: function get_filter_weeks could not get serial data
27-01-2025 06:30:04 WARNING: Expected return not found
27-01-2025 06:30:04 WARNING: get_ventilation_status function could not get serial data
27-01-2025 06:30:05 WARNING: Expected return not found
27-01-2025 06:30:05 WARNING: function get_filter_hours could not get serial data
27-01-2025 06:30:06 WARNING: Expected return not found
27-01-2025 06:30:06 WARNING: function get_fan_status could not get serial data
27-01-2025 06:30:07 WARNING: function get_bypass_status could not get serial data
comfoair/ha_climate_mode/fan/set is low (speed 20)
FanLevel 2
27-01-2025 06:30:33 INFO: Changed the ventilation to 2
27-01-2025 06:30:33 WARNING: Expected return not found
27-01-2025 06:30:33 WARNING: get_filter_status function could not get serial data
27-01-2025 06:30:35 WARNING: Expected return not found
27-01-2025 06:30:35 WARNING: get_ventilation_status function could not get serial data
27-01-2025 06:30:35 WARNING: Expected return not found
27-01-2025 06:30:35 WARNING: function get_filter_weeks could not get serial data
27-01-2025 06:30:37 WARNING: Expected return not found
27-01-2025 06:30:37 WARNING: function get_fan_status could not get serial data
27-01-2025 06:30:37 WARNING: function get_filter_hours could not get serial data
comfoair/ha_climate_mode/fan/set is medium (speed 30)
FanLevel 3
27-01-2025 07:09:41 WARNING: Expected return not found
27-01-2025 07:09:41 WARNING: function get_bypass_status could not get serial data
27-01-2025 07:09:43 INFO: Changed the ventilation to 3
27-01-2025 07:09:43 WARNING: Expected return not found
27-01-2025 07:09:43 WARNING: function get_preheating_status could not get serial data
27-01-2025 07:09:45 WARNING: Expected return not found

The readings change; when I adjust the fan speed, they also change, so theoretically, it’s working correctly. What about switching the mode from winter to summer? Can this be done through the integration?
Previously, I tested it on a Raspberry Pi Zero, and it seemed to work better. I’ll switch back to it tomorrow and see how it goes.

Summer/winter mode is not controllable (directly). It is just a read only parameter - the unit controls it automatically based on outside temperature and the comfort temperature setting.

May I ask for your support again, please?

Within these chats I have found lot of various description what needs to be done, etc.
After all, I don`t really know which steps needs to be done.
What I did so far:

  • python is running on my pi
  • I have installed and configured MQTT
  • I have copied these lines to configuration.yaml
shell_command:
  start_ca350: python3 /config/custom_components/ca350/ca350runner.py &
  • I have created a folder /homeassistant/lovelace-hacomfoairmqtt
  • in this folder I have copied the file "hacomfoairmqtt.js
  • I restarted HA and tried to insert this card in a new dashboard, but it`s not available

Is this all right?
What needs to be done then?

Thank you for your support.

You need to put it in the www subfolder. e.g. /homeassistant/www/lovelace-hacomfoairmqtt
After that go to your dashboard, go to edit mode, select “Manage resources” from the three dot menu:
image
and add javascript module with url /local/lovelace-hacomfoairmqtt/hacomfoairmqtt-card.js

1 Like

Thank you very much.

I did this, but cannot see the entities in my Dashboard.
Attached you can find some screenshots to maybe understand better, what I did:

Dashboard (no graph or picture seen)

configuration.yaml

configuration.yaml

Folders & Files

Folder-Structure_1

Do I need to make any changes in a file if I want to connect ComfoAir350to the USB-Port ttyUSB0?

USB_Pi

Thank you very much.

You need to adjust the settngs.ini file to your environment (e.g. mqtt server, serial port etc.)

1 Like

Thank you.
I have already changed the config.ini according my data.
Please see the screenshot below.

Do I have to make any chenges if I want to use the USB I have shown above?
It could be that I also have copied some date in a wrong directory.

I don`t want you to have too much work, but do you have a overview which data you have copied to which folder?

My structure is like this:

I still don`t see any picture in the dashboard.
Thanks a lot.

I’m sorry but I’m not fully sure about the deployment in HAOS and I don’t have it at home. First of all I would verify that the serial port is correct. You can check what is visible in the /dev/ folder. Run ls /dev/serial/by-id and you’ll see what’s there. I don’t know what type of RS232 adapter/cable you have and what other devices you have connected to your system.
Apart from that, make sure you’ve followed instructions on deploying the ca350 script as described in the Wiki Home Assistant Operating System · adorobis/hacomfoairmqtt Wiki · GitHub. As I’m not the author of those instructions I can’t validate that they are still up to date and will be working in your case. But they look good according to my knowledge.
Next, check that the script is actually sending any data to MQTT broker, you can do it by using MQTT Explorer app. If you have not changed this in the config.ini the data should show up in comfoair topic:
image
If the data is not there it means that the script does not run. If it is there, especially with online status go to HA and verify that the corresponding device and entities are visible in the MQTT integration:


If it is not there, it means that something is wrong with your MQTT integration.

1 Like

Great support-thank you!

I have followedthe guideline you have linked.
My USB-Connector is listed as following (worked well with openHAB) port:

port

Must the port be copied to the config.ini → if yes waht will be the name?

If I check MQTT, I`ll get following result (Comfoair is not listed, as described by you).

I think, it`s a problem with MQTT.
Sorry for all those questions.

Yes, the name will be /dev/serial/by-id/[this-long-name-that-you-have-shown-above]
Now, once this is correct, restart this command line again, or ideally just run it from the command line so you’ll see if it works or if there is any error being returned. To do that, in command line activate the venv:
source /config/custom_components/ca350/python3venv/bin/activate
and run the program:
python3 /config/custom_components/ca350/ca350.py
Observe what is happening there and post the log here.
Run deactivate when finished

1 Like

Thank you.
This is what I got after running the scripts via Terminal.

Terminal

➜  ~ ls /dev/serial/by-id
usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0
➜  ~ source /config/custom_components/ca350/python3venv/bin/activate
(python3venv) ➜  ~ python3 /config/custom_components/ca350/ca350.py
*****************************
* CA350 MQTT Home Assistant *
*****************************

31-01-2025 16:59:48 WARNING: Opening serial port exception:
31-01-2025 16:59:48 WARNING: (<class 'serial.serialutil.SerialException'>, SerialException(2, "could not open port usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0: [Errno 2] No such file or directory: 'usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0'"), <traceback object at 0x7fba973e00>)
(python3venv) ➜  ~ 


11

Thank you again. :wink:

Well, clearly the serial port is not correct. You need to provide the full path as I’ve mentioned earlier:

/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0
1 Like

Btw, 10 seconds for update interval is definitely too frequent. I would not put anything shorter than 30 seconds as it takes some time to send commands via serial port.

1 Like

Wow, you are the greatest!!
Thank you so much until now.

I can now change the fan-speed and get data like on the screenshot.
How can I get the outgoing and incoming temperatures as well?

A1

Have you checked if data is now appearing in MQTT? If yes, do you see the new device in the MQTT integration in HA?

1 Like