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
717 stars 124 forks source link

Shelly with BT, doesn't change on the TRV #472

Closed DariBer closed 1 year ago

DariBer commented 1 year ago

TRV: Shelly TRV (wifi) BT version: Beta22 HA Version: 2022.9.6

When I change the temperatur on the Better Thermostat, it doesn't change the temp on the TRV

I have attached a screenshot. The TRV has been awake, so it's not in sleep mode

Screenshot 2022-09-24 at 10 24 59

Diagnostic file from BT device config_entry-better_thermostat-368126748d73f23f8fccc475323bc5ce.json.txt

Diagnostic file from Shelly TRV device config_entry-shelly-f188869c104c96d4b790db62c5f7a96a.json.txt

DariBer commented 1 year ago

When I removed and added them again, it started to work.

DariBer commented 1 year ago

after a while same problem happened, so remove and add new BT seems to work for a while, and then same problem

DariBer commented 1 year ago

not sure how to reopen a closed bug. or do I need to open an new case edit: found this "you cannot re-open your own issues if a repo collaborator closed them"

DariBer commented 1 year ago

a reboot made BT start working again, will see for how long.

DariBer commented 1 year ago

could the problem be somehow when the wifi termostat goes into some kind of sleep mode?

KartoffelToby commented 1 year ago

Its possible, does it work if you Change the temp with the ha org. Climate entity?

DariBer commented 1 year ago

That’s the thing that confuse me. When I change the temp on the Shelley’s thermostat entity in HA works all the time.

RubenKelevra commented 1 year ago

That’s the thing that confuse me. When I change the temp on the Shelley’s thermostat entity in HA works all the time.

Technically BT does exactly the same, just automatically.

So it's probably not a sleep functionality :)

KartoffelToby commented 1 year ago

@DariBer try out beta 23, i seperate the temp and hvac mode sending

DariBer commented 1 year ago

Will try it when I get Home after the weekend.

DariBer commented 1 year ago

I found some time to test before the weekend. The problem is still there. It works fine, but suddenly it stopps to work. The "real" thermostat entity in HA for the TRV (Shelly TRV Kök 1 & Shelly TRV Kök 2) works fine all the time. Same for the Zigbee thermostat I have in my bathroom for the electric floor heating. I have connection with TRV, so it's not that they are in sleep mode.

I recorded a screen capture for you to see.

BT Kök 1 is a Better Thermostat entity for Shelly TRV Kök 1 (wifi TRV from Shelly) BT Kök 2 is Better Thermostat entity for Shelly TRV Kök 2 (wifi TRV from Shelly) BT Badrum is Better Thermostat entity for Termostat-Badrum (Zitbeen Thermostat from Namron)

https://user-images.githubusercontent.com/26138185/192970044-1c0f9b19-99b6-4f8f-8714-be30cd13f6e7.mov

KartoffelToby commented 1 year ago

Thats strage, and you on Beta 23/24?

Can you pls try to run a normal service call to the real TRV, and check if the target temp changes?

service: climate.set_temperature
data:
  temperature: 25
target:
  entity_id: climate.heizung_bad_real
DariBer commented 1 year ago

I installed beta 24 now, but same problem

I tried to set the temp to 25 from the BT, didn't work, but I was able to change with call service, see bellow what worked

Screenshot 2022-09-29 at 21 54 48
DariBer commented 1 year ago

One thing that I noticed now was,From BT, I was able to lower the temp to 17 and than change back to 21, but I was not able to go to 25 from BT, but works with call service

DariBer commented 1 year ago

weird thing is that it can work fine, suddenly it stops to work to change to any temp... or it works to lower but not higher, and so on

KartoffelToby commented 1 year ago

Pls test Beta 25 it should work every time

DariBer commented 1 year ago

Looks like it's working now. Will try it some days.

One thing I noticed was it takes little bit longer for BT to change the temp on the TRV, not a problem, just a notice :-)

DariBer commented 1 year ago

Some update, works for a while and then some BT entities stoped to work, random which one stops to work.

Will try to see if I can find any logic in why.

KartoffelToby commented 1 year ago

Can you Share the logs, i added more debug logs in Beta 25

DariBer commented 1 year ago

What logs do you want? Where do I find them?

DariBer commented 1 year ago

One thing I can see in the log is this (se below)

Termostat-Badrum is my only Zigbee thermostat, it's to my floor heating in my bathroom. And that's the only BT Thermostat that works fine.

But I haven't configured any window sensor for that BT. So not sure why it complains for the window sensor.

Logger: homeassistant.components.mqtt.number Source: components/mqtt/number.py:215 Integration: MQTT (documentation, issues) First occurred: 10:42:02 PM (2 occurrences) Last logged: 10:42:02 PM

Invalid value for number.termostat_badrum_window_open_check: 0 (range 1.5 - 4.0)

KartoffelToby commented 1 year ago

This is a mqtt error, not from BT.

You need to enable the debug Modus for BT.

DariBer commented 1 year ago

Ok, I'm not sure how to do that, guide me please

bsafh commented 1 year ago

in /config/configuration.yaml

logger:
  # The next line sets the default logging level, for all python modules.
  # It seems "recommended" to set it to avoid too much logging.
  default: warning
  logs:
    custom_components.better_thermostat: debug
DariBer commented 1 year ago

My TRV is not Zigbee, they are Shelly wifi. Should I still use the custom_components.zha_toolkit?

bsafh commented 1 year ago

of course not, that was just an example for any other component. I've changed the comment to avoid further confusion

DariBer commented 1 year ago

are the log entries written in the home-assistant.log file?

DariBer commented 1 year ago

I found the log,

Not sure if this could cause the error

2022-10-02 09:07:40.001 INFO (MainThread) [custom_components.better_thermostat.controlling] better_thermostat BT Kök 2: received a new setpoint from HA: 25.0 2022-10-02 09:07:40.001 DEBUG (MainThread) [custom_components.better_thermostat.climate] better_thermostat BT Kök 2: HA asked for our HVAC action, we will respond with: heating 2022-10-02 09:07:40.002 DEBUG (MainThread) [custom_components.better_thermostat.climate] better_thermostat BT Kök 2: HA asked for our HVAC action, we will respond with: heating 2022-10-02 09:07:40.561 DEBUG (MainThread) [custom_components.better_thermostat.controlling] better_thermostat BT Kök 2: processing controls 2022-10-02 09:07:40.561 DEBUG (MainThread) [custom_components.better_thermostat.weather] better_thermostat BT Kök 2: checking ambient air sensor data... 2022-10-02 09:07:40.561 DEBUG (MainThread) [custom_components.better_thermostat.controlling] better_thermostat BT Kök 2: control_trv: own mode is on, call for heat decision is true, setting TRV mode to on 2022-10-02 09:07:41.392 INFO (MainThread) [custom_components.better_thermostat.controlling] better_thermostat BT Kök 2: send new temperature to TRV, value: '24.0' 2022-10-02 09:07:41.684 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat BT Kök 2: skipping trigger_trv_change because ignore_states is true 2022-10-02 09:07:42.670 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat BT Kök 2: skipping trigger_trv_change because ignore_states is true 2022-10-02 09:07:46.679 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat BT Kök 2: TRV's decoded TRV mode is not valid, skipping 2022-10-02 09:07:46.687 DEBUG (MainThread) [custom_components.better_thermostat.climate] better_thermostat BT Kök 2: HA asked for our HVAC action, we will respond with: heating 2022-10-02 09:07:46.690 DEBUG (MainThread) [custom_components.better_thermostat.controlling] better_thermostat BT Kök 2: processing controls 2022-10-02 09:07:46.690 DEBUG (MainThread) [custom_components.better_thermostat.weather] better_thermostat BT Kök 2: checking ambient air sensor data... 2022-10-02 09:07:46.690 DEBUG (MainThread) [custom_components.better_thermostat.controlling] better_thermostat BT Kök 2: control_trv: own mode is on, call for heat decision is true, setting TRV mode to on 2022-10-02 09:07:46.695 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/better_thermostat/controlling.py", line 37, in control_queue await control_trv(controls_to_process) File "/config/custom_components/better_thermostat/controlling.py", line 123, in control_trv await set_trv_values( File "/config/custom_components/better_thermostat/controlling.py", line 251, in set_trv_values await self.hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 588, in async_service_temperature_set await entity.async_set_temperature(**kwargs) File "/usr/src/homeassistant/homeassistant/components/shelly/climate.py", line 262, in async_set_temperature await self.set_state_full_path(target_t_enabled=1, target_t=f"{current_temp}") File "/usr/src/homeassistant/homeassistant/components/shelly/climate.py", line 245, in set_state_full_path return await self.wrapper.device.http_request( File "/usr/local/lib/python3.10/site-packages/aioshelly/block_device.py", line 222, in http_request if self.options.auth is None and self.requires_auth: File "/usr/local/lib/python3.10/site-packages/aioshelly/block_device.py", line 280, in requires_auth assert self.shelly AssertionError 2022-10-02 09:07:48.396 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat BT Kök 2: skipping trigger_trv_change because ignore_states is true

DariBer commented 1 year ago

Later today I will do a Screen recording with logs and when I change in BT and when I do from call service.

KartoffelToby commented 1 year ago

Looks like a Special Shelly Thing,

What happend if your call the normal climate.set Temperatur Service to the Shelly TRV? Does it response?

DariBer commented 1 year ago

Please see the video (was too big to post here, so had to put it on YouTube) Works fine when I change when I use call service, but unfortunately not with the BT

https://youtu.be/f30w79KKZj8

DariBer commented 1 year ago

I can see in the logfile that the BT received the change but it doesn't change the temp on the TRV.

When I go to call service and try there to change temp on the TRV, it works fine, without any problem.

DariBer commented 1 year ago

I testet again with beta 26. I can change the temp back and forth, suddenly I see this logg and it stop to work. I don't understand the log. Not sure why it happens, but everything works fine until I logs this, and after this log, it doesn't change the temp on the TRV. But I can change the temp if I manually go and use the call service command.

22-10-08 00:34:09.473 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat BT Kök 1: processing controls 2022-10-08 00:34:09.473 DEBUG (MainThread) [custom_components.better_thermostat.utils.weather] better_thermostat BT Kök 1: checking ambient air sensor data... 2022-10-08 00:34:09.473 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat BT Kök 1: control_trv: own mode is on, call for heat decision is true, setting TRV mode to on 2022-10-08 00:34:09.473 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat BT Kök 1: heat_auto_swapped True 2022-10-08 00:34:09.473 INFO (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat BT Kök 1: TO TRV set_temperature: 19.0 2022-10-08 00:34:10.262 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat BT Kök 1: control_trv: current TRV mode: heat new TRV mode: auto 2022-10-08 00:34:10.262 INFO (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat BT Kök 1: TO TRV set_hvac_mode: auto 2022-10-08 00:34:16.417 INFO (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat BT Sovrum: received a new setpoint from HA: 25.0 2022-10-08 00:34:18.545 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat BT Kök 1: heat_auto_swapped False 2022-10-08 00:34:18.546 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat BT Kök 1: skipping trigger_trv_change because ignore_states is true 2022-10-08 00:34:18.546 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat BT Kök 1: heat_auto_swapped True 2022-10-08 00:34:18.546 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat BT Kök 1: TRV's decoded TRV mode is not valid, skipping 2022-10-08 00:34:18.552 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat BT Kök 1: heat_auto_swapped False 2022-10-08 00:34:18.552 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat BT Kök 1: skipping trigger_trv_change because ignore_states is true 2022-10-08 00:34:18.552 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat BT Kök 1: heat_auto_swapped True 2022-10-08 00:34:18.552 INFO (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat BT Kök 1: TRV update received 2022-10-08 00:34:18.553 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat BT Kök 1: processing controls 2022-10-08 00:34:18.554 DEBUG (MainThread) [custom_components.better_thermostat.utils.weather] better_thermostat BT Kök 1: checking ambient air sensor data... 2022-10-08 00:34:18.554 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat BT Kök 1: control_trv: own mode is on, call for heat decision is true, setting TRV mode to on 2022-10-08 00:34:18.554 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat BT Kök 1: heat_auto_swapped True 2022-10-08 00:34:18.554 INFO (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat BT Kök 1: TO TRV set_temperature: 19.0 2022-10-08 00:34:18.555 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/better_thermostat/utils/controlling.py", line 40, in control_queue await control_trv(controls_to_process) File "/config/custom_components/better_thermostat/utils/controlling.py", line 109, in control_trv await set_trv_values( File "/config/custom_components/better_thermostat/utils/controlling.py", line 221, in set_trv_values await set_temperature(self, value) File "/config/custom_components/better_thermostat/utils/bridge.py", line 41, in set_temperature return await self.adapter.set_temperature(self, temperature) File "/config/custom_components/better_thermostat/adapters/generic.py", line 22, in set_temperature await self.hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 207, in handle_service await service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 613, in async_service_temperature_set await entity.async_set_temperature(**kwargs) File "/usr/src/homeassistant/homeassistant/components/shelly/climate.py", line 264, in async_set_temperature await self.set_state_full_path(target_t_enabled=1, target_t=f"{current_temp}") File "/usr/src/homeassistant/homeassistant/components/shelly/climate.py", line 247, in set_state_full_path return await self.wrapper.device.http_request( File "/usr/local/lib/python3.10/site-packages/aioshelly/block_device.py", line 226, in http_request if self.options.auth is None and self.requires_auth: File "/usr/local/lib/python3.10/site-packages/aioshelly/block_device.py", line 284, in requires_auth assert self.shelly AssertionError

DariBer commented 1 year ago

I also see this in Home Assistent when I try to change the temp on the BT, never seen that error message before. "Failed to call service climate/set_temperature. task_done() called too many times"

2022-10-08 00:50:20.619 INFO (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat BT Kök 1: received a new setpoint from HA: 25.0 2022-10-08 00:50:20.622 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140282193652816] task_done() called too many times Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 202, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 207, in handle_service await service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 613, in async_service_temperature_set await entity.async_set_temperature(kwargs) File "/config/custom_components/better_thermostat/climate.py", line 743, in async_set_temperature await set_target_temperature(self, kwargs) File "/config/custom_components/better_thermostat/utils/controlling.py", line 162, in set_target_temperature self.control_queue_task.task_done() File "/usr/local/lib/python3.10/asyncio/queues.py", line 202, in task_done raise ValueError('task_done() called too many times') ValueError: task_done() called too many times Connected

KartoffelToby commented 1 year ago

Totaly Strange, is it the Shelly WiFi Thermostat? Have you other TRVs?

DariBer commented 1 year ago

I have one Zigbee electric floor heating thermostat in Zigbee2MQTT, that one works fine. Yes, the Shelly TRVs is WiFi based

DariBer commented 1 year ago

Seems the problem is when it use "target temperature". Cause my Zigbee thermostat works when using "local calibration" but has problem when I change to "target".

KartoffelToby commented 1 year ago

This would be strage because target temp just send Normal target temp set Point to the TRV.

Arquiteto commented 1 year ago

Why don't you just use Shelly TRV capability of beeing fed with external temperature sensor?