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
872 stars 130 forks source link

Show add status entity with reason for "not avaiable" #1431

Open der-seemann opened 3 weeks ago

der-seemann commented 3 weeks ago

What is the feature?

Me and may other users have problems that under some circumstances a Better Tmermostat Entity is "not avaiable". Sometimes it is very difficult to find the reason why it is not loading. There might be a Problem with the original thermostat entity, or with a sensor, or something else... It would be great if there is an Status entity for each BetterThermostat device showing the reason why it is not avaiable.

Description

Additional Information

Panoramiac commented 3 weeks ago

I currently encounter the issue that a BT is not available, but all Zigbee devices are fine. A reload of the BT or a configuration loop with removing and then adding the window sensor again fixes the issues. Need to get a goog debug log and create an bug ticket.

KartoffelToby commented 3 weeks ago

BT shoud send a HA Repair issue with detaild infos, or if you use the BT UI its displayed in the UI itself.

okba-zoueghi commented 2 weeks ago

@KartoffelToby I am facing the same issue, I have seen nothing in HA Repairs coming from BT. However I enabled debug logs and I see the following:

2024-11-07 18:25:30.722 INFO (MainThread) [custom_components.better_thermostat.adapters.delegate] better_thermostat None: integration: tuya isn't native supported, feel free to open an issue, fallback adapter generic
2024-11-07 18:25:30.778 INFO (MainThread) [custom_components.better_thermostat.climate] better_thermostat better thermostat office: Waiting for entity to be ready...
2024-11-07 18:25:39.110 INFO (MainThread) [custom_components.better_thermostat.climate] better_thermostat better thermostat office: Starting version 1.6.1. Waiting for entity to be ready...
2024-11-07 18:25:39.110 DEBUG (MainThread) [custom_components.better_thermostat.climate] better_thermostat better thermostat office: Undefined target temperature, falling back to 30.0
2024-11-07 18:25:39.110 DEBUG (MainThread) [custom_components.better_thermostat.climate] better_thermostat better thermostat office: No previously hvac mode found on startup, turn bt to trv mode heat
2024-11-07 18:25:39.110 DEBUG (MainThread) [custom_components.better_thermostat.climate] better_thermostat better thermostat office: Startup config, BT hvac mode is heat, Target temp 30.0
2024-11-07 18:25:39.113 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat None: climate.thermostat_office - new setpoint calibration: 30.0 | external_temp: 22.1, target_temp: 30.0, trv_temp: 22.9
2024-11-07 18:25:39.113 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: TO TRV set_hvac_mode: climate.thermostat_office from: heat_cool to: heat
2024-11-07 18:25:39.113 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat None: set_hvac_mode heat
2024-11-07 18:25:39.114 WARNING (MainThread) [homeassistant.components.climate] tuya::TuyaClimateEntity sets the hvac_mode heat which is not valid for this entity with modes: off, heat_cool, heat_cool. This will stop working in 2025.4 and raise an error instead. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+tuya%22
2024-11-07 18:25:39.182 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
File "/config/custom_components/better_thermostat/climate.py", line 858, in startup
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 772, in async_handle_set_hvac_mode_service
await self.async_set_hvac_mode(hvac_mode)
File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 780, 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/entity.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

As far as I understood, the problem is caused by setting hvac_mode to 'heat' which is not supported by my thermostat.

2024-11-07 18:25:39.113 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat None: set_hvac_mode heat
2024-11-07 18:25:39.114 WARNING (MainThread) [homeassistant.components.climate] tuya::TuyaClimateEntity sets the hvac_mode heat which is not valid for this entity with modes: off, heat_cool, heat_cool. This will stop working in 2025.4 and raise an error instead. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+tuya%22

Any hints on how to fix the issue?

Note: some times the entity gets available after trying to reconfigure lots of time (more than 5 times). After restarting HA the entity becomes unavailable.