KartoffelToby / better_thermostat

This custom component for Home Assistant will add crucial features to your climate-controlling TRV (Thermostatic Radiator Valves) to save you the work of creating automations to make it smart. It combines a room-temperature sensor, window/door sensors, weather forecasts, or an ambient temperature probe to decide when it should call for heat and automatically calibrate your TRVs to fix the imprecise measurements taken in the radiator's vicinity.
https://better-thermostat.org
GNU Affero General Public License v3.0
822 stars 126 forks source link

[Eve Thermo] Home Assistant no longer responds #1394

Open Shimakuchi opened 1 month ago

Shimakuchi commented 1 month ago

Eve Thermo v2 and v3

Description

Home Assistant does not respond anymore.

Steps to Reproduce

Sometimes it happens when setting the temperature, but sometimes it just happens randomly

Expected behavior:

I set a temperature and the thermostat reacts accordingly without Home Assistant being unavailable and me having to restart the Docker container

Actual behavior:

I set a temperature and Home Assistant no longer responds

Versions

Core 2024.9.1 Frontend 20240906.0 BT 1.6.0 BT-UI 2.2.0

Additional Information

I found the following in the log. The second output, the error, then runs on an endless loop and apparently ensures that Home Assistant is no longer accessible

2024-09-16 07:30:18.534 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to import_module with args ('custom_components.better_thermostat.adapters.generic',) inside the event loop by custom integration 'better_thermostat' at custom_components/better_thermostat/adapters/delegate.py, line 27: self.adapter = import_module( (offender: /config/custom_components/better_thermostat/adapters/delegate.py, line 27: self.adapter = import_module(), please create a bug report at https://github.com/KartoffelToby/better_thermostat/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#import_module
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.12/site-packages/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.12/site-packages/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/config_entries.py", line 752, in async_setup_locked
    await self.async_setup(hass, integration=integration)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/better_thermostat/__init__.py", line 35, in async_setup_entry
    await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/config_entries.py", line 2121, in async_forward_entry_setups
    await self._async_forward_entry_setups_locked(entry, platforms)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/config_entries.py", line 2132, in _async_forward_entry_setups_locked
    await asyncio.gather(
  File "/usr/local/lib/python3.12/site-packages/homeassistant/config_entries.py", line 2134, in <genexpr>
    create_eager_task(
  File "/usr/local/lib/python3.12/site-packages/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/config_entries.py", line 2214, in _async_forward_entry_setup
    await entry.async_setup(self.hass, integration=integration)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/climate/__init__.py", line 226, in async_setup_entry
    return await component.async_setup_entry(entry)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 194, in async_setup_entry
    return await self._platforms[key].async_setup_entry(config_entry)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 328, in async_setup_entry
    return await self._async_setup_platform(async_create_setup_awaitable)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 358, in _async_setup_platform
    awaitable = create_eager_task(awaitable, loop=hass.loop)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/config/custom_components/better_thermostat/climate.py", line 135, in async_setup_entry
    async_add_devices(
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 510, in _async_schedule_add_entities_for_entry
    task = self.config_entry.async_create_task(
  File "/usr/local/lib/python3.12/site-packages/homeassistant/config_entries.py", line 1152, in async_create_task
    task = hass.async_create_task_internal(
  File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 829, in async_create_task_internal
    task = create_eager_task(target, name=name, loop=self.loop)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 644, in async_add_entities
    await add_func(coros, entities, timeout)
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 595, in _async_add_entities
    await coro
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 909, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 1365, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/better_thermostat/climate.py", line 338, in async_added_to_hass
    _adapter = load_adapter(self, trv["integration"], trv["trv"])
  File "/config/custom_components/better_thermostat/adapters/delegate.py", line 27, in load_adapter
    self.adapter = import_module(
2024-09-16 07:44:51.835 ERROR (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: ERROR controlling: climate.heizung_arbeitszimmer
Traceback (most recent call last):
  File "/config/custom_components/better_thermostat/utils/controlling.py", line 53, in control_queue
    _temp = await control_trv(self, trv)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/better_thermostat/utils/controlling.py", line 277, in control_trv
    await set_temperature(self, heater_entity_id, _temperature)
  File "/config/custom_components/better_thermostat/adapters/delegate.py", line 77, in set_temperature
    return await self.real_trvs[entity_id]["adapter"].set_temperature(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/better_thermostat/adapters/generic.py", line 111, in set_temperature
    await self.hass.services.async_call(
  File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 996, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/climate/__init__.py", line 939, in async_service_temperature_set
    raise ServiceValidationError(
homeassistant.exceptions.ServiceValidationError: Provided temperature 35.0 is not valid. Accepted range is 10.0 to 30.0
KleinRiese commented 1 month ago

Same here: homeassistant.exceptions.ServiceValidationError: Provided temperature 35.0 is not valid. Accepted range is 5 to 25

KleinRiese commented 1 month ago

Dirty Workaround, seems to work:

Edit custom_components/better_thermostat/utils/controlling.py and change the code starting at line 267:

if _temperature != _current_set_temperature: if _temperature > 25: _temperature = 25 old = self.real_trvs[heater_entity_id].get("last_temperature", "?")

Pay attention to the correct indentation an alter 25 to whatever you need. I hardcoded "bt_max_temp" to 25 before and the problem persists. Seems the limits are not checked within the calculation or the limits of different trvs gets mixed up.

VladimirWrites commented 1 month ago

I had the same issue. I am using Bosch Thermostat 230v. Just tested the fix, and this seems to solve the problem. Thank you!

YordiDR commented 1 month ago

Hi, i've got the same issue, home assistant is not responding anymore because of this. It's happening daily for me now. Where do you find the target temperature? my journalctl logs don't show the temperature invalid temperature error though. Where do you find this?

KleinRiese commented 1 month ago

Look in HA's base directory, you should find a file named 'home-assistant.log'.

starhopper1 commented 1 month ago

@KleinRiese hi i tried you fix but i can´t get the indentation to work, i tried switsching around different spaces or even tabs.. Can you give a hint for indentation? here is the error : File "/config/custom_components/better_thermostat/utils/controlling.py", line 270 old = self.real_trvs[heater_entity_id].get("last_temperature", "?") ^ IndentationError: unindent does not match any outer indentation level

i didn´t even change that line, only added the two above like in you post, maby you or someone sees my mistake.

KleinRiese commented 1 month ago

@starhopper1 well, for the sake of simplicity I attached my controlling.py (limited to 25) 😊

controlling.zip

starhopper1 commented 1 month ago

thanks ok i see my error.

KartoffelToby commented 1 day ago

you use all eve devices? can someone provide the org. eve HA Debug infos from this device?

KleinRiese commented 1 day ago

No, I use mainly Tado but have 2 different Tuya-Devices:

config_entry-better_thermostat-df3bd9b0e2143f643d7ffc5772d50da2.json config_entry-better_thermostat-81be3c65bda4aeae19bd4910bce7503b.json

jusicgn commented 21 hours ago

@KartoffelToby maybe I can help. I'm running with 8 Eve Thermo over Matter. What exactly do you need?

image

This? And if so, do I have to edit out some confidential information before uploading here or is there nothig to worry about?

KartoffelToby commented 21 hours ago

Yes its safe. Its a function from ha itself

jusicgn commented 20 hours ago

@KartoffelToby alright, so here is the debug of one of my Eve Thermo connected via Matter integration. Hope it helps :)

matter-7dba542cd06503fb22e72db21f6a6f1c-Eve Thermo 20EBP1701-f161eec3ec993cb2a6832e824a1045a8.json