Zehnder ComfoAirQ350 -- do I need ComfoConnect to control it?

@bitweasel: Would be great if you’d like to share some of your code?

I suggest that plugin used cheap CAN adapter instead expensive Zehnder wifi module :slight_smile:

Why not both? :smiley:

1 Like

Hello Vakis2006,

Totally agree. The Comfosense Lan is very expensive.

I wonder if anyone has already realized this.

Could a CAN analyzer help to realize this?

if someone is interested i’ve implemented gateway for ComfoAir Q in Homie4 convention. It supports most of sensors and there is a possibility of controlling various modes including fan speed, automatic and manual mode, away and boost mode for a given time or balance mode. Everything should be auto-discovered by OpenHAB. It is possibility of controlling connection to Comfoconnect LAN directly from OpenHAB. Unfortunately there are some issues with Homie binding in OpenHab but I’ve implemented workaraound and a few rules.
https://github.com/klaudiusz223/ComfoAirQ-Homie

4 Likes

Hello Klaudiusz,
Can you write a short “howto” guide to get this running in Openhab?

Thx for your effort!

1 Like

First you will need MQTT broker. I’m using mosquitto and i don’t recommend OH embedded broker. Then install MQTT binding for OH and configure MQTT broker in OH. Above task are very common so You should easy find ready HOWTO’s.
With properly installed MQTT in OH. You can start installation of ComfoAirQ-Homie according to README file from repository.
After installation 2 Homie devices should be auto discovered by OH so You can configure everything using Paper UI. If You preffer using text configuration there are examples in my repository.

1 Like

Would this Node-RED MQTT Broker be suitable?

Can you shed any light on this?

I’ve added the two items that you mention on your GitHub page (and Wheel, which was missing)

But when I run the comfoairq-homie command, I get this

root@OpenHab2_Odroid:/opt# comfoairq-homie

Traceback (most recent call last):
   File "/usr/local/bin/comfoairq-homie", line 9, in <module>
 load_entry_point('comfoairq-homie==0.2.0', 'console_scripts', 'comfoairq-homie')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
 return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
 return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2229, in load
 return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
 module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python3.5/dist-packages/comfoairq_homie/__main__.py", line 11, in <module>
 from .comfoairq_homie import ComfoAirQ_Homie
File "/usr/local/lib/python3.5/dist-packages/comfoairq_homie/comfoairq_homie.py", line 4, in <module>
 from .homie_device.device_comfoairq         import  Device_ComfoAirQ
File "/usr/local/lib/python3.5/dist-packages/comfoairq_homie/homie_device/device_comfoairq.py", line 20, in module>
 from ..comfoairq.comfoairq import ComfoAirQ
File "/usr/local/lib/python3.5/dist-packages/comfoairq_homie/comfoairq/comfoairq.py", line 15
 connection_event : threading.Event = None
                  ^
SyntaxError: invalid syntax

I’m assuming I’m missing a step somewhere, as I would assume I need to put add an IP address and some credentials for both the ComfoAir and the MQTT broker ??

Also, will this run in the background without further interaction and how would you recommend I / we add it to the startup routine?

Update

It looks like I’m missing a step somewhere, as the comfoairq-homie.service file hasn’t been installed

And FYI

It looks like it’s due to python 3.5. Theoretically python 3.6 is required but I will try to solve it. Please check the new version I recently commited (use --upgrade option during installation). I updated also README file and added info about config file. Systemd service file is not installed by default. You need to do it manually. Example configs are in repo.

1 Like

I also don’t get it to run. I am also missing a step by step guide because I am not familiar with python.

My environment:
openHABian mit openHAB 2.5.1-2
Release = Raspbian GNU/Linux 10 (buster)
Kernel = Linux 4.19.93-v7+
Platform = Raspberry Pi 3 Model B Plus Rev 1.3

my steps:

install python:
sudo apt-get install python3-pip

Then continue with the instructions on https://github.com/klaudiusz223/ComfoAirQ-Homie:

pip3 install --upgrade git+https://github.com/michaelarnauts/comfoconnect.git
pip3 install git+https://github.com/klaudiusz223/ComfoAirQ-Homie.git

result:

Successfully built comfoairq-homie
Installing collected packages: paho-mqtt, netifaces, Homie4, pyyaml, comfoairq-homie
The script comfoairq-homie is installed in ‘/home/openhabian/.local/bin’ which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed Homie4-0.3.5 comfoairq-homie-0.2.1 netifaces-0.10.9 paho-mqtt-1.5.0 pyyaml-5.3.1

Configfile:
Create comfoairq_homie.yml or adapted template from GitHub - klaudiusz223/ComfoAirQ-Homie: Homie4 for Zehnder ComfoAirQ.

Where can I get the COMFOCONNECT_UUID ??

So now to the real problem.
No matter where I copy the comfoairq_homie.yml I always get the following error:

[18:38:02] openhabian@openhab:~$ python3 -m comfoairq_homie
Traceback (most recent call last):
File “/usr/lib/python3.7/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.7/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/main.py”, line 72, in
main()
File “/home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/main.py”, line 48, in main
with open(args.config, ‘r’) as ymlfile:
FileNotFoundError: [Errno 2] No such file or directory: ‘./comfoairq_homie.yml’

I tried the following paths:

/home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/comfoairq_homie.yml
/home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/comfoairq/comfoairq_homie.yml
/home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/homie_device/comfoairq_homie.yml
/home/openhabian/.local/bin/comfoairq-homie//comfoairq_homie.yml

more attempts:

[18:47:56] openhabian@openhab:~$ comfoairq-homie
-bash: comfoairq-homie: Kommando nicht gefunden.

[18:50:50] openhabian@openhab:~$ comfoairq-homie -c config_file.yml -l optional_log_file.log
-bash: comfoairq-homie: Kommando nicht gefunden.

[18:50:51] openhabian@openhab:~$ sudo comfoairq-homie -c config_file.yml -l optional_log_file.log
sudo: comfoairq-homie: Befehl nicht gefunden

[18:50:54] openhabian@openhab:~$ python3 -m comfoairq-homie -c config_file.yml -l optional_log_file.log
/usr/bin/python3: No module named comfoairq-homie

[18:51:09] openhabian@openhab:~$ sudo python3 -m comfoairq-homie -c config_file.yml -l optional_log_file.log
/usr/bin/python3: No module named comfoairq-homie

Please help
thx

1 Like

please try :

python3 -m comfoairq_homie -c config_file.yml

or with log file

python3 -m comfoairq_homie -c config_file.yml -l optional_log_file.log

python module name is comfoairq_homie (underscore) but console script is comfoairq-homie (dash). Unfortunately console script is not installed correctly in Your system or maybe You need to correct PATH variable.

COMFOCONNECT_UUID - You rather don’t need to change that

What exactly do I have to do? I installed it exactly according to the instructions.

I overlooked the underscore. Now I’m getting a little bit further:

[21:44:16] openhabian@openhab:/home$ python3 -m comfoairq_homie -c /home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/comfoairq_homie.yml -l /home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/comfoairq_homie.log
2020-05-17 21:48:38,828 - [main] [INFO] Waiting… Stop with CTRL+C
2020-05-17 21:48:38,828 - [main] [INFO] Waiting… Stop with CTRL+C
Traceback (most recent call last):
File “/usr/lib/python3.7/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.7/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/main.py”, line 72, in
main()
File “/home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/main.py”, line 58, in main
comfoconnect_settings = cfg[‘comfoconnect’],
File “/home/openhabian/.local/lib/python3.7/site-packages/comfoairq_homie/comfoairq_homie.py”, line 34, in init
connect_at_start = comfoconnect_settings[‘COMFOCONNECT_AUTOCONNECT’],
KeyError: ‘COMFOCONNECT_AUTOCONNECT’

the content of the log file:

2020-05-17 21:48:38,828 - [main] [INFO] Waiting… Stop with CTRL+C
2020-05-17 21:48:38,828 - [main] [INFO] Waiting… Stop with CTRL+C

what should happen now? Nothing happens in the MQTT, no message …

Add to the config:

COMFOCONNECT_AUTOCONNECT : True

You can find updated version in the repo

thanks, it works - at least many MQTT messages come in! Every 2 seconds each state!
Is this ok? Hope the MQTT server can handle it.
It would be enough for me every 30 seconds. Can i set that?

Attached is my log file, the following error always occurs:

2020-05-17 23:51:05,029 - [homie.device_base] [INFO] Device MQTT Connected state is True
2020-05-17 23:51:05,031 - [homie.device_base] [INFO] Device MQTT Connected state is False
2020-05-17 23:51:05,034 - [homie.mqtt.paho_mqtt_client] [WARNING] MQTT Unexpected disconnection <paho.mqtt.client.Client object at 0x75bbbc10> None Connection refused - incorrect protocol version
2020-05-17 23:51:05,041 - [homie.mqtt.mqtt_base] [WARNING] MQTT On Disconnect: Result Code 1
comfoairq_homie.log (109.6 KB)

Thanks a lot!

regarding to errors:
IIRC I had similar errors with OH embedded MQTT broker. I switched to mosquitto and everything works perfectly. Which broker do You use?
regarding to messages:
it shouldn’t be a problem for MQTT broker. There is no simply option for slowing down but it can be easy twicked in the code by removing unused sensors or adding transformation functions. All read only sensors are defined in this dictionary https://github.com/klaudiusz223/ComfoAirQ-Homie/blob/81384b86a15591d1480c933415aa38ea545c61ed/comfoairq_homie/homie_device/device_comfoairq.py#L90.
Some Python skills are required

Thank you for your time in helping us “non-software” people get to grips with your code.

I’m making progress by following your comments here.

This is what I have done so far and it seems to be working.
All I have to do now is edit the .service file to make it start at boot.
(I don’t see the virtualenv folder, so I’m a bit stuck now)

  • Created a MQTT broker in Node-RED (Aedes)

  • Cloned your GIT to /opt
    git clone https://github.com/klaudiusz223/ComfoAirQ-Homie.git

  • ran the two commands shown in your Readme page

pip3 install --upgrade git+https://github.com/michaelarnauts/comfoconnect.git
pip3 install git+https://github.com/klaudiusz223/ComfoAirQ-Homie.git

I originally got some errors saying that I didn’t have wheel installed, so I ran this command and tried the two above again

pip3 install wheel

  • edited the comfoairq_homie.yml file as best I can, given that I’m not entirely sure what the correct information in (The PIN seems to have been changed, so I’ll need to talk to the installer)

mqtt:
  MQTT_BROKER: "127.0.0.1"
  MQTT_PORT: 1883
  MQTT_USERNAME: null
  MQTT_PASSWORD: null
  MQTT_KEEPALIVE: 60
  MQTT_CLIENT_ID: null
  MQTT_SHARE_CLIENT: False

comfoconnect:
  COMFOCONNECT_HOST : null
  COMFOCONNECT_PIN  : 0000
  COMFOCONNECT_NAME : "ComfoConnect Homie Gateway"
  COMFOCONNECT_UUID : "00000000000000000000000000000006"
  COMFOCONNECT_AUTOCONNECT : True

comfoairq_homie:
  HOMIE_ID              : zehnderq450
  HOMIE_NAME            : ZehnderQ450

Setting the Host to 192.168.1.31 seemed to speed up the process, but I can’t see any major change.

IE

comfoconnect:
  COMFOCONNECT_HOST : 192.168.1.31
  COMFOCONNECT_PIN  : 0000
  COMFOCONNECT_NAME : "ComfoConnect Homie Gateway"
  COMFOCONNECT_UUID : "00000000000000000000000000000006"
  COMFOCONNECT_AUTOCONNECT : True

When I run the following command, I get a lot more useful information,which looks like it is really trying to connect, if it wasn’t for that dam PIN… :sob:

python3 -m comfoairq_homie -c comfoairq_homie.yml

root@OpenHab2_Odroid:/opt/ComfoAirQ-Homie# python3 -m comfoairq_homie -c comfoairq_homie.yml


2020-05-18 11:05:32,304 - [__main__]  [INFO]  Waiting... Stop with CTRL+C
2020-05-18 11:05:32,304 - [__main__]  [INFO]  Waiting... Stop with CTRL+C
2020-05-18 11:05:32,306 - [homie.mqtt.homie_mqtt_client]  [INFO]  Using new MQTT client, number of instances 0
2020-05-18 11:05:32,307 - [homie.mqtt.mqtt_base]  [INFO]  MQTT set will homie/zehnderq450/$state, topic lost
2020-05-18 11:05:32,313 - [homie.mqtt.paho_mqtt_client]  [INFO]  Starting MQTT publish thread
2020-05-18 11:05:32,315 - [homie.mqtt.paho_mqtt_client]  [INFO]  Starting Asyincio looping forever
2020-05-18 11:05:32,319 - [homie.device_base]  [INFO]  Device Start ZehnderQ450
2020-05-18 11:05:32,320 - [homie.device_base]  [INFO]  Device MQTT Connected state is True
2020-05-18 11:05:32,360 - [homie.mqtt.homie_mqtt_client]  [INFO]  Using new MQTT client, number of instances 1
2020-05-18 11:05:32,372 - [homie.mqtt.mqtt_base]  [INFO]  MQTT set will homie/zehnderq450gateway/$state, topic lost
2020-05-18 11:05:32,376 - [homie.mqtt.paho_mqtt_client]  [INFO]  Starting MQTT publish thread
2020-05-18 11:05:32,378 - [homie.mqtt.paho_mqtt_client]  [INFO]  Starting Asyincio looping forever
2020-05-18 11:05:32,380 - [homie.device_base]  [INFO]  Device Start ZehnderQ450Gateway
2020-05-18 11:05:32,402 - [homie.device_base]  [INFO]  Device MQTT Connected state is True
2020-05-18 11:05:37,505 - [comfoairq_homie.comfoairq.comfoairq]  [INFO]  Bridge found: 00000000000c10128001144fd71e05cd (192.168.1.31)
2020-05-18 11:05:38,538 - [comfoairq_homie.comfoairq.comfoairq]  [WARNING]  Connection failed
2020-05-18 11:05:38,539 - [comfoairq_homie.comfoairq.comfoairq]  [WARNING]  Could not connect to the bridge since the PIN seems to be invalid.
2020-05-18 11:05:38,539 - [comfoairq_homie.comfoairq.comfoairq]  [INFO]  Disconnection procedure
2020-05-18 11:05:38,540 - [comfoairq_homie.comfoairq.comfoairq]  [WARNING]  'NoneType' object has no attribute 'join'
2020-05-18 11:05:43,616 - [comfoairq_homie.comfoairq.comfoairq]  [INFO]  Bridge found: 00000000000c10128001144fd71e05cd (192.168.1.31)
2020-05-18 11:05:44,668 - [comfoairq_homie.comfoairq.comfoairq]  [WARNING]  Connection failed
2020-05-18 11:05:44,669 - [comfoairq_homie.comfoairq.comfoairq]  [WARNING]  Could not connect to the bridge since the PIN seems to be invalid.
2020-05-18 11:05:44,669 - [comfoairq_homie.comfoairq.comfoairq]  [INFO]  Disconnection procedure
2020-05-18 11:05:44,669 - [comfoairq_homie.comfoairq.comfoairq]  [WARNING]  'NoneType' object has no attribute 'join'
2020-05-18 11:05:49,709 - [comfoairq_homie.comfoairq.comfoairq]  [INFO]  Bridge found: 00000000000c10128001144fd71e05cd (192.168.1.31)
2020-05-18 11:05:50,748 - [comfoairq_homie.comfoairq.comfoairq]  [WARNING]  Connection failed

I’m hoping that this comfoairq-homie.service file will do the trick, once I get the PIN right.

[Unit]
Description="Homie4 ComfoAirQ Service"
After=syslog.target network.target nodered.service openhab2.service


[Service]
WorkingDirectory=/opt/ComfoAirQ-Homie/
Environment=COMFOAIRQ_LOGLEVEL=INFO
Environment=COMFOAIRQ_COMFOCONNECT_LOGLEVEL=INFO
Environment=PATH=/opt/ComfoAirQ-Homie:$PATH
ExecStart=/usr/bin/python3 -m comfoairq_homie -c /opt/ComfoAirQ-Homie/comfoairq_homie.yml
ExecStop=/bin/kill $MAINPID
Restart=always

[Install]
WantedBy=multi-user.target

Update

We’ve got the pin now and the output has changed to something more positive, but it still looks like there is an issue, as PaperUI is reporting this for the Gateway Thing

Status: OFFLINE - COMMUNICATION_ERROR java.lang.Exception: Did not receive mandatory topic value: homie/zehnderq450gateway/$name

systemctl status comfoairq

May 18 12:04:23 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:23,556 - [homie.device_base]  [INFO]  Device MQTT Connected state is True
May 18 12:04:23 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:23,606 - [homie.mqtt.homie_mqtt_client]  [INFO]  Using new MQTT client, number of instances 1
May 18 12:04:23 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:23,614 - [homie.mqtt.mqtt_base]  [INFO]  MQTT set will homie/zehnderq450gateway/$state, topic lost
May 18 12:04:23 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:23,621 - [homie.mqtt.paho_mqtt_client]  [INFO]  Starting MQTT publish thread
May 18 12:04:23 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:23,622 - [homie.mqtt.paho_mqtt_client]  [INFO]  Starting Asyincio looping forever
May 18 12:04:23 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:23,623 - [homie.device_base]  [INFO]  Device Start ZehnderQ450Gateway
May 18 12:04:23 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:23,638 - [comfoairq_homie.comfoairq.comfoairq]  [INFO]  Bridge found: 00000000000c10128001144fd71e05cd (192.168.1.31)
May 18 12:04:23 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:23,655 - [homie.device_base]  [INFO]  Device MQTT Connected state is True
May 18 12:04:24 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:24,161 - [comfoconnect]  [INFO]  Unhandled CnNodeNotificationType
May 18 12:04:24 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:24,162 - [comfoconnect]  [INFO]  Unhandled CnNodeNotificationType

FYI…

I have upgraded to Python 3.6 using these instructions -
https://medium.com/@rajputankit22/upgrade-python-2-7-to-3-6-and-3-7-in-ubuntu-97d2727bf911

That’s is one of the issues I mentioned earlier. It’s a known bug ([mqtt.homie] Did not receive mandatory topic value: homie/xxx/$name · Issue #7252 · openhab/openhab-addons · GitHub). After installation any Homie device in OH you need restart it :-(. So please restart ComfoAirQ-Homie. Similar situation is when you restart OH. You need to restart Homie device. But I prepare workarounds. Rules for OH are in repo. So implementing this rules should solve future problems.

Regarding to config:
COMFOCONNECT_PIN : 0
is a correct configuration. You don’t need to change anything. I don’t know what for is this pin used:-).

Regarding to service.file
looks quite good but You need to follow the whole installation procedure for custom systemd service. Please find proper howto for Your linux distro. It will be much better than my;-)

Regarding to virtualenv folder:
My installation is in python virtual environment. It’s not necessary. It gives some advantages but You can skip it or leave it as last stage.

Hello

Thanks for replying.

That’s curious.

Without changing the PIN, I was getting a constant error, stating that the PIN was incorrect.

Changing it to the PIN needed for the phone app made a huge difference.

The service file I’ve created seems to be working well :smile:

Curious

I’ll try a complete reboot, as that’s the only thing I haven’t done yet.

Is the error I’m seeing normal until a full restart?

 May 18 12:04:24 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:24,161 - [comfoconnect]  [INFO]  Unhandled CnNodeNotificationType
May 18 12:04:24 OpenHab2_Odroid python3[1647]: 2020-05-18 12:04:24,162 - [comfoconnect]  [INFO]  Unhandled CnNodeNotificationType

Ummmm

I’ve completely rebooted the machine and it’s still reporting this error

May 18 17:07:08 OpenHab2_Odroid python3[1647]: 2020-05-18 17:07:08,995 - [comfoconnect]  [INFO]  Unhandled CnNodeNotificationType
May 18 17:07:08 OpenHab2_Odroid python3[1647]: 2020-05-18 17:07:08,996 - [comfoconnect]  [INFO]  Unhandled CnNodeNotificationType

And the Things are stating

Status: OFFLINE - COMMUNICATION_ERROR java.lang.Exception: Did not receive mandatory topic value: homie/zehnderq450gateway/$homie

But… I have now got channels in the Gateway :smile: so that’s a massive step forward.

I’m totally stabbing in the dark here…

Do I need to do something with the MQTT bridge, like adding a channel?

If so .

What does it need?