rikroe / cometblue-custom-component

Eurotronic CometBlue custom component for HomeAssistant
MIT License
0 stars 0 forks source link

Can not add Thermostat due to Timeout Error #1

Open DerGary opened 5 days ago

DerGary commented 5 days ago

Good Day!

I am new to Home Assistant and wanted to make my Heating smart, I got some TRVs from my Father that were lying around that are Eurotronic Comet Blues. And I stumbled upon your custom component and immediately tried it out. I could install it via HACS on my Home Assistant Container Instance which I host via Docker. I mounted a bluetooth usb stick into the container and immediately after installing your component it picked up the Thermostat: image

I used these settings: image

Although in the manual it states that the PIN is 000 000, but I was unable to set that PIN due to the fact that the number chooser does not allow multiple zero digits. After pressing next and waiting some time I was greeted with this message: image

but also an error in the integration: image

In the error log I could only figure out these lines, which do not help me to correct the error:

2024-10-10 13:19:59.562 DEBUG (MainThread) [cometblue] Setting up device D0:B5:C2:F1:6D:23: Comet Blue
2024-10-10 13:19:59.562 DEBUG (MainThread) [cometblue] Connecting to D0:B5:C2:F1:6D:23: Comet Blue
2024-10-10 13:20:19.565 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Comet Blue D0:B5:C2:F1:6D:23 for cometblue
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/bleak/backends/bluezdbus/client.py", line 214, in connect
    reply = await self._bus.call(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dbus_fast/aio/message_bus.py", line 385, in call
    await future
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/cometblue/__init__.py", line 60, in async_setup_entry
    async with cometblue_device:
  File "/usr/local/lib/python3.12/site-packages/cometblue/__init__.py", line 626, in __aenter__
    await self.connect_async()
  File "/usr/local/lib/python3.12/site-packages/cometblue/__init__.py", line 404, in connect_async
    await self.client.connect()
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 311, in connect
    connected = await super().connect(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 615, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/backends/bluezdbus/client.py", line 151, in connect
    async with async_timeout(timeout):
  File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

Is there anything I can do to make it work?

Greetings Gary

rikroe commented 4 days ago

Thanks for you interest! You're the first one to try it out (except for me).

Bluetooth devices are not very stable. You can try to reload the integration and hope that it works then. The TimeoutError occurs (in your case) the bluetooth stick is not able to connect to the CometBlue device.

This can also happen during runtime, but will usually recover itself. For you, the main issue is that this failure occurs during initial setup (after your bluetooth stick has seen that the device is around).

Is there a good connection between the bluetooth stick and the device? Maybe use a USB extension to not have the bluetooth stick directly at the computer.

DerGary commented 4 days ago

So I already tried installing the latest version of bluez on my host which unfortunately did not resolve the Problem.

Is there a good connection between the bluetooth stick and the device

I don't know exactly because It won't connect but the device was right next to the bluetooth stick when I tried it.

Maybe use a USB extension to not have the bluetooth stick directly at the computer.

I tried this now and interestingly It picked up more of my thermostats and it also successfully integrated one of them, but all others are still erroring out:

image

And for the one that is connected I am unable to change anything because it just returns errors. Unfortunately I was not able to reproduce the error message it is now just not doing anything after I changed something in the Climate UI

image

I am starting to think that these devices are not the right fit for my use case, They would also need to communicate a distance that will likely not work with bluetooth, I think I need to switch to Zigbee Thermostats which is the protocol I use for the rest of my smart devices 🤔

rikroe commented 3 days ago

Can you enable debug logging for the integration?

It could also be that there are issues with your Bluetooth stick, not sure. I have developed it on a MacBook with the TRV right next to it.

It is now running quite good for me. To gap the distances between my homeserver I'm using 2 ESPHome devices as Bluetooth proxies.

I also wanted to replace the Bluetooth TRVs and bought some zigbee (tuya based) ones from Lidl last year (because they are were only €30). They are even worse...

DerGary commented 1 day ago

Hello Richard,

I wanted to give an update. I ordered 2 ESP32 an Amazon on Saturday and they arrived today. I flashed them with the ESPHome Bluetooth Proxy Firmware. Initially I had some errors that some of the values returned by the Comet Blue Thermostats would be invalid, but after factory resetting all of them I could now integrate them into home assistant and can read and write temperatures. So for now everything looks very promising. All 6 Thermostats are connected and seem working.

Thank you for the tipp with the Bluetooth Proxies and your custom component. 🙏

Seems like we can close this issue then.

rikroe commented 1 day ago

Hi Gary, great to hear and thanks for the update! Please be aware that you will get regular log entries about missing connections - usually however that is nothing to be worried about and will automatically recover.

Enjoy some cheap (but effective) radiator controls!

DerGary commented 8 hours ago

Hi Richard,

I am trying it out a bit and noticed that most of the time when I try to change the Temperature by Home Assistant it is not applied and sometimes it displays an error about a timeout. It does not recover itself after I set the temperature, when the connection is reestablished it shows the old target temperature instead of the new one. The log says that the timeout is 20seconds, is there a way to increase that?

Here are some logs:


2024-10-15 11:03:27.011 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Comet Blue D0:B5:C2:F1:6D:23 for cometblue
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 584, in bluetooth_device_connect
    await connect_future
TimeoutError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 297, in connect
    await self._client.bluetooth_device_connect(
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 604, in bluetooth_device_connect
    raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to D0:B5:C2:F1:6D:23 after 20s, disconnect timed out: True,  after 20.0s

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/cometblue/__init__.py", line 60, in async_setup_entry
    async with cometblue_device:
  File "/usr/local/lib/python3.12/site-packages/cometblue/__init__.py", line 626, in __aenter__
    await self.connect_async()
  File "/usr/local/lib/python3.12/site-packages/cometblue/__init__.py", line 404, in connect_async
    await self.client.connect()
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 311, in connect
    connected = await super().connect(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 615, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 79, in _async_wrap_bluetooth_operation
    raise asyncio.TimeoutError(str(err)) from err
TimeoutError: Timeout waiting for connect response while connecting to D0:B5:C2:F1:6D:23 after 20s, disconnect timed out: True,  after 20.0s
2024-10-15 11:06:16.014 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140634712054160] Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/cometblue/coordinator.py", line 66, in send_command
    async with self.device:
  File "/usr/local/lib/python3.12/site-packages/cometblue/__init__.py", line 626, in __aenter__
    await self.connect_async()
  File "/usr/local/lib/python3.12/site-packages/cometblue/__init__.py", line 416, in connect_async
    raise ex
  File "/usr/local/lib/python3.12/site-packages/cometblue/__init__.py", line 404, in connect_async
    await self.client.connect()
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 311, in connect
    connected = await super().connect(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 615, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 327, in connect
    await connected_future
bleak.exc.BleakError: Error ESP_GATT_CONN_FAIL_ESTABLISH while connecting: Connection failed to establish

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 1029, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/config/custom_components/cometblue/climate.py", line 146, in async_set_temperature
    await self.coordinator.send_command(
  File "/config/custom_components/cometblue/coordinator.py", line 77, in send_command
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Error sending command '{'values': {'manualTemp': 16.5, 'targetTempLow': None, 'targetTempHigh': None}}' to 'climate.thermostat_arbeitszimmer_links': Error ESP_GATT_CONN_FAIL_ESTABLISH while connecting: Connection failed to establish
2024-10-15 11:07:25.207 DEBUG (MainThread) [custom_components.cometblue.coordinator] Updating device with 'climate.thermostat_arbeitszimmer_links' from '{'values': {'manualTemp': 16.5, 'targetTempLow': None, 'targetTempHigh': None}}'
2024-10-15 11:07:25.207 DEBUG (MainThread) [cometblue] Setting up device D0:B5:C2:F1:6D:23: Comet Blue
2024-10-15 11:07:25.208 DEBUG (MainThread) [cometblue] Connecting to D0:B5:C2:F1:6D:23: Comet Blue
2024-10-15 11:08:00.460 DEBUG (MainThread) [cometblue] Setting up device D0:B5:C2:F1:64:C3: Comet Blue
2024-10-15 11:08:00.460 DEBUG (MainThread) [cometblue] Connecting to D0:B5:C2:F1:64:C3: Comet Blue
2024-10-15 11:08:00.565 DEBUG (MainThread) [cometblue] Setting up device D0:B5:C2:F1:64:B6: Comet Blue
2024-10-15 11:08:00.565 DEBUG (MainThread) [cometblue] Connecting to D0:B5:C2:F1:64:B6: Comet Blue
2024-10-15 11:08:02.462 DEBUG (MainThread) [cometblue] Setting up device D0:B5:C2:F1:64:EB: Comet Blue
2024-10-15 11:08:02.462 DEBUG (MainThread) [cometblue] Connecting to D0:B5:C2:F1:64:EB: Comet Blue
2024-10-15 11:08:03.252 DEBUG (MainThread) [cometblue] Setting up device D0:B5:C2:FA:D7:98: Comet Blue
2024-10-15 11:08:03.252 DEBUG (MainThread) [cometblue] Connecting to D0:B5:C2:FA:D7:98: Comet Blue
2024-10-15 11:08:04.148 DEBUG (MainThread) [cometblue] Established connection to D0:B5:C2:F1:64:C3: Comet Blue
2024-10-15 11:08:04.252 DEBUG (MainThread) [cometblue] Connected to D0:B5:C2:F1:64:C3: Comet Blue
2024-10-15 11:08:05.070 DEBUG (MainThread) [custom_components.cometblue.coordinator] Received data: {'battery': 60, 'holiday': {}, 'targetTempLow': 16.0, 'windowOpen': None, 'targetTempHigh': 21.0, 'manualTemp': 21.0, 'tempOffset': None, 'currentTemp': 21.5, 'windowOpenMinutes': 10}
2024-10-15 11:08:05.070 DEBUG (MainThread) [custom_components.cometblue.coordinator] Finished fetching Comet Blue D0:B5:C2:F1:64:C3 data in 4.609 seconds (success: True)
2024-10-15 11:08:05.211 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140634712054160] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 584, in bluetooth_device_connect
    await connect_future
TimeoutError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 297, in connect
    await self._client.bluetooth_device_connect(
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 604, in bluetooth_device_connect
    raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to D0:B5:C2:F1:6D:23 after 20s, disconnect timed out: True,  after 20.0s

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 1029, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/config/custom_components/cometblue/climate.py", line 146, in async_set_temperature
    await self.coordinator.send_command(
  File "/config/custom_components/cometblue/coordinator.py", line 66, in send_command
    async with self.device:
  File "/usr/local/lib/python3.12/site-packages/cometblue/__init__.py", line 626, in __aenter__
    await self.connect_async()
  File "/usr/local/lib/python3.12/site-packages/cometblue/__init__.py", line 404, in connect_async
    await self.client.connect()
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 311, in connect
    connected = await super().connect(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 615, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 79, in _async_wrap_bluetooth_operation
    raise asyncio.TimeoutError(str(err)) from err
TimeoutError: Timeout waiting for connect response while connecting to D0:B5:C2:F1:6D:23 after 20s, disconnect timed out: True,  after 20.0s
2024-10-15 11:08:08.561 DEBUG (MainThread) [cometblue] Established connection to D0:B5:C2:FA:D7:98: Comet Blue
2024-10-15 11:08:08.653 DEBUG (MainThread) [cometblue] Connected to D0:B5:C2:FA:D7:98: Comet Blue
2024-10-15 11:08:09.883 DEBUG (MainThread) [custom_components.cometblue.coordinator] Received data: {'battery': 76, 'holiday': {}, 'targetTempLow': 16.0, 'windowOpen': None, 'targetTempHigh': 21.0, 'manualTemp': 21.0, 'tempOffset': None, 'currentTemp': 22.5, 'windowOpenMinutes': 10}
2024-10-15 11:08:09.883 DEBUG (MainThread) [custom_components.cometblue.coordinator] Finished fetching Comet Blue D0:B5:C2:FA:D7:98 data in 6.631 seconds (success: True)
2024-10-15 11:08:10.263 DEBUG (MainThread) [cometblue] Setting up device D0:B5:C2:F1:64:E3: Comet Blue
2024-10-15 11:08:10.263 DEBUG (MainThread) [cometblue] Connecting to D0:B5:C2:F1:64:E3: Comet Blue
2024-10-15 11:08:19.531 DEBUG (MainThread) [cometblue] Error connecting to D0:B5:C2:F1:64:B6: Comet Blue. Timeout 22s, try 1.
2024-10-15 11:08:19.531 ERROR (MainThread) [custom_components.cometblue.coordinator] Error fetching Comet Blue D0:B5:C2:F1:64:B6 data: (BleakError) Error ESP_GATT_CONN_FAIL_ESTABLISH while connecting: Connection failed to establish
2024-10-15 11:08:19.531 DEBUG (MainThread) [custom_components.cometblue.coordinator] Finished fetching Comet Blue D0:B5:C2:F1:64:B6 data in 18.967 seconds (success: False)
2024-10-15 11:08:25.553 DEBUG (MainThread) [cometblue] Established connection to D0:B5:C2:F1:64:E3: Comet Blue
2024-10-15 11:08:25.651 DEBUG (MainThread) [cometblue] Connected to D0:B5:C2:F1:64:E3: Comet Blue
2024-10-15 11:08:26.986 DEBUG (MainThread) [custom_components.cometblue.coordinator] Received data: {'battery': 77, 'holiday': {}, 'targetTempLow': 16.0, 'windowOpen': None, 'targetTempHigh': 21.0, 'manualTemp': 16.0, 'tempOffset': None, 'currentTemp': 19.0, 'windowOpenMinutes': 10}
2024-10-15 11:08:26.986 DEBUG (MainThread) [custom_components.cometblue.coordinator] Finished fetching Comet Blue D0:B5:C2:F1:64:E3 data in 16.723 seconds (success: True)
2024-10-15 11:08:42.463 ERROR (MainThread) [custom_components.cometblue.coordinator] Error fetching Comet Blue D0:B5:C2:F1:64:EB data: (TimeoutError) Timeout waiting for connect response while connecting to D0:B5:C2:F1:64:EB after 20s, disconnect timed out: True,  after 20.0s
2024-10-15 11:08:42.463 DEBUG (MainThread) [custom_components.cometblue.coordinator] Finished fetching Comet Blue D0:B5:C2:F1:64:EB data in 40.001 seconds (success: False)