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
846 stars 128 forks source link

bt unavailable #1396

Closed Wave89 closed 1 month ago

Wave89 commented 2 months ago

Prerequisites

tuya devices

"home_assistant": {
      "name": "HK2OGK",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "climate.hk2ogk",
            "state": "heat_cool",
            "attributes": {
              "hvac_modes": [
                "off",
                "heat_cool",
                "heat_cool",
                "heat"
              ],
              "min_temp": 5.0,
              "max_temp": 30.0,
              "target_temp_step": 0.5,
              "preset_modes": [
                "holiday",
                "holidayready"
              ],
              "current_temperature": 19.0,
              "temperature": 18.5,
              "preset_mode": null,
              "friendly_name": "HK2OGK",
              "supported_features": 17
            },
            "last_changed": "2024-09-16T23:07:13.401632+00:00",
            "last_reported": "2024-09-17T06:19:36.987329+00:00",
            "last_updated": "2024-09-17T06:19:36.987329+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": "battery",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": "%",
          "state": {
            "entity_id": "sensor.hk2ogk_battery",
            "state": "100.0",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "%",
              "device_class": "battery",
              "friendly_name": "HK2OGK Battery"
            },
            "last_changed": "2024-09-16T23:07:13.414438+00:00",
            "last_reported": "2024-09-16T23:07:13.414438+00:00",
            "last_updated": "2024-09-16T23:07:13.414438+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.hk2ogk_child_lock",
            "state": "on",
            "attributes": {
              "friendly_name": "HK2OGK Child lock"
            },
            "last_changed": "2024-09-16T23:07:13.418306+00:00",
            "last_reported": "2024-09-16T23:07:13.418306+00:00",
            "last_updated": "2024-09-16T23:07:13.418306+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.hk2ogk_open_window_detection",
            "state": "off",
            "attributes": {
              "friendly_name": "HK2OGK Open window detection"
            },
            "last_changed": "2024-09-16T23:07:13.418416+00:00",
            "last_reported": "2024-09-16T23:07:13.418416+00:00",
            "last_updated": "2024-09-16T23:07:13.418416+00:00"
          }
        }
      ]
    },
    "set_up": true,
    "support_local": true
  }
}

Actual behavior:

It is working quiete a while until it's crashed or it is unavailable directly from reboot.

Versions

"home_assistant": { "installation_type": "Home Assistant OS", "version": "2024.9.2", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.12.4", "docker": true, "arch": "aarch64", "timezone": "Europe/Berlin", "os_name": "Linux", "os_version": "6.6.31-haos-raspi", "supervisor": "2024.09.1", "host_os": "Home Assistant OS 13.1", "docker_version": "26.1.4", "chassis": "embedded", "run_as_root": true }, "better_thermostat": { "documentation": "https://github.com/KartoffelToby/better_thermostat", "version": "1.6.0", "requirements": [] },

Additional Information

One Log File response is: Logger: homeassistant.util.loop Source: util/loop.py:136 First occurred: 1:07:12 AM (4 occurrences) Last logged: 1:07:12 AM

Detected blocking call to import_module with args ('custom_components.better_thermostat.adapters.tuya',) inside the event loop by custom integration 'better_thermostat' at custom_components/better_thermostat/adapters/delegate.py, line 16: self.adapter = import_module( (offender: /config/custom_components/better_thermostat/adapters/delegate.py, line 16: 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 "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 223, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/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/src/homeassistant/homeassistant/config_entries.py", line 752, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/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/src/homeassistant/homeassistant/config_entries.py", line 2121, in async_forward_entry_setups await self._async_forward_entry_setups_locked(entry, platforms) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2132, in _async_forward_entry_setups_locked await asyncio.gather( File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2134, in create_eagertask( File "/usr/src/homeassistant/homeassistant/util/async.py", line 45, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2214, in _async_forward_entry_setup await entry.async_setup(self.hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 226, in async_setup_entry return await component.async_setup_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 194, in async_setup_entry return await self._platforms[key].async_setup_entry(config_entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 328, in async_setup_entry return await self._async_setup_platform(async_create_setup_awaitable) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 358, in _async_setup_platform awaitable = create_eagertask(awaitable, loop=hass.loop) File "/usr/src/homeassistant/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/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in _async_schedule_add_entities_for_entry task = self.config_entry.async_create_task( File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1152, in async_create_task task = hass.async_create_task_internal( File "/usr/src/homeassistant/homeassistant/core.py", line 829, in async_create_task_internal task = create_eagertask(target, name=name, loop=self.loop) File "/usr/src/homeassistant/homeassistant/util/async.py", line 45, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 644, in async_add_entities await add_func(coros, entities, timeout) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 595, in _async_add_entities await coro File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 909, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/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 16, in load_adapter self.adapter = import_module(

The error message is later: This error originated from a custom integration.

Logger: custom_components.better_thermostat.utils.controlling Source: custom_components/better_thermostat/utils/controlling.py:53 integration: Better Thermostat (documentation, issues) First occurred: 7:45:00 AM (24 occurrences) Last logged: 8:12:08 AM

better_thermostat None: ERROR controlling: climate.hk2ogk better_thermostat None: ERROR controlling: climate.tv05_zg_curve_7 better_thermostat None: ERROR controlling: climate.tv05_zg_curve_8 better_thermostat None: ERROR controlling: climate.hk1ogaz 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 220, in control_trv await set_hvac_mode(self, heater_entity_id, _new_hvac_mode) File "/config/custom_components/better_thermostat/adapters/delegate.py", line 84, in set_hvac_mode return await self.real_trvs[entity_id]["adapter"].set_hvac_mode( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/better_thermostat/adapters/generic.py", line 124, in set_hvac_mode await self.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 758, in async_set_hvac_mode await self.hass.async_add_executor_job(self.set_hvac_mode, hvac_mode) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/tuya/climate.py", line 290, in set_hvac_mode self._send_command(commands) File "/usr/src/homeassistant/homeassistant/components/tuya/base.py", line 276, in _send_command self.device_manager.send_commands(self.device.id, commands) File "/usr/local/lib/python3.12/site-packages/tuya_sharing/manager.py", line 93, in send_commands return self.device_repository.send_commands(device_id, commands) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tuya_sharing/device.py", line 180, in send_commands self.api.post(f"/v1.1/m/thing/{device_id}/commands", None, {"commands": commands}) File "/usr/local/lib/python3.12/site-packages/tuya_sharing/customerapi.py", line 192, in post return self.__request("POST", path, params, body) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tuya_sharing/customerapi.py", line 121, in __request raise Exception(f"network error:({ret['code']}) {ret['msg']}") Exception: network error:(2008) command or value not support

StevenStreller commented 1 month ago

I have the same error with my thermostat. Solving the problem would be great!

tco99ttocs commented 1 month ago

thats an old problem: there is an workaround here (Issue 1322)

Wave89 commented 1 month ago

thats an old problem: there is an workaround here (Issue 1322)

Thank you @tco99ttocs for the hint. I tried it workaround and it works. I would be nice to intergrate it in a new version. So I'm closing that point.