Can't connect to homematic system

Hi,

i had the hope, that i could use home assistant to connect to my new homematic-IP-wired system. Instead of using the cloud solution of homematic i installed a CCU3 with raspberrymatic to get access. But I had no success. I already asked danielperna84 (owner of pyhomematic), but he told me, that it is an issue of home assistant and not pyhomematic.
My configuration.yaml part for homematic (and Daniel told me that it is looking good) is:

homematic:
  interfaces:
    ip:
      host: 192.168.0.61
      port: 2010
      resolvenames: "json"
      username: !secret CCU3_User
      password: !secret CCU3_PW
    groups:
      host: 192.168.0.61
      port: 9292
      resolvenames: "json"
      username: !secret CCU3_User
      password: !secret CCU3_PW
      path: /groups
  hosts:
    raspberrymatic:
      host: 192.168.0.61
      port: 2001
      username: !secret CCU3_User
      password: !secret CCU3_PW

During the start of home assistant the folling messages appear in the logs:

2021-08-10 07:54:09 WARNING (SyncWorker_3) [pyhomematic._hm] Failed connecting to proxy at http://192.168.0.61:2010
2021-08-10 07:54:09 CRITICAL (SyncWorker_3) [pyhomematic.connection] Failed to create server
2021-08-10 07:54:09 CRITICAL (SyncWorker_3) [pyhomematic.connection] Failed to start server: ‘HMConnection’ object has no attribute ‘_server’
2021-08-10 07:54:09 ERROR (MainThread) [homeassistant.setup] Error during setup of component homematic
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/pyhomematic/connection.py”, line 76, in start
self._server.start()
AttributeError: ‘HMConnection’ object has no attribute ‘_server’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/setup.py”, line 249, in _async_setup_component
result = await task
File “/usr/local/lib/python3.9/concurrent/futures/thread.py”, line 52, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/homematic/init.py”, line 253, in setup
homematic.start()
File “/usr/local/lib/python3.9/site-packages/pyhomematic/connection.py”, line 82, in start
self._server.stop()
AttributeError: ‘HMConnection’ object has no attribute ‘_server’

I’m trying to get it running since weeks. I can’t even see the raspberrymatic. The homematic-ip-wired devices connected to the raspberrymatic are supported in pyhomematic. I hope someone could give me a tip what I have to do to get access to the homematic system via home assistant. Thanks in advance.

My actual home assistant is running on a raspberry Pi4b with the following setup:

version | core-2021.8.6
installation_type | Home Assistant OS
dev | false
hassio | true
docker | true
user | root
virtualenv | false
python_version | 3.9.6
os_name | Linux
os_version | 5.10.17-v8
arch | aarch64
timezone | Europe/Amsterdam

host_os | Home Assistant OS 6.2
update_channel | stable
supervisor_version | supervisor-2021.06.8
docker_version | 20.10.6
disk_total | 228.5 GB
disk_used | 10.6 GB
healthy | true
supported | true
board | rpi4-64
supervisor_api | ok
version_api | ok
installed_addons | Samba share (9.5.0), Mosquitto broker (6.0.1), Signal Messenger (0.42.0), Terminal & SSH (9.1.3), File editor (5.3.1), Samba Backup (4.5.0), MariaDB (2.4.0)

Regards Dieter

I actually said: There must be some local problem with your connection between Home Assistant and the CCU.
What I mean by that is that it is either related to your network (connectivity issues), or to settings on the CCU (firewall, permissions of the user you are using to connect, SSL, etc.). However you said, that you have that configured correctly. So maybe someone else has an idea because of similar problems in the past. And here’s the place with the biggest audience.

I tried to ping all required ports from the home assistant terminal on the ip address of the ccu3. All required ports are open. As i mentioned before i configured the ccu3 with free access for XML-RPC API and Script-API. I hope that this is enough. All videos on the connection between home assistant and ccu3 showed nothing different. I’m not sure if the situation with docker might be a reason for the problem and I’m not familiar with the use of docker. I thought that I can use home assistant (and I’m pretty happy with it) without digging to deep in linux, docker and python. Up to now that worked perfect.

Here’s my firewall configuration:

Does yours look similar? And if you have set the API’s to Eingeschränkt, have you set the correct networks / IP addresses in the box at the bottom like I have (of course adjusted to your network)?

Daniel,

thanks for your efforts.

My firewall settings (for my actual test):
Firewall-Richtlinie: “Ports offen”
Homematic XML-RPC-API: “Vollzugriff”
Remote-Homematic Script-API: “Vollzugriff”
Mediola-Zugriff XML-RPC-API: “Vollzugriff”
Textbox [Port-Freigabe] is empty
Textbox [IP-Adressen für den eingeschränkten Zugriff] is empty, but I have tested it with the ip address of my HA installation as well. No difference in the result.
Maybe you could give me a short explanantion why you entered 2 ip addresses in the textbox.
As soon as I (with the help of other people) have found a solution I want to limit the firewall settings, but for the test I thought that a minimum of “resistance” is an appropriate way.

A friend promised to provide a managed switch with port-mirroring. I will use that for a wireshark recording of the boot phase. Maybe I can find something in the communication between PI4b and ccu3.

Regards Dieter

  1. The second IP is just for my local networking setup. For you 192.168.0.0/24 probably will be fine.
  2. While it’s not working, please remove the entire hosts section, the groups interface and the resolvenames-line from the ip section.
  3. Please SSH into your Home Assistant Box and start a Python 3 interpreter (if not available, at least do it from some other host). Then enter the following commands in the interpreter-prompt (you can exit the prompt by pressing CTRL+d on your keyboard or entering quit(), then confirming with the enter-key):
from xmlrpc.client import ServerProxy
p = ServerProxy("http://192.168.0.61:2010")
p.listDevices()

This should output a big Python-list with all the available devices / channels as the elements of the list. As long as this does not work, Home Assistant won’t be able to communicate with your CCU.

If you do have trouble getting valid output, SSH into the CCU and observe the log-files in /var/log for any errors, especially when executing the p.listDevices() command.

Changed the IP in the second textbox to 192.168.0.0/24. No change in the result.

Executed the python commands and produced a long list. The beginning of the list is shown in the attachment. Size of the list is about 48k. Hope that’s what you expected (haven’t found a way to upload the file with the result).

Deleted the groups and host sections and resolvenames statement in the ip section. Once again the same error messages for homematic in the HA log after a restart.

In the meantime I have wireshark-recorded the restart of the HA host. HA talks to CCU3. But HA never sends a single tcp or udp command to 192.168.0.61 using port 2010. I thought that at least HA uses the port mentioned in the configuration.yaml.

Yes, that’s how the response should look like.

The only other thing I can think of is to turn on debug logging for HomeMatic. You can do so by adding the following to your configuration.yaml:

logger:
  default: warning
  logs:
    pyhomematic: debug
    homeassistant.components.homematic: debug

Daniel,
That was the key clue.
Debug output shows that he wants to cast 134S to an ‘integer’!? That is absolutely senseless, because that is the beginning of the user password given in secrets.yaml. I have no idea why home assistant tries to use the password information as Port.
As an action i configured a user in raspberrymatic with as password that begins with a letter and restarted HA. And now I can see all the entities related to homematic in HA. Perfect.
Thanks again for your efforts.
Regards Dieter

2021-08-15 12:35:46 DEBUG (SyncWorker_4) [pyhomematic.connection] HMConnection: Creating server object
2021-08-15 12:35:46 DEBUG (SyncWorker_4) [pyhomematic._hm] ServerThread.__init__
2021-08-15 12:35:46 DEBUG (SyncWorker_4) [pyhomematic._hm] createProxies: Creating proxies
2021-08-15 12:35:46 INFO (SyncWorker_4) [pyhomematic._hm] Creating proxy ip. Connecting to 192.168.0.61:2010
2021-08-15 12:35:46 WARNING (SyncWorker_4) [pyhomematic._hm] Failed connecting to proxy at http://192.168.0.61:2010
2021-08-15 12:35:46 DEBUG (SyncWorker_4) [pyhomematic._hm] __init__: Exception: Port could not be cast to integer value as '134S'
2021-08-15 12:35:46 CRITICAL (SyncWorker_4) [pyhomematic.connection] Failed to create server 
2021-08-15 12:35:46 DEBUG (SyncWorker_4) [pyhomematic.connection] 
2021-08-15 12:35:46 CRITICAL (SyncWorker_4) [pyhomematic.connection] Failed to start server: 'HMConnection' object has no attribute '_server'
2021-08-15 12:35:46 DEBUG (SyncWorker_4) [pyhomematic.connection] 'HMConnection' object has no attribute '_server'
2021-08-15 12:35:49 ERROR (MainThread) [homeassistant.setup] Error during setup of component homematic

I should add, that after some tests with the password, the use of signs like ( ) and #, generated the connect problem. Small and capital letters and numbers only are working without any problem.

2 Likes

@dieterguenter I know it is more than a year ago, but i had very frustrating times trying to get homematic connected, and your post made my try a new password instead (i Use ‘#’ in my password) and without this character it works great :slight_smile:
Unbelievable that still in end of 2022 some characters are not allowed.