swingerman / ha-dual-smart-thermostat

The `dual_smart_thermostat` is an enhaced verion of generic thermostat implemented in Home Assistant. It uses several sensors and dedicated switches connected to a heater and air conditioning under the hood.
https://github.com/swingerman/ha-dual-thermostat
Apache License 2.0
121 stars 20 forks source link

[bug] - error adding entity climate #239

Closed serlinGi closed 1 month ago

serlinGi commented 2 months ago

Hi, for quickness I modified my thermostats to work in cold only mode.

I just have one problem I noticed that with preset_mode set, if I manually change the temperature value and then restart the integration (or restart HA), it gives me an error and I find the thermostat turned off and blocked. I have to act manually to turn on and recall one of the preset modes.

this is the error message in log:

Logger: homeassistant.components.climate
Source: helpers/[entity_platform.py:598](http://entity_platform.py:598/)
integration: Climate (documentation, issues)
First occurred: 00:29:11 (5 occurrences)
Last logged: 00:29:11

Error adding entity climate.climatizzatore_sala for domain climate with platform dual_smart_thermostat
Error adding entity......with platform dual_smart_thermostat
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/[entity_platform.py](http://entity_platform.py/)", line 598, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/[entity_platform.py](http://entity_platform.py/)", line 912, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/[entity.py](http://entity.py/)", line 1361, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/dual_smart_thermostat/[climate.py](http://climate.py/)", line 542, in async_added_to_hass
    self.environment.apply_old_state(old_state)
  File "/config/custom_components/dual_smart_thermostat/managers/[environment_manager.py](http://environment_manager.py/)", line 574, in apply_old_state
    self._target_temp = float(old_target)
                        ^^^^^^^^^^^^^^^^^
TypeError: float() argument must be a string or a real number, not 'dict'

and this my conf

  - platform: dual_smart_thermostat
    name: "climatizzatore sala"
    unique_id: climate.climatizzatore_sala
    heater: fan.clima_sala
    target_sensor: sensor.aqara_sala_temperature
    openings:
      - entity_id: binary_sensor.balcone_sala_contact
        timeout: 00:02:30
    heat_cool_mode: false #true # <-important
    keep_alive: #lo attivo e commento initial_hvac_mode per verificare se mantiene lo stato al riavvio
      minutes: 2
    ac_mode: true
    min_temp: 16
    max_temp: 32
    cold_tolerance: 0.4
    hot_tolerance: 0.1
    target_temp_step: 0.1
    min_cycle_duration:
      minutes: 1
    away:
      temperature: 28.0
      target_temp_low: 27
      target_temp_high: 29.5
    home:
      temperature: 23.0
      target_temp_low: 22.5
      target_temp_high: 23.5
    comfort:
      temperature: 25.0
      target_temp_low: 24
      target_temp_high: 25.5
    sleep:
      temperature: 27.5
      target_temp_low: 26.5
      target_temp_high: 28.0

HA.OS: Core 2024.7.2 Supervisor 2024.06.2 Operating System 12.4 Frontend 20240710.0 dual_smart_thermostat: v0.9.7.beta-4

any suggestions? thx

swingerman commented 2 months ago

I will look into this. Stay tuned.

swingerman commented 2 months ago

Please check v0.9.7.beta-5

serlinGi commented 2 months ago

I think he's not behaving properly at all. but the problem that caused the error and blocking seems to have been solved.

I'll give you the 2 screenshots: before restarting the integration with the values I had set and after the restart

Screenshot_2024-07-22-13-25-37-52_c3a231c25ed346e59462e84656a70e50

Screenshot_2024-07-22-13-27-20-41_c3a231c25ed346e59462e84656a70e50

swingerman commented 1 month ago

I see. There are a lot of interesting things going on. Let's focus on "Sala" first. It seems it picks 28 as a target from the sleep preset while it's set to comfort. So we expect to pick the temp from the comfort preset: 25.5, or do we want to take the last set target: 26.4? As far as I remember, after restarting, we should apply the preset, so it should be 25.5

serlinGi commented 1 month ago

I don't understand: You want me to try rebooting now?

swingerman commented 1 month ago

No. Just trying to confirm the expected logic.

serlinGi commented 1 month ago

I think there are too many variables then; it would be enough if it restarted at least on the preset temperature for that preset_mode with which it turns off; πŸ‘ but if I wanted to refine a lot, the last temperature used would be perfect. πŸ” Instead, for me, it stays on "comfort" but with the temperature expected for "away"πŸ˜“

swingerman commented 1 month ago

Yeah. I found the problem already. Working on a permanent fix...

swingerman commented 1 month ago

It was tough. A lot of mess, but I cleaned it up. A new beta will be available tomorrow.

swingerman commented 1 month ago

Please check v0.9.8.beta-5

serlinGi commented 1 month ago

OKk, it seems that it maintains the state and temperature; but now I think there are problems in changing the preset_mode states for the machines that are on at reboot: the temperatures don't correspond to those set in the conf file. I've also a warning in the logs: "No case matched when off"

I'm at work and I can't go into more detail. I'll do some tests in the afternoon (IT time) πŸ‘‹

serlinGi commented 1 month ago

https://github.com/user-attachments/assets/20535560-aac8-4b93-808b-7d87285bf7a9

Screenshot_2024-08-13-11-44-14-07_c3a231c25ed346e59462e84656a70e50

OKk, it seems that it maintains the state and temperature; but now I think there are problems in changing the preset_mode states for the machines that are on at reboot: the temperatures don't correspond to those set in the conf file. I've also a warning in the logs: "No case matched when off"

I'm at work and I can't go into more detail. I'll do some tests in the afternoon (IT time) πŸ‘‹

It seems to me that, when ON, it points to the value set as target_temp_high

swingerman commented 1 month ago

I needed to rework the preset settings completely, and I think it's fixed now. Please check v0.9.8.beta-6