Skip to content

Add support for the new ComfoConnect Pro#74

Open
jvanhees wants to merge 4 commits into
michaelarnauts:masterfrom
jvanhees:comfoconnect-pro-connection
Open

Add support for the new ComfoConnect Pro#74
jvanhees wants to merge 4 commits into
michaelarnauts:masterfrom
jvanhees:comfoconnect-pro-connection

Conversation

@jvanhees
Copy link
Copy Markdown

I installed a new ComfoConnect Pro a few weeks ago, which seems to be replacing the previous version, and adds Wifi and other functionality that was in another connect box previously. The library didn't seem to properly connect to this new ComfoConnect Pro, even though it does support the same protocol. After some retrying, the library is able to connect, but since it initially fails the HACS integration doesn't really play nice. I used Claude to change the connection logic to also support this device, apparently it keeps the TCP connection open instead of disconnecting after a failed authentication, and just waits for a new registration.

I asked Claude to also add some test for this functionality, all other tests are still working. I do note that whenever I run the discover functionality the first time, it tends to not find the bridge. After running it a second time, it does run. Might need some more investigation but I suspect this won't be an issue with the Home Assistant integration.

Please let me know if you need anything changed or something else. Hopefully we can merge this, update the HACS integration as well with the new version and get the ComfoConnect Pro working in Home Assistant :) .

@jvanhees
Copy link
Copy Markdown
Author

Related to this discussion: #55

@jvanhees jvanhees changed the title Add support for the new Comfoconnect Pro Add support for the new ComfoConnect Pro May 27, 2026
@michaelarnauts
Copy link
Copy Markdown
Owner

Thanks!

I think this looks fine, odd that there is such a small difference between the two devices.

Can you take a look at the lint issue?

@jvanhees
Copy link
Copy Markdown
Author

I agree it's odd that there is this difference between the two devices, but I suspect that they may have rewritten some of the networking inside the device, but were able to salvage much of the software of the old device? Or they just completely rebuild it using the existing spec, who knows. To be honest, I haven't tested the complete integration yet so I'm not sure if all the addresses are the same - but there's no reason for me to suspect they've changed.

Linting issue has been fixed.

@michaelarnauts
Copy link
Copy Markdown
Owner

Thanks! I do wonder if maybe the flow should be changed, because currently, we are waiting for a timeout to know that we should register. This can perhaps explain the timeout you are also seeing in Home Assistant.

If you don't have a better idea, I'm okay with merging this.

@michaelarnauts
Copy link
Copy Markdown
Owner

CI still fails. Can you also run black to format the code?

poetry run black --check aiocomfoconnect/*.py

@jvanhees
Copy link
Copy Markdown
Author

The current flow for this fix is far from elegant, I agree. Obviously we could add a flag to the CLI interface but I don't like that and it would require the Home Assistant integration to add another option to the setup wizard. There is an option to do a version call before logging in. I've added the command to my branch, but I don't have a LAN C so I am unable to see the difference, could you run this?

poetry run python -m aiocomfoconnect version --host <your host>

On the Pro, this is the output:

gatewayVersion  : 3222274053
serialNumber    : ENG<my serial>
comfoNetVersion : 1074790400

I've asked my digital junior developer for other options, this is the response:

Here are the remaining avenues worth exploring:

  1. VersionRequest serial prefix (most promising, needs LAN C data)
    Your Pro returned ENG<15 numbers>. LAN C serial numbers likely have a different prefix. This works pre-session, so the version command we just added would be the tool — just need someone with a LAN C to run it.

  2. gatewayVersion bit pattern
    Your Pro: 0xC0000005. The top byte 0xC0 (1100 0000) might encode the device variant. If a LAN C returns 0x80000005 or 0x40000005, the top bits would be a reliable flag.

  3. CnNodeNotification.productId (post-registration)
    Once connected, the bridge broadcasts node notifications that include a productId. Node 1 is the gateway itself — the Pro product number mentioned earlier was 30006323. This would be definitive but only works after a registered session is established.

  4. ListRegisteredAppsRequest pre-session
    Worth trying — some older firmware versions respond to this without a session. If it works and the response format differs between devices, that's a data point.

However, I'm not very hopeful we can differentiate with only 2 devices.

One other option is to call the HTTP endpoint that is exposed on port 80 on the device, and search the returned HTML for the text ComfoConnect PRO. But I'm not sure if that option is more elegant than the timeout solution.

I should have fixed the linting and formatting issues btw.

@jvanhees
Copy link
Copy Markdown
Author

I might try to get a pcap from the Zehnder application to see how it is handling it later this week, but we could also accept this fix for now and perhaps later (well.... you know ;) ) find a better way.

@michaelarnauts
Copy link
Copy Markdown
Owner

Using your version call times out on my Comfoconnect LAN C

It's because you are using the same source UUID and destination UUID. Oddly enough, this then works fine on the ComfoConnect PRO?

DEBUG:aiocomfoconnect.bridge:Connected to bridge 192.168.1.170
DEBUG:aiocomfoconnect.bridge:VersionRequest
DEBUG:aiocomfoconnect.bridge:Adding listener for event 1
DEBUG:aiocomfoconnect.bridge:TX 00000000000000000000000000000001 -> 00000000000000000000000000000001: 08122001
type: VersionRequestType
reference: 1

When I change your version code to be like this:

async def run_version(host: str):
    """Request version information from the bridge (no registration required)."""
    bridges = await discover_bridges(host)
    if not bridges:
        raise BridgeNotFoundException("No bridge found")

    bridge = bridges[0]
    await bridge.connect(DEFAULT_UUID)
    try:
        msg = await bridge.cmd_version_request()
        print(f"gatewayVersion  : {msg.gatewayVersion}")
        print(f"serialNumber    : {msg.serialNumber}")
        print(f"comfoNetVersion : {msg.comfoNetVersion}")
    finally:
        await bridge.disconnect()

It works, because the destination UUID is correct then.

DEBUG:aiocomfoconnect.bridge:Connected to bridge 192.168.1.170
DEBUG:aiocomfoconnect.bridge:VersionRequest
DEBUG:aiocomfoconnect.bridge:Adding listener for event 1
DEBUG:aiocomfoconnect.bridge:TX 00000000000000000000000000000001 -> 0000000000251010800170b3d54264b4: 08122001
type: VersionRequestType
reference: 1


DEBUG:aiocomfoconnect.bridge:RX 0000000000251010800170b3d54264b4 -> 00000000000000000000000000000001: 08442001 0881a8c0800c120d44454d30313136333731323034188080c0800c
type: VersionConfirmType
reference: 1

gatewayVersion: 3222279169
serialNumber: "DEM0116371204"
comfoNetVersion: 3222274048

DEBUG:aiocomfoconnect.bridge:Emitting for event 1
gatewayVersion  : 3222279169
serialNumber    : DEM0116371204
comfoNetVersion : 3222274048
DEBUG:aiocomfoconnect.bridge:Disconnecting from bridge 192.168.1.170

@michaelarnauts
Copy link
Copy Markdown
Owner

Also, calling the HTTP endpoint won't work, because the Comfoconect LAN C doesn't expose a HTTP server, and I don't like to try and wait for a timeout just to know what system you have.

But maybe the Comfoconnect PRO sends a specifc UUID (because in your code, it seemed to accept the default uuid)?

What do you see when you run

$ poetry run python -m aiocomfoconnect --debug discover --host <ip>

DEBUG:asyncio:Using selector: EpollSelector
INFO:asyncio:Datagram endpoint local_addr=('0.0.0.0', 0) remote_addr=None created: (<_SelectorDatagramTransport fd=6 read=idle write=<idle, bufsize=0>>, <aiocomfoconnect.discovery.BridgeDiscoveryProtocol object at 0x7b73387093a0>)
DEBUG:aiocomfoconnect.discovery:Socket has been created
DEBUG:aiocomfoconnect.discovery:Sending discovery request to 192.168.1.170:56747
DEBUG:aiocomfoconnect.discovery:Data received from ('192.168.1.170', 56747): b'\x12#\n\r192.168.1.170\x12\x10\x00\x00\x00\x00\x00%\x10\x10\x80\x01p\xb3\xd5Bd\xb4\x18\x01'
Discovered bridges:
<Bridge 192.168.1.170, UID=0000000000251010800170b3d54264b4>

DEBUG:asyncio:Close <_UnixSelectorEventLoop running=False closed=False debug=True>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants