michaelarnauts / home-assistant-comfoconnect

Home Assistant integration for Zehnder ComfoAir trough a Zehnder ComfoConnect LAN C.
Other
26 stars 13 forks source link

Connection issue #22

Closed zollak closed 4 months ago

zollak commented 1 year ago

Hi, I would change the built-in comfoconnect to this HACS addon following the guide in the README. I was able to add the new repository via HACS, the system has been rebooted, the previous comfoconnect config was commented out in the configuration.yaml and where my sensors located.

During the integration (via UI), there is an "unknown error occured" (both cases: the recognized IP - that is valid for LAN C and the manually added way).

Here is the log entry for the connection issue:

2023-08-01 12:31:46.920 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/config/custom_components/comfoconnect/config_flow.py", line 133, in _register
    await self.bridge.cmd_start_session(True)
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 168, in _send
    return await asyncio.wait_for(fut, TIMEOUT)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 213, in _read_messages
    message = await self._read()
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 199, in _read
    raise ComfoConnectNotAllowed(message)
aiocomfoconnect.exceptions.ComfoConnectNotAllowed: 00000000002e10168001144fd71e3161 -> 4d32b5d83e4e76044ce827bac2f422ba: 083510052001 
type: StartSessionConfirmType
result: NOT_ALLOWED
reference: 1

I was able to ping the LAN C module from HA. It seems not a network related issue.

I don't know, what does "registering with the device" mean and I have not changed any factory default settings on the Zehnder end. Is there any way to skip the registering part of the connection or using the same way how the built-in integration wants to connect to the LAN C module?

My current HA details:

Home Assistant OS 10.3
Home Assistant Core 2023.7.3

As I could not resolve the issue, I rolled back to the official (built-in) integration. That integration keeps working. So there seems to be an issue specifically with how this HACS integration handles login and (I assume) token expiry.

Here is the log entry, with the built-in connection:

2023-08-01 13:31:33.526 INFO (SyncWorker_1) [homeassistant.components.comfoconnect] Bridge found: 00000000002e10168001144fd71e3161 (192.168.8.208)

The ID is the same as in the previous log, where the HACS add-on would change it a new one that is not allowed... I hope it might help to figure out how the issue can be solved.

michaelarnauts commented 1 year ago

Hmm, that's strange. The actual registration should be more stable in the HACS version.

I assume your unit is not using the default PIN (0000), but the configuration flow should ask the PIN then. It seems this isn't happening?

Can you enable debug logging (from the integration page, there is a menu item there) and try the registration again?

michaelarnauts commented 1 year ago

Also, what might be interesting for you, the HACS version should take over the UUID of the YAML configuration. Just make sure that the configuration is still there the first time the HACS version starts.

zollak commented 1 year ago

In the UI configuration flow, I stucked at the first stage, where the host should be set. I think it offers the IP for LAN C because somehow it is recognized by the add-on. After I submitted the selected IP, the add-on try to connect to the LAN C module but it throw an error as I mentioned that ("unknown error occured") so the integration not added yet. That is why there is no debug menu there. Moreover, because of the issue I have not seen the next stage where I have to set the PIN. Is the PIN you mentioned that is the same as the Installer Passcode: 4210 - I have found it earlier somewhere that I used in the official Zehnder mobile app. Is there any way to configure this add-on in config file? If yes, what is the config for it?

zollak commented 1 year ago

For the debug logging, is the components in this case same as before? If yes, I can set the debug logging like this:

# Loglevel settings
logger:
  default: warning
  logs:
    # log level for Zehnder
    #homeassistant.components.comfoconnect: info
    aiocomfoconnect: debug
    #homeassistant.custom_components.comfoconnect: debug

UPDATE: this config worked for debugging in the configuration.yaml

michaelarnauts commented 1 year ago

If you leave in the original YAML configuration, the new HACS integration will pick that up and it should be already registered. However, I do want to investigate your issue further.

Just for clarity, what is the version of your ComfoAirQ and your ComfoConnect Gateway? It's the last two items on the Status tab in the official App.

An older version of the ComfoConnect gateway only supported one connection, but later version support up to 5 connections. Maybe that's happening here?

michaelarnauts commented 1 year ago

For the debug logging, is the components in this case same as before? If yes, I can set the debug logging like this:

# Loglevel settings
logger:
  default: warning
  logs:
    # log level for Zehnder
    homeassistant.components.comfoconnect: debug

You should also add aiocomfoconnect: debug

michaelarnauts commented 1 year ago

I think for the custom component, you can use custom_components.comfoconnect, not sure though. The aiocomfoconnect is the most interesting.

zollak commented 1 year ago

HRU Type: ComfoAir Q350 SI TR ERV ComfoAir Q Firmware: R1.9.0 ComfoConnect Gateway: R1.5.1

let me check the logs with the custom_components.comfoconnect

zollak commented 1 year ago

Here is the debug log:


2023-08-01 14:51:07.295 DEBUG (MainThread) [aiocomfoconnect.discovery] Socket has been created
2023-08-01 14:51:07.295 DEBUG (MainThread) [aiocomfoconnect.discovery] Sending discovery request to broadcast:56747
2023-08-01 14:51:07.346 DEBUG (MainThread) [aiocomfoconnect.discovery] Data received from ('192.168.8.208', 56747): b'\x12#\n\r192.168.8.208\x12\x10\x00\x00\x00\x00\x00.\x10\x16\x80\x01\x14O\xd7\x1e1a\x18\x01'
2023-08-01 14:51:12.336 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnecting from bridge 192.168.8.208
2023-08-01 14:51:12.336 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnected from bridge 192.168.8.208
2023-08-01 14:51:12.336 DEBUG (MainThread) [aiocomfoconnect.bridge] Connecting to bridge 192.168.8.208
2023-08-01 14:51:12.338 DEBUG (MainThread) [aiocomfoconnect.bridge] Connected to bridge 192.168.8.208
2023-08-01 14:51:12.338 DEBUG (MainThread) [aiocomfoconnect.bridge] StartSessionRequest
2023-08-01 14:51:12.338 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 1
2023-08-01 14:51:12.338 DEBUG (MainThread) [aiocomfoconnect.bridge] TX a882c13821ca8b79e27cc199a235c99f -> 00000000002e10168001144fd71e3161: 08032001 0801
type: StartSessionRequestType
reference: 1

takeover: true

2023-08-01 14:51:12.876 DEBUG (MainThread) [aiocomfoconnect.bridge] RX 00000000002e10168001144fd71e3161 -> a882c13821ca8b79e27cc199a235c99f: 083510052001 
type: StartSessionConfirmType
result: NOT_ALLOWED
reference: 1

2023-08-01 14:51:12.876 DEBUG (MainThread) [aiocomfoconnect.bridge] Emitting for event 1
2023-08-01 14:51:12.876 DEBUG (MainThread) [aiocomfoconnect.bridge] RegisterAppRequest
2023-08-01 14:51:12.876 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 2
2023-08-01 14:51:12.876 DEBUG (MainThread) [aiocomfoconnect.bridge] TX a882c13821ca8b79e27cc199a235c99f -> 00000000002e10168001144fd71e3161: 08022002 0a10a882c13821ca8b79e27cc199a235c99f10001a20486f6d6520417373697374616e742028486f6d652d537a6f6c6f6c6967657429
type: RegisterAppRequestType
reference: 2

uuid: "\250\202\3018!\312\213y\342|\301\231\2425\311\237"
pin: 0
devicename: "Home Assistant (Home-xxx)"

2023-08-01 14:51:12.877 INFO (MainThread) [aiocomfoconnect.bridge] The connection was closed.
2023-08-01 14:51:17.877 WARNING (MainThread) [aiocomfoconnect.bridge] Timeout while waiting for response from bridge
2023-08-01 14:51:17.896 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnecting from bridge 192.168.8.208
2023-08-01 14:51:17.896 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnected from bridge 192.168.8.208
2023-08-01 14:51:17.896 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/config/custom_components/comfoconnect/config_flow.py", line 133, in _register
    await self.bridge.cmd_start_session(True)
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 168, in _send
    return await asyncio.wait_for(fut, TIMEOUT)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 213, in _read_messages
    message = await self._read()
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 199, in _read
    raise ComfoConnectNotAllowed(message)
aiocomfoconnect.exceptions.ComfoConnectNotAllowed: 00000000002e10168001144fd71e3161 -> a882c13821ca8b79e27cc199a235c99f: 083510052001 
type: StartSessionConfirmType
result: NOT_ALLOWED
reference: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 168, in _send
    return await asyncio.wait_for(fut, TIMEOUT)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 297, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 393, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/comfoconnect/config_flow.py", line 68, in async_step_user
    return await self._register()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/comfoconnect/config_flow.py", line 138, in _register
    await self.bridge.cmd_register_app(
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 171, in _send
    raise AioComfoConnectTimeout from exc
aiocomfoconnect.exceptions.AioComfoConnectTimeout
michaelarnauts commented 1 year ago

It seems the connection gets disconnected after you make the RegisterAppRequestType call. I'm expecting a RegisterAppConfirmType there.

If you use the mobile app, and go to "manage registered apps" under the gateway settings. (hamburger menu, my systems, select your gateway, manage registered app). Do you have a lot of registrations there? Maybe you can try removing some?

Does your "Home-xxx" contain any non-standard characters?

My log looks like this:

2023-08-01 14:57:12.641 DEBUG (MainThread) [aiocomfoconnect.discovery] Sending discovery request to zehnder-bridge.lan:56747
2023-08-01 14:57:12.669 DEBUG (MainThread) [aiocomfoconnect.discovery] Data received from ('192.168.1.213', 56747): b'\x12#\n\r192.168.1.213\x12\x10\x00\x00\x00\x00\x00%\x10\x10\x80\x01p\xb3\xd5Bd\xb4\x18\x01'
2023-08-01 14:57:12.669 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnecting from bridge 192.168.1.213
2023-08-01 14:57:12.669 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnected from bridge 192.168.1.213
2023-08-01 14:57:12.669 DEBUG (MainThread) [aiocomfoconnect.bridge] Connecting to bridge 192.168.1.213
2023-08-01 14:57:12.672 DEBUG (MainThread) [aiocomfoconnect.bridge] Connected to bridge 192.168.1.213
2023-08-01 14:57:12.672 DEBUG (MainThread) [aiocomfoconnect.bridge] StartSessionRequest
2023-08-01 14:57:12.672 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 1
2023-08-01 14:57:12.672 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 1288733ac499d9078ba47fdc4db602d9 -> 0000000000251010800170b3d54264b4: 08032001 0801
type: StartSessionRequestType
reference: 1

takeover: true

2023-08-01 14:57:13.217 DEBUG (MainThread) [aiocomfoconnect.bridge] RX 0000000000251010800170b3d54264b4 -> 1288733ac499d9078ba47fdc4db602d9: 083510052001
type: StartSessionConfirmType
result: NOT_ALLOWED
reference: 1

2023-08-01 14:57:13.218 DEBUG (MainThread) [aiocomfoconnect.bridge] Emitting for event 1
2023-08-01 14:57:13.218 DEBUG (MainThread) [aiocomfoconnect.bridge] RegisterAppRequest
2023-08-01 14:57:13.218 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 2
2023-08-01 14:57:13.218 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 1288733ac499d9078ba47fdc4db602d9 -> 0000000000251010800170b3d54264b4: 08022002 0a101288733ac499d9078ba47fdc4db602d910001a1c486f6d6520417373697374616e742028646576656c6f706d656e7429
type: RegisterAppRequestType
reference: 2

uuid: "\022\210s:\304\231\331\007\213\244\177\334M\266\002\331"
pin: 0
devicename: "Home Assistant (development)"

2023-08-01 14:57:13.233 DEBUG (MainThread) [aiocomfoconnect.bridge] RX 0000000000251010800170b3d54264b4 -> 1288733ac499d9078ba47fdc4db602d9: 08342002
type: RegisterAppConfirmType
reference: 2

2023-08-01 14:57:13.233 DEBUG (MainThread) [aiocomfoconnect.bridge] Emitting for event 2
2023-08-01 14:57:13.233 DEBUG (MainThread) [aiocomfoconnect.bridge] StartSessionRequest
2023-08-01 14:57:13.233 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 3
2023-08-01 14:57:13.234 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 1288733ac499d9078ba47fdc4db602d9 -> 0000000000251010800170b3d54264b4: 08032003 0801
type: StartSessionRequestType
reference: 3

takeover: true

2023-08-01 14:57:13.240 DEBUG (MainThread) [aiocomfoconnect.bridge] RX 0000000000251010800170b3d54264b4 -> 1288733ac499d9078ba47fdc4db602d9: 083510002003
type: StartSessionConfirmType
result: OK
reference: 3
michaelarnauts commented 1 year ago

HRU Type: ComfoAir Q350 SI TR ERV ComfoAir Q Firmware: R1.9.0 ComfoConnect Gateway: R1.5.1

That's looking fine. My ComfoAirQ has firmware R1.10.0 and my gateway has R1.5.1. But it's the gateway where we are connecting to, and that's the same version, so it should behave the same as mine.

Have you tried power cycling the Comfoconnect LAN C? Maybe it's not accepting new registrations for some unknown reason...

zollak commented 1 year ago

I have found 2 items in the registered apps:

Home Assistant
zollak's iPhone

not so much. I have tried to power off and on the device remotely (I have a tasmota plug, so I was able to do it remotely)

Do you think, I have to update firmware?

zollak commented 1 year ago

In my case, there is no data value in the RegisterAppRequestType call:

your log entry:

2023-08-01 14:57:13.218 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 1288733ac499d9078ba47fdc4db602d9 -> 0000000000251010800170b3d54264b4: 08022002 0a101288733ac499d9078ba47fdc4db602d910001a1c486f6d6520417373697374616e742028646576656c6f706d656e7429
type: RegisterAppRequestType

My log entry:

2023-08-01 14:51:12.876 DEBUG (MainThread) [aiocomfoconnect.bridge] TX a882c13821ca8b79e27cc199a235c99f -> 00000000002e10168001144fd71e3161: 08022002 0a10a882c13821ca8b79e27cc199a235c99f10001a20486f6d6520417373697374616e742028486f6d652d537a6f6c6f6c6967657429
type: RegisterAppRequestType

it seems there is no session... As the 08022002 is same, that is why I think the data after this can be some value of the 08022002 command (whatever it means)

UPDATE: doesn't matter... for the next trial there is a value but the issue is the same:

2023-08-01 16:13:18.409 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 97fbe38a0787c363378171cf03ec1235 -> 00000000002e10168001144fd71e3161: 08022002 0a1097fbe38a0787c363378171cf03ec123510001a20486f6d6520417373697374616e742028486f6d652d537a6f6c6f6c6967657429
type: RegisterAppRequestType
zollak commented 1 year ago

If I remove the "Home Assistant" registered device from the app means that there won't be possible to continue with the same entity_id's? What do you think?

michaelarnauts commented 1 year ago

If I remove the "Home Assistant" registered device from the app means that there won't be possible to continue with the same entity_id's? What do you think?

The Home Assistant one is for the old integration. You can leave that one.

I guess the entity id's will be different anyway with the new integration, but you can always rename them back to the old entity id's.

zollak commented 1 year ago

I saw that the PIN in the app was the default value.

So, what is next? How can we continue for debugging?

michaelarnauts commented 1 year ago

it seems there is no session... As the 08022002 is same, that is why I think the data after this can be some value of the 08022002 command (whatever it means)

The hexadecimal string you see after 08022002 is the actual command you can see below that line. Yours is longer since I guess your device name is longer.

The actual issue is that it seems your device is disconnecting right after the RegisterAppRequestType. It still takes 5 seconds for the timeout to be handled though.

From your log:

2023-08-01 14:51:12.876 DEBUG (MainThread) [aiocomfoconnect.bridge] TX a882c13821ca8b79e27cc199a235c99f -> 00000000002e10168001144fd71e3161: 08022002 0a10a882c13821ca8b79e27cc199a235c99f10001a20486f6d6520417373697374616e742028486f6d652d537a6f6c6f6c6967657429
type: RegisterAppRequestType
reference: 2

uuid: "\250\202\3018!\312\213y\342|\301\231\2425\311\237"
pin: 0
devicename: "Home Assistant (Home-xxx)"

2023-08-01 14:51:12.877 INFO (MainThread) [aiocomfoconnect.bridge] The connection was closed.
2023-08-01 14:51:17.877 WARNING (MainThread) [aiocomfoconnect.bridge] Timeout while waiting for response from bridge

So, what is next? How can we continue for debugging?

Could you create a network capture on your Home Assistant server? I'm curious to see if your bridge is actually sending a disconnect right after our RegisterAppRequestType message.

$ tcpdump -i any -s 0 -w /tmp/capture.pcap tcp and port 56747
michaelarnauts commented 1 year ago

I think that the library incorrectly thinks the connection has been disconnected since it can't read for the reply.

Could you modify the manifest.json file in config/custom_components/comfoconnect and make sure the requirement line is like this?

  "requirements": ["git+https://github.com/michaelarnauts/aiocomfoconnect.git@debug#aiocomfoconnect==0.1.8.1"],

See changes here: https://github.com/michaelarnauts/aiocomfoconnect/compare/master...debug

This will instruct Home Assistant to use a debug branch of aiocomfoconnect where I have added additional logging when the IncompleteReadError is caught.

This will log the actual exception on why we got an IncompleteReadError.

zollak commented 1 year ago

this command worked for me: tcpdump -s 0 port 56747 -i enp0s18 -w /config/capture3.pcap "Any" interfaces was not good for tcpdump... don't know why. Here you can download the dump: https://drive.google.com/drive/folders/14dStTUCdst72gTy7Szn3rt5bxP94Sq94

zollak commented 1 year ago

I have modified the manifest.js as well. Here is the log after the new trial to add integration:

2023-08-01 16:59:20.010 DEBUG (MainThread) [aiocomfoconnect.discovery] Socket has been created
2023-08-01 16:59:20.010 DEBUG (MainThread) [aiocomfoconnect.discovery] Sending discovery request to broadcast:56747
2023-08-01 16:59:20.116 DEBUG (MainThread) [aiocomfoconnect.discovery] Data received from ('192.168.8.208', 56747): b'\x12#\n\r192.168.8.208\x12\x10\x00\x00\x00\x00\x00.\x10\x16\x80\x01\x14O\xd7\x1e1a\x18\x01'
2023-08-01 16:59:23.265 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnecting from bridge 192.168.8.208
2023-08-01 16:59:23.265 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnected from bridge 192.168.8.208
2023-08-01 16:59:23.265 DEBUG (MainThread) [aiocomfoconnect.bridge] Connecting to bridge 192.168.8.208
2023-08-01 16:59:23.267 DEBUG (MainThread) [aiocomfoconnect.bridge] Connected to bridge 192.168.8.208
2023-08-01 16:59:23.267 DEBUG (MainThread) [aiocomfoconnect.bridge] StartSessionRequest
2023-08-01 16:59:23.267 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 1
2023-08-01 16:59:23.267 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 61352a31eb3d314b0c37a77a827e3fe5 -> 00000000002e10168001144fd71e3161: 08032001 0801
type: StartSessionRequestType
reference: 1

takeover: true

2023-08-01 16:59:23.792 DEBUG (MainThread) [aiocomfoconnect.bridge] RX 00000000002e10168001144fd71e3161 -> 61352a31eb3d314b0c37a77a827e3fe5: 083510052001 
type: StartSessionConfirmType
result: NOT_ALLOWED
reference: 1

2023-08-01 16:59:23.792 DEBUG (MainThread) [aiocomfoconnect.bridge] Emitting for event 1
2023-08-01 16:59:23.792 DEBUG (MainThread) [aiocomfoconnect.bridge] RegisterAppRequest
2023-08-01 16:59:23.792 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 2
2023-08-01 16:59:23.792 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 61352a31eb3d314b0c37a77a827e3fe5 -> 00000000002e10168001144fd71e3161: 08022002 0a1061352a31eb3d314b0c37a77a827e3fe510001a20486f6d6520417373697374616e742028486f6d652d537a6f6c6f6c6967657429
type: RegisterAppRequestType
reference: 2

uuid: "a5*1\353=1K\0147\247z\202~?\345"
pin: 0
devicename: "Home Assistant (Home-Szololiget)"

2023-08-01 16:59:23.794 INFO (MainThread) [aiocomfoconnect.bridge] The connection was closed.
2023-08-01 16:59:28.793 WARNING (MainThread) [aiocomfoconnect.bridge] Timeout while waiting for response from bridge
2023-08-01 16:59:28.797 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnecting from bridge 192.168.8.208
2023-08-01 16:59:28.797 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnected from bridge 192.168.8.208
2023-08-01 16:59:28.797 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/config/custom_components/comfoconnect/config_flow.py", line 133, in _register
    await self.bridge.cmd_start_session(True)
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 168, in _send
    return await asyncio.wait_for(fut, TIMEOUT)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 213, in _read_messages
    message = await self._read()
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 199, in _read
    raise ComfoConnectNotAllowed(message)
aiocomfoconnect.exceptions.ComfoConnectNotAllowed: 00000000002e10168001144fd71e3161 -> 61352a31eb3d314b0c37a77a827e3fe5: 083510052001 
type: StartSessionConfirmType
result: NOT_ALLOWED
reference: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 168, in _send
    return await asyncio.wait_for(fut, TIMEOUT)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 297, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 393, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/comfoconnect/config_flow.py", line 68, in async_step_user
    return await self._register()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/comfoconnect/config_flow.py", line 138, in _register
    await self.bridge.cmd_register_app(
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 171, in _send
    raise AioComfoConnectTimeout from exc
aiocomfoconnect.exceptions.AioComfoConnectTimeout
michaelarnauts commented 1 year ago

Hmm, it looks like my change wasn't applied. Have you restarted Home Assistant before retrying? It's supposed to output additional info before the following line:

2023-08-01 16:59:23.794 INFO (MainThread) [aiocomfoconnect.bridge] The connection was closed.

I've got your pcap, you can remove it from your drive if you want. The odd thing is that I actually see a FIN bit being set by 192.168.8.208 (packet 9), indicating that it wants to close the connection.

I'm not sure why this could be happening.

michaelarnauts commented 1 year ago

You should also see Home Assistant updating the aiocomfoconnect message in the log the first time after restarting. You can try again by upping the version number at the end of the requirements line. Home Assistant will only update if it is newer than the version it already has.

zollak commented 1 year ago

The pcap file, I have seen the packets, but the FIN seems as a normal close by the HA server...

Now, I have rebooted the full server, let's see:

This snippet came when I opened the integration panel and its discovered the IP I have:

2023-08-01 17:10:26.959 DEBUG (MainThread) [aiocomfoconnect.discovery] Socket has been created
2023-08-01 17:10:26.959 DEBUG (MainThread) [aiocomfoconnect.discovery] Sending discovery request to broadcast:56747
2023-08-01 17:10:26.979 DEBUG (MainThread) [aiocomfoconnect.discovery] Data received from ('192.168.8.208', 56747): b'\x12#\n\r192.168.8.208\x12\x10\x00\x00\x00\x00\x00.\x10\x16\x80\x01\x14O\xd7\x1e1a\x18\x01'

Here comes the error:

2023-08-01 17:11:40.170 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnected from bridge 192.168.8.208
2023-08-01 17:11:40.170 DEBUG (MainThread) [aiocomfoconnect.bridge] Connecting to bridge 192.168.8.208
2023-08-01 17:11:40.171 DEBUG (MainThread) [aiocomfoconnect.bridge] Connected to bridge 192.168.8.208
2023-08-01 17:11:40.171 DEBUG (MainThread) [aiocomfoconnect.bridge] StartSessionRequest
2023-08-01 17:11:40.171 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 1
2023-08-01 17:11:40.171 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 44a17e508789c51d69a9a452aa9552b4 -> 00000000002e10168001144fd71e3161: 08032001 0801
type: StartSessionRequestType
reference: 1

takeover: true

2023-08-01 17:11:40.691 DEBUG (MainThread) [aiocomfoconnect.bridge] RX 00000000002e10168001144fd71e3161 -> 44a17e508789c51d69a9a452aa9552b4: 083510052001 
type: StartSessionConfirmType
result: NOT_ALLOWED
reference: 1

2023-08-01 17:11:40.691 DEBUG (MainThread) [aiocomfoconnect.bridge] Emitting for event 1
2023-08-01 17:11:40.691 DEBUG (MainThread) [aiocomfoconnect.bridge] RegisterAppRequest
2023-08-01 17:11:40.692 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 2
2023-08-01 17:11:40.692 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 44a17e508789c51d69a9a452aa9552b4 -> 00000000002e10168001144fd71e3161: 08022002 0a1044a17e508789c51d69a9a452aa9552b410001a20486f6d6520417373697374616e742028486f6d652d537a6f6c6f6c6967657429
type: RegisterAppRequestType
reference: 2

uuid: "D\241~P\207\211\305\035i\251\244R\252\225R\264"
pin: 0
devicename: "Home Assistant (Home-Szololiget)"

2023-08-01 17:11:40.693 INFO (MainThread) [aiocomfoconnect.bridge] The connection was closed.
2023-08-01 17:11:45.692 WARNING (MainThread) [aiocomfoconnect.bridge] Timeout while waiting for response from bridge

And the response got back on the UI (Unknown error occured) and a bit later here comes the timeout:

2023-08-01 17:11:45.692 WARNING (MainThread) [aiocomfoconnect.bridge] Timeout while waiting for response from bridge
 File "/usr/local/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 213, in _read_messages
    message = await self._read()
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 199, in _read
    raise ComfoConnectNotAllowed(message)
aiocomfoconnect.exceptions.ComfoConnectNotAllowed: 00000000002e10168001144fd71e3161 -> 44a17e508789c51d69a9a452aa9552b4: 083510052001 
type: StartSessionConfirmType
result: NOT_ALLOWED
reference: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 168, in _send
    return await asyncio.wait_for(fut, TIMEOUT)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 297, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 393, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/comfoconnect/config_flow.py", line 68, in async_step_user
    return await self._register()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/comfoconnect/config_flow.py", line 138, in _register
    await self.bridge.cmd_register_app(
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 171, in _send
    raise AioComfoConnectTimeout from exc
aiocomfoconnect.exceptions.AioComfoConnectTimeout

I have double checked the manifest.json file... still the modified one...

zollak commented 1 year ago

Now, I have to go, in 2 hours I can continue to debug if you have any idea how... Thanks for helping on this... I hope that we can find what is it...

michaelarnauts commented 1 year ago

I've added more debugging to that branch. If you update the version of the manifest line in your manifest.json, it should be downloaded.

The Home Assistant log should contain this line:

2023-08-01 17:09:07.802 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of git+https://github.com/michaelarnauts/aiocomfoconnect.git@debug#aiocomfoconnect==0.1.8.2

Although that FIN flag (it's set on a packet of the bridge to your computer) looks really odd. I wonder if it could be caused by some firewall in your network or something.

zollak commented 1 year ago

I could not see in the log this line that shows the install was successfull... I dont't know what I'm doing wrong.

Log settings:

# Loglevel settings
logger:
  default: warning
  logs:
    # log level for Zehnder
    #homeassistant.components.comfoconnect: info
    aiocomfoconnect: debug
    homeassistant.loader: debug

I have removed the /config/custom_components/comfoconnect directory and recreated with HACS add-on (downloaded again) and modified the manifest.json before restart HA:

{
  "domain": "comfoconnect",
  "name": "Zehnder ComfoAir Q",
  "config_flow": true,
  "documentation": "https://www.home-assistant.io/integrations/comfoconnect",
  "integration_type": "hub",
  "requirements": ["git+https://github.com/michaelarnauts/aiocomfoconnect.git@debug#aiocomfoconnect==0.1.8.2"],
  "codeowners": ["@michaelarnauts"],
  "iot_class": "local_push",
  "loggers": ["aiocomfoconnect"],
  "version": "0.1.8"
}

After restart HA, the log contains only these entries:

2023-08-02 02:03:27.490 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration comfoconnect which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-08-02 02:03:27.491 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-08-02 02:03:27.712 INFO (SyncWorker_2) [homeassistant.loader] Loaded group from homeassistant.components.group
2023-08-02 02:03:27.714 INFO (SyncWorker_0) [homeassistant.loader] Loaded device_tracker from homeassistant.components.device_tracker
2023-08-02 02:03:28.479 INFO (SyncWorker_1) [homeassistant.loader] Loaded google_assistant from homeassistant.components.google_assistant
2023-08-02 02:03:28.481 INFO (SyncWorker_1) [homeassistant.loader] Loaded alexa from homeassistant.components.alexa
2023-08-02 02:03:28.485 INFO (SyncWorker_4) [homeassistant.loader] Loaded camera from homeassistant.components.camera
2023-08-02 02:03:28.585 INFO (SyncWorker_4) [homeassistant.loader] Loaded media_player from homeassistant.components.media_player
2023-08-02 02:03:38.942 INFO (SyncWorker_4) [homeassistant.loader] Loaded binary_sensor from homeassistant.components.binary_sensor
2023-08-02 02:03:38.943 INFO (SyncWorker_4) [homeassistant.loader] Loaded template from homeassistant.components.template
2023-08-02 02:03:38.943 INFO (SyncWorker_0) [homeassistant.loader] Loaded update from homeassistant.components.update
2023-08-02 02:03:39.340 INFO (SyncWorker_0) [homeassistant.loader] Loaded rest from homeassistant.components.rest
2023-08-02 02:03:39.474 INFO (SyncWorker_2) [homeassistant.loader] Loaded systemmonitor from homeassistant.components.systemmonitor
2023-08-02 02:03:39.645 INFO (SyncWorker_1) [homeassistant.loader] Loaded google_translate from homeassistant.components.google_translate
2023-08-02 02:03:40.554 INFO (SyncWorker_1) [homeassistant.loader] Loaded remote from homeassistant.components.remote
2023-08-02 02:03:40.557 INFO (SyncWorker_4) [homeassistant.loader] Loaded switch from homeassistant.components.switch
2023-08-02 02:03:40.585 INFO (SyncWorker_3) [homeassistant.loader] Loaded switch_as_x from homeassistant.components.switch_as_x
2023-08-02 02:03:40.589 INFO (SyncWorker_1) [homeassistant.loader] Loaded button from homeassistant.components.button
2023-08-02 02:03:40.589 INFO (SyncWorker_0) [homeassistant.loader] Loaded alarm_control_panel from homeassistant.components.alarm_control_panel
2023-08-02 02:03:40.594 INFO (SyncWorker_5) [homeassistant.loader] Loaded fan from homeassistant.components.fan
2023-08-02 02:03:40.595 INFO (SyncWorker_5) [homeassistant.loader] Loaded lock from homeassistant.components.lock
2023-08-02 02:03:40.595 INFO (SyncWorker_3) [homeassistant.loader] Loaded siren from homeassistant.components.siren
2023-08-02 02:03:40.596 INFO (SyncWorker_6) [homeassistant.loader] Loaded image from homeassistant.components.image
2023-08-02 02:03:40.596 INFO (SyncWorker_1) [homeassistant.loader] Loaded cover from homeassistant.components.cover
2023-08-02 02:03:40.597 INFO (SyncWorker_2) [homeassistant.loader] Loaded humidifier from homeassistant.components.humidifier
2023-08-02 02:03:40.597 INFO (SyncWorker_5) [homeassistant.loader] Loaded number from homeassistant.components.number
2023-08-02 02:03:40.597 INFO (SyncWorker_4) [homeassistant.loader] Loaded climate from homeassistant.components.climate
2023-08-02 02:03:40.597 INFO (SyncWorker_0) [homeassistant.loader] Loaded select from homeassistant.components.select
2023-08-02 02:03:40.598 INFO (SyncWorker_7) [homeassistant.loader] Loaded light from homeassistant.components.light
2023-08-02 02:03:40.598 INFO (SyncWorker_3) [homeassistant.loader] Loaded text from homeassistant.components.text
2023-08-02 02:03:40.600 INFO (SyncWorker_4) [homeassistant.loader] Loaded water_heater from homeassistant.components.water_heater
2023-08-02 02:03:40.600 INFO (SyncWorker_6) [homeassistant.loader] Loaded vacuum from homeassistant.components.vacuum
2023-08-02 02:03:40.700 INFO (SyncWorker_2) [homeassistant.loader] Loaded notify from homeassistant.components.notify
2023-08-02 02:03:41.142 INFO (SyncWorker_7) [homeassistant.loader] Loaded weather from homeassistant.components.weather
2023-08-02 02:04:19.243 INFO (SyncWorker_8) [homeassistant.loader] Loaded homekit_controller from homeassistant.components.homekit_controller
2023-08-02 02:04:19.289 INFO (SyncWorker_4) [homeassistant.loader] Loaded bluetooth_adapters from homeassistant.components.bluetooth_adapters
2023-08-02 02:04:19.297 INFO (SyncWorker_4) [homeassistant.loader] Loaded esphome from homeassistant.components.esphome
2023-08-02 02:04:19.303 INFO (SyncWorker_4) [homeassistant.loader] Loaded shelly from homeassistant.components.shelly
2023-08-02 02:04:19.316 INFO (SyncWorker_4) [homeassistant.loader] Loaded ruuvi_gateway from homeassistant.components.ruuvi_gateway
2023-08-02 02:04:19.665 INFO (SyncWorker_1) [homeassistant.loader] Loaded thread from homeassistant.components.thread
2023-08-02 02:05:28.148 INFO (SyncWorker_2) [homeassistant.loader] Loaded dlna_dms from homeassistant.components.dlna_dms

When I tried to add in Settings > Integrations > Add integration > search for Zehnder... > Add a ComfoConnect LAN C bridge the log entries shows that the more debug feature not yet loeaded:

2023-08-02 02:05:53.039 DEBUG (MainThread) [aiocomfoconnect.discovery] Socket has been created
2023-08-02 02:05:53.039 DEBUG (MainThread) [aiocomfoconnect.discovery] Sending discovery request to broadcast:56747
2023-08-02 02:05:53.069 DEBUG (MainThread) [aiocomfoconnect.discovery] Data received from ('192.168.8.208', 56747): b'\x12#\n\r192.168.8.208\x12\x10\x00\x00\x00\x00\x00.\x10\x16\x80\x01\x14O\xd7\x1e1a\x18\x01'
2023-08-02 02:06:29.321 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnecting from bridge 192.168.8.208
2023-08-02 02:06:29.321 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnected from bridge 192.168.8.208
2023-08-02 02:06:29.321 DEBUG (MainThread) [aiocomfoconnect.bridge] Connecting to bridge 192.168.8.208
2023-08-02 02:06:29.322 DEBUG (MainThread) [aiocomfoconnect.bridge] Connected to bridge 192.168.8.208
2023-08-02 02:06:29.323 DEBUG (MainThread) [aiocomfoconnect.bridge] StartSessionRequest
2023-08-02 02:06:29.323 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 1
2023-08-02 02:06:29.323 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 625016a3b3cca0b44c6d8d5fa3f3b965 -> 00000000002e10168001144fd71e3161: 08032001 0801
type: StartSessionRequestType
reference: 1

takeover: true

2023-08-02 02:06:29.829 DEBUG (MainThread) [aiocomfoconnect.bridge] RX 00000000002e10168001144fd71e3161 -> 625016a3b3cca0b44c6d8d5fa3f3b965: 083510052001 
type: StartSessionConfirmType
result: NOT_ALLOWED
reference: 1

2023-08-02 02:06:29.829 DEBUG (MainThread) [aiocomfoconnect.bridge] Emitting for event 1
2023-08-02 02:06:29.829 DEBUG (MainThread) [aiocomfoconnect.bridge] RegisterAppRequest
2023-08-02 02:06:29.829 DEBUG (MainThread) [aiocomfoconnect.bridge] Adding listener for event 2
2023-08-02 02:06:29.829 DEBUG (MainThread) [aiocomfoconnect.bridge] TX 625016a3b3cca0b44c6d8d5fa3f3b965 -> 00000000002e10168001144fd71e3161: 08022002 0a10625016a3b3cca0b44c6d8d5fa3f3b96510001a20486f6d6520417373697374616e742028486f6d652d537a6f6c6f6c6967657429
type: RegisterAppRequestType
reference: 2

uuid: "bP\026\243\263\314\240\264Lm\215_\243\363\271e"
pin: 0
devicename: "Home Assistant (Home-Szololiget)"

2023-08-02 02:06:29.830 INFO (MainThread) [aiocomfoconnect.bridge] The connection was closed.
2023-08-02 02:06:34.831 WARNING (MainThread) [aiocomfoconnect.bridge] Timeout while waiting for response from bridge
2023-08-02 02:06:34.835 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnecting from bridge 192.168.8.208
2023-08-02 02:06:34.835 DEBUG (MainThread) [aiocomfoconnect.bridge] Disconnected from bridge 192.168.8.208
2023-08-02 02:06:34.835 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/config/custom_components/comfoconnect/config_flow.py", line 133, in _register
    await self.bridge.cmd_start_session(True)
  File "/usr/local/lib/python3.11/site-packages/aiocomfoconnect/bridge.py", line 168, in _send
    return await asyncio.wait_for(fut, TIMEOUT)
           ^^^^^^^^^^^^^^^
...

Do you have any idea what should I do in a different way? It seems, the manifest.json modification via Studio Code Server was not reloaded after restart/reboot HA.

zollak commented 1 year ago

A little addition info about my network config that might helps. My HA is runnuing on Proxmox. I have added 3 network interfaces to HA server because I use many VLANs. The VLAN tags added by Proxmox, so HA server does not see any differences between interfaces... They are completly different networks... The Proxmox server connected to a managed switch in a trunk port. The main network is that where the LAN C also located. The LAN C connected directly to the same switch where the switch gives the VLAN tag. In this case there is no firewall/router between the LAN C and HA communication. They are able to see each other and if I turn back the official comfoconnect add-on there is no issue with that.

michaelarnauts commented 1 year ago

I assume the reason your old integration is still working is because it is still registered, and it seems that the gateway only disconnects during a registration.

There should be a way to re-use the uuid of the old integration, and I think that's what it should do when it imports the existing configuration. I'll look at that, but the main curiosity is still why the gateway is disconnecting.

I think there is a way to manually add the config entry, I'll see if I can find out how this works.

I'm also running Home Assistant on a Proxmox VM. I assume you are using the installation method with Home Assistant OS?

webflash-aj commented 10 months ago

Hi @michaelarnauts

I have the same problems as @zollak. Do you have any new Information, or ideas to try?

Andy

ehoogend commented 9 months ago

HI @michaelarnauts , same problems here unfortunately. First time user of the Integration, and I haven't used the old one. Exactly the same issues as @zollak is having.

Anything we can try here?

michaelarnauts commented 9 months ago

I really have no idea on how to troubleshoot this further. Could it be related to some strange asymmetric routing? I know some firewalls don't like this. Maybe proxmox has an issue with this? I don't understand your setup really well. You have different VLANs, but no routing between them?

Note that I am running my Home Assistant also on Proxmox, but it's not on the same VLAN as my Comfoconnect LAN C. Therefore, I can't do discovery, but manually adding the IP works fine. I have a pfsense that is routing between those VLANs.

ehoogend commented 9 months ago

I have no firewalls in between HA and the ComfoConnect nor any VLANs. They're both hardwired to the same switch.

I sent an email to Zehnder to hopefully get some support on this. The way I see it, it looks like for some ComfoConnect devices the registration step is just failing for some unknown reason. Maybe the protocol was changed for newer devices/firmwares? I'm not sure

ehoogend commented 7 months ago

@michaelarnauts So in the end I "fixed" this with a forked repo in which I hardcoded the local_uuid instead of using the random_uuid_hex() function which was causing the issues by generating unsupported uuid's it seems. You can see the changes here

I'm hesitant to make a pull request for this since it's more of a workaround than a fix and I'm not sure of the implications of not using the random uuid anymore.

zollak commented 6 months ago

@michaelarnauts So in the end I "fixed" this with a forked repo in which I hardcoded the local_uuid instead of using the random_uuid_hex() function which was causing the issues by generating unsupported uuid's it seems. You can see the changes here

I'm hesitant to make a pull request for this since it's more of a workaround than a fix and I'm not sure of the implications of not using the random uuid anymore.

Thanks for your suggestion! It worked for me too! Now, I have integrated my Q350 this way! @michaelarnauts Consider @ehoogend 's suggestion because it works for me too.

My current versions for HA: OS Version: Home Assistant OS 11.4 Home Assistant Core: 2024.1.5

After that I have had different entity_id's... I was able to replace entity by new one without losing history...

JohnyDeejay commented 6 months ago

Hello. I have simmilar problem here and if I restart the home assistant everything works without any problems. But when it doesn't just shows unknown error.

zollak commented 6 months ago

Hello. I have simmilar problem here and if I restart the home assistant everything works without any problems. But when it doesn't just shows unknown error.

Hi, thanks for your feedback. It is not so clear for me: is a single restart solve the connection issue for you? What versions you have? (HA, LAN-C, Zehnder fw) Did you have an official Comfoconnect integration before you tried to use this HACS integration? Could you please explain more, what environment you have and what are your circumstances?

JohnyDeejay commented 6 months ago

[home-assistant_2024-01-28T16-33-09.677Z.log](https://github.com/michaelarnauts/home-assistant-

Hello. I have simmilar problem here and if I restart the home assistant everything works without any problems. But when it doesn't just shows unknown error.

Hi, thanks for your feedback. It is not so clear for me: is a single restart solve the connection issue for you? What versions you have? (HA, LAN-C, Zehnder fw) Did you have an official Comfoconnect integration before you tried to use this HACS integration? Could you please explain more, what environment you have and what are your circumstances?

Yes single restart solve problem and works for another day. I have:

Each time is error:

I also tried fix, but still the same error after one day. self.local_uuid = "00000000000000000000000000000001" pin or "0000",

Do you maybe have some more info about that error or I just set HA to reboot each day, don't know. If you have any other questions please let me know. home-assistant_2024-01-28T16-33-09.677Z.log

Screenshot_6 Screenshot_7 Screenshot_8 Screenshot_10
zollak commented 6 months ago

Hi @JohnyDeejay, based on your details, it is a different "connection issue", that I opened here. My problem was with the Zehnder ComfoAirQ integration that can be installed from HACS. The initial connection failed when I wanted to add into the integration. Different processes then take place than in your case, which you have already managed to add to your system and the connection problems you indicated appeared during operation.

Now, I have the same issue... I opened a new issue for this: https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/33

michaelarnauts commented 4 months ago

Closing since I want to migrate all these issues in one issue. See https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/43 for a possible solution and follow-up.