jmcollin78 / versatile_thermostat

A full featured Thermostat for Home Assistant: presets, window, motion, presence and overpowering management
MIT License
327 stars 34 forks source link

Google Nest issues after upgrade -> 6.3.0 #518

Closed sapphonie closed 3 weeks ago

sapphonie commented 1 month ago

Version of the custom_component

6.3.0

Configuration

hvac_modes: heat, cool, heat_cool, off
min_temp: 60
max_temp: 85
target_temp_step: 1
current_temperature: 79
temperature: 70
is_on: true
hvac_action: idle
hvac_mode: cool
preset_mode: none
type: null
is_controlled_by_central_mode: false
last_central_mode: null
frost_temp: 85
eco_temp: 68
boost_temp: 85
comfort_temp: 73
frost_away_temp: 70
eco_away_temp: 70
boost_away_temp: 70
comfort_away_temp: 70
power_temp: null
target_temperature_step: 1
ext_current_temperature: 59
ac_mode: true
current_power: null
current_power_max: null
saved_preset_mode: none
saved_target_temp: 80
saved_hvac_mode: null
motion_sensor_entity_id: null
motion_state: null
power_sensor_entity_id: null
max_power_sensor_entity_id: null
overpowering_state: null
presence_sensor_entity_id: binary_sensor.ishome
presence_state: on
window_state: off
window_auto_state: off
window_bypass_state: false
window_sensor_entity_id: null
window_delay_sec: 30
window_auto_enabled: false
window_auto_open_threshold: null
window_auto_close_threshold: null
window_auto_max_duration: null
window_action: window_turn_off
security_delay_min: 60
security_min_on_percent: 0.5
security_default_on_percent: 0.1
last_temperature_datetime: 2024-10-01T23:49:49.780180-04:00
last_ext_temperature_datetime: 2024-10-01T23:49:49.632466-04:00
security_state: false
minimal_activation_delay_sec: 10
device_power: 1
mean_cycle_power: null
total_energy: 140.27
last_update_datetime: 2024-10-01T23:52:10.124083-04:00
timezone: America/New_York
temperature_unit: °F
is_device_active: false
ema_temp: 80.2
is_used_by_central_boiler: false
is_over_climate: true
start_hvac_action_date: null
underlying_climate_0: climate.den_thermostat <-- this is a Google Nest integrated into my HA
underlying_climate_1: null
underlying_climate_2: null
underlying_climate_3: null
is_regulated: true
regulated_target_temperature: 68.4
auto_regulation_mode: auto_regulation_medium
regulation_accumulated_error: -20
auto_fan_mode: auto_fan_high
current_auto_fan_mode: auto_fan_high
auto_activated_fan_mode: null
auto_deactivated_fan_mode: null
auto_regulation_use_device_temp: false
friendly_name: Den Thermo
supported_features: 411
fan_modes: on, off
preset_modes: none, eco, comfort, boost
target_temp_high: null
target_temp_low: null
fan_mode: on

If it is releveant to regulation performance or optimisation some curves are needed

N/A

Describe the bug

I'm trying to:

And I expect:

But I observe this ....

✔️ I read the documentation on the README.md file and I don't find any relevant information about this issue.

Logs

Upon trying to change temperature:

Logger: homeassistant
Source: components/climate/__init__.py:323
First occurred: 11:49:59 PM (1 occurrences)
Last logged: 11:49:59 PM
Error doing job: Task exception was never retrieved (None)

Traceback (most recent call last):
  File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 1857, in _async_presence_changed
    await self.async_control_heating(force=True)
  File "/config/custom_components/versatile_thermostat/thermostat_climate.py", line 807, in async_control_heating
    ret = await super().async_control_heating(force, _)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 2514, in async_control_heating
    self.update_custom_attributes()
  File "/config/custom_components/versatile_thermostat/thermostat_climate.py", line 544, in update_custom_attributes
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1063, in __async_calculate_state
    capability_attr = self.capability_attributes
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 323, in __getattribute__
    return super().__getattribute__(__name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 510, in capability_attributes
    data[ATTR_PRESET_MODES] = self.preset_modes
                              ^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 323, in __getattribute__
    return super().__getattribute__(__name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 1143, in preset_modes
    return self._attr_preset_modes
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 323, in __getattribute__
    return super().__getattribute__(__name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 323, in __getattribute__
    return super().__getattribute__(__name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ThermostatOverClimate' object has no attribute '__attr_preset_modes'. Did you mean: '__attr_preset_mode'?

Switching to Heat/Cool instead of Cool initiates cooling, but then I see


Logger: homeassistant
Source: util/unit_conversion.py:532
First occurred: 11:55:39 PM (2 occurrences)
Last logged: 11:55:39 PM
Error doing job: Task exception was never retrieved (None)

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/report_state.py", line 123, in _async_entity_state_listener
    entity_data = entity.query_serialize()
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/helpers.py", line 702, in query_serialize
    deep_update(attrs, trt.query_attributes())
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 1251, in query_attributes
    TemperatureConverter.convert(
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 78, in convert
    return cls.converter_factory(from_unit, to_unit)(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 532, in _fahrenheit_to_celsius
    return (fahrenheit - 32.0) / 1.8
            ~~~~~~~~~~~^~~~~~
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

in logs.

Reverting to 6.2.9 fixes the issue for me.

It also looks like Thermo target temp low / high are getting set in C rather than in F - image

Please let me know if you need anything else from me. Thanks!

jmcollin78 commented 1 month ago

Hello @sapphonie,

Thank you for your report, this really thing to be a bug introduce with 6.3.0 and Google Nest thermostat and Farenheit conversion. I have to find out what happens (thanks for the logs). Please stay in 6.2.9, but because I'm not in Fahrenheit it is complex to reproduce.

I have many problems in the past with F° (see: old issue https://github.com/jmcollin78/versatile_thermostat/issues/240, https://github.com/jmcollin78/versatile_thermostat/issues/38). @mag2352 solves the issue for me. Maybe he can have a look is something is broken with 6.3.0.

Are you on HA 2024.10 ? I don't have tried with this release and I see some change on Thermostat with this release

mag2352 commented 1 month ago

I haven't updated to 6.3.0, so I haven't observed this issue. I will look into it soon. Does the change in code for issue #508 between 6.2.9 and 6.3.0 cause the issue? I am also on 2024.9.3. Hopefully I can get back to you in a couple of days.

Edit: That unit conversion is failing from the Google Assistant integration... that's interesting. I hope this isn't a google specific issue, since I don't have a nest.

jmcollin78 commented 1 month ago

Thank you @mag2352 . I guess this is the #508 change which introduce this. When reverting back to 6.2.9 @sapphonie says that is issue is not preset.

I don't have change so many things in this release.

mag2352 commented 1 month ago

Thank you @mag2352 . I guess this is the #508 change which introduce this. When reverting back to 6.2.9 @sapphonie says that is issue is not preset.

I don't have change so many things in this release.

I also tried updating to HA 2024.10, and 6.3.0 is necessary on my system due to the issues in #508. So I'm not sure if this is a Google Nest specific problem, since I think 6.3.0 is a necessary update for 2024.10. Does anyone else have the issue described in this post?

jmcollin78 commented 1 month ago

since I think 6.3.0 is a necessary update for 2024.10

Yes ! It have been done for that.

mag2352 commented 1 month ago

Also @sapphonie, why is it in the second set of logs you posted that HA is trying to convert from Fahrenheit to Celsius? Is your system using Celsius as the default unit? It seems you are expecting to see Fahrenheit, yet HA is trying to convert Fahrenheit back to Celsius.

Edit: Considering the America/New_York time zone (and the VT temperature unit of F), I'm going to assume you are using Fahrenheit. Are you able to try another temperature sensor and confirm if the issue still exists there? Can you also confirm if you use the TPI algorithm or Central Config in VT's settings (just confirming that the changes to those 2 features between 6.2.9 -> 6.3.0 are not the issue here)?

jmcollin78 commented 1 month ago

Try this fix release please: https://github.com/jmcollin78/versatile_thermostat/releases/tag/6.3.1

This fix the error message I saw in your log: "ThermostatOverClimate object has no attribute __attr_preset_modes"

sapphonie commented 1 month ago

Also @sapphonie, why is it in the second set of logs you posted that HA is trying to convert from Fahrenheit to Celsius? Is your system using Celsius as the default unit? It seems you are expecting to see Fahrenheit, yet HA is trying to convert Fahrenheit back to Celsius.

Edit: Considering the America/New_York time zone (and the VT temperature unit of F), I'm going to assume you are using Fahrenheit. Are you able to try another temperature sensor and confirm if the issue still exists there? Can you also confirm if you use the TPI algorithm or Central Config in VT's settings (just confirming that the changes to those 2 features between 6.2.9 -> 6.3.0 are not the issue here)?

Yes, I use F, I already tried another temp sensor, and tried with/without a central cfg setup. Going to update to 6.3.1 and see if it's resolved.

sapphonie commented 1 month ago

Can still repro, no log error spew, but cool does not kick on - this is debug logs after i turn the temp from 68 to 67 while the temp sensor i have set up is showing 75:

2024-10-06 18:11:55.004 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Den Thermo - Set target temp: 67.0
2024-10-06 18:11:55.004 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - Calling ThermostatClimate._send_regulated_temperature force=True
2024-10-06 18:11:55.004 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - regulation calculation will be done
2024-10-06 18:11:55.004 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - usage of regulation_step: 0.20
2024-10-06 18:11:55.004 DEBUG (MainThread) [custom_components.versatile_thermostat.pi_algorithm] PITemperatureRegulator - Error: -8.40 accumulated_error: -50.00 offset: -7.36 offset_ext: -0.00 target_tem: 67.0 regulatedTemp: 62.0
2024-10-06 18:11:55.004 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - Regulated temp have changed to 62.0. Resend it to underlyings
2024-10-06 18:11:55.004 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - The device offset temp for regulation is 0.00 - internal temp is 0.00. New target is 62.00
2024-10-06 18:11:55.004 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - recalculate all
2024-10-06 18:11:55.005 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - Calling update_custom_attributes: {'is_on': True, 'hvac_action': <HVACAction.IDLE: 'idle'>, 'hvac_mode': <HVACMode.COOL: 'cool'>, 'preset_mode': 'none', 'type': None, 'is_controlled_by_central_mode': False, 'last_central_mode': None, 'frost_temp': 85.0, 'eco_temp': 68.0, 'boost_temp': 85.0, 'comfort_temp': 73.0, 'frost_away_temp': 70.0, 'eco_away_temp': 70.0, 'boost_away_temp': 70.0, 'comfort_away_temp': 70.0, 'power_temp': None, 'target_temperature_step': 1.0, 'ext_current_temperature': 82.0, 'ac_mode': True, 'current_power': None, 'current_power_max': None, 'saved_preset_mode': 'none', 'saved_target_temp': 69.0, 'saved_hvac_mode': None, 'motion_sensor_entity_id': None, 'motion_state': None, 'power_sensor_entity_id': None, 'max_power_sensor_entity_id': None, 'overpowering_state': None, 'presence_sensor_entity_id': 'binary_sensor.ishome', 'presence_state': 'on', 'window_state': 'off', 'window_auto_state': 'off', 'window_bypass_state': False, 'window_sensor_entity_id': None, 'window_delay_sec': 30, 'window_auto_enabled': False, 'window_auto_open_threshold': None, 'window_auto_close_threshold': None, 'window_auto_max_duration': None, 'window_action': 'window_turn_off', 'security_delay_min': 60, 'security_min_on_percent': 0.5, 'security_default_on_percent': 0.1, 'last_temperature_datetime': '2024-10-06T18:09:39.407872-04:00', 'last_ext_temperature_datetime': '2024-10-06T18:09:35.495957-04:00', 'security_state': False, 'minimal_activation_delay_sec': 10, 'device_power': 1.0, 'mean_cycle_power': None, 'total_energy': 0.03, 'last_update_datetime': '2024-10-06T18:11:55.004699-04:00', 'timezone': 'America/New_York', 'temperature_unit': <UnitOfTemperature.FAHRENHEIT: '°F'>, 'is_device_active': False, 'ema_temp': 73.85, 'is_used_by_central_boiler': False, 'is_over_climate': True, 'start_hvac_action_date': None, 'underlying_climate_0': 'climate.den_thermostat', 'underlying_climate_1': None, 'underlying_climate_2': None, 'underlying_climate_3': None, 'is_regulated': True, 'regulated_target_temperature': 62.0, 'auto_regulation_mode': 'auto_regulation_strong', 'regulation_accumulated_error': -50, 'auto_fan_mode': 'auto_fan_high', 'current_auto_fan_mode': 'auto_fan_high', 'auto_activated_fan_mode': None, 'auto_deactivated_fan_mode': None, 'auto_regulation_use_device_temp': False}
2024-10-06 18:11:55.005 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Den Thermo - last_change_time is now 2024-10-06 18:11:55.005534-04:00
2024-10-06 18:11:55.005 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Den Thermo - Checking new cycle. hvac_mode=cool, security_state=False, preset_mode=none
2024-10-06 18:11:55.005 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Den Thermo - Window auto is on, check the alert. last slope is 7.430
2024-10-06 18:11:55.005 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Den Thermo - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-10-06 18:11:55.005 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Den Thermo - power not configured. check_overpowering not available
2024-10-06 18:11:55.005 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Den Thermo - checking security delta_temp=2.3 delta_ext_temp=2.3 mod_cond=True temp_cond=False climate_cond=False switch_cond=False
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - Calling update_custom_attributes: {'is_on': True, 'hvac_action': <HVACAction.IDLE: 'idle'>, 'hvac_mode': <HVACMode.COOL: 'cool'>, 'preset_mode': 'none', 'type': None, 'is_controlled_by_central_mode': False, 'last_central_mode': None, 'frost_temp': 85.0, 'eco_temp': 68.0, 'boost_temp': 85.0, 'comfort_temp': 73.0, 'frost_away_temp': 70.0, 'eco_away_temp': 70.0, 'boost_away_temp': 70.0, 'comfort_away_temp': 70.0, 'power_temp': None, 'target_temperature_step': 1.0, 'ext_current_temperature': 82.0, 'ac_mode': True, 'current_power': None, 'current_power_max': None, 'saved_preset_mode': 'none', 'saved_target_temp': 69.0, 'saved_hvac_mode': None, 'motion_sensor_entity_id': None, 'motion_state': None, 'power_sensor_entity_id': None, 'max_power_sensor_entity_id': None, 'overpowering_state': None, 'presence_sensor_entity_id': 'binary_sensor.ishome', 'presence_state': 'on', 'window_state': 'off', 'window_auto_state': 'off', 'window_bypass_state': False, 'window_sensor_entity_id': None, 'window_delay_sec': 30, 'window_auto_enabled': False, 'window_auto_open_threshold': None, 'window_auto_close_threshold': None, 'window_auto_max_duration': None, 'window_action': 'window_turn_off', 'security_delay_min': 60, 'security_min_on_percent': 0.5, 'security_default_on_percent': 0.1, 'last_temperature_datetime': '2024-10-06T18:09:39.407872-04:00', 'last_ext_temperature_datetime': '2024-10-06T18:09:35.495957-04:00', 'security_state': False, 'minimal_activation_delay_sec': 10, 'device_power': 1.0, 'mean_cycle_power': None, 'total_energy': 0.03, 'last_update_datetime': '2024-10-06T18:11:55.005886-04:00', 'timezone': 'America/New_York', 'temperature_unit': <UnitOfTemperature.FAHRENHEIT: '°F'>, 'is_device_active': False, 'ema_temp': 73.85, 'is_used_by_central_boiler': False, 'is_over_climate': True, 'start_hvac_action_date': None, 'underlying_climate_0': 'climate.den_thermostat', 'underlying_climate_1': None, 'underlying_climate_2': None, 'underlying_climate_3': None, 'is_regulated': True, 'regulated_target_temperature': 62.0, 'auto_regulation_mode': 'auto_regulation_strong', 'regulation_accumulated_error': -50, 'auto_fan_mode': 'auto_fan_high', 'current_auto_fan_mode': 'auto_fan_high', 'auto_activated_fan_mode': None, 'auto_deactivated_fan_mode': None, 'auto_regulation_use_device_temp': False}
2024-10-06 18:11:55.006 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - Calling ThermostatClimate._send_regulated_temperature force=False
2024-10-06 18:11:55.006 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - period (0.0) min is < 1 min -> forget the regulation send
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_last_temp_datetime - climate state change
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_last_ext_temp_datetime - climate state change
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_temperature_slope - climate state change
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_ema_temperature - climate state change
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_energy - climate state change
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_regulated_temperature - climate state change
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Den Thermo_security_state - climate state change
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Den Thermo_window_bypass_state - climate state change
2024-10-06 18:11:55.006 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Den Thermo_presence_state - climate state change
2024-10-06 18:11:55.007 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_last_temp_datetime - climate state change
2024-10-06 18:11:55.007 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_last_ext_temp_datetime - climate state change
2024-10-06 18:11:55.007 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_temperature_slope - climate state change
2024-10-06 18:11:55.007 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_ema_temperature - climate state change
2024-10-06 18:11:55.007 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_energy - climate state change
2024-10-06 18:11:55.007 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Den Thermo_regulated_temperature - climate state change
2024-10-06 18:11:55.007 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Den Thermo_security_state - climate state change
2024-10-06 18:11:55.007 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Den Thermo_window_bypass_state - climate state change
2024-10-06 18:11:55.007 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Den Thermo_presence_state - climate state change

I also see

Logger: custom_components.versatile_thermostat.thermostat_climate
Source: custom_components/versatile_thermostat/thermostat_climate.py:149
integration: Versatile Thermostat configuration ([documentation](https://github.com/jmcollin78/versatile_thermostat), [issues](https://github.com/jmcollin78/versatile_thermostat/issues))
First occurred: 6:14:59 PM (2 occurrences)
Last logged: 6:14:59 PM
%s - don't send regulated temperature cause VTherm current_temp (%s) or target_temp (%s) is None. This should be a temporary warning message.

in logs occasionally.

jmcollin78 commented 1 month ago

%s - don't send regulated temperature cause VTherm current_temp (%s) or target_temp (%s) is None. This should be a temporary warning message.

This is the new error message replacing the exception stacktrace you had before TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

The target temperature doesn't have value in your case.

maia commented 1 month ago

The target temperature doesn't have value in your case.

Could this be related to https://github.com/jmcollin78/versatile_thermostat/discussions/497 ?

jmcollin78 commented 1 month ago

I guess not. It seems to be specific to Google Nest and Fahrenheit

jdeksup commented 1 month ago

Hey, I put myself inside the conversation as I got a similar behavior with my underlying climates (Atlantic AC).

Versions :

State of my underlying climate :

hvac_modes: off, heat_cool, cool, heat
min_temp: 16
max_temp: 30
fan_modes: auto, on
current_temperature: 22.8
temperature: null
target_temp_high: null
target_temp_low: null
fan_mode: auto
occupied_cooling_setpoint: 2150
occupied_heating_setpoint: 2100
system_mode: [<SystemMode.Off: 0>]/off
friendly_name: Clim bureau JD Thermostat
supported_features: 395

When comparing #510 code (underlyings.py) :

    async def set_temperature(self, temperature, max_temp, min_temp):
        """Set the target temperature"""
        if not self.is_initialized:
            return

        # Issue 508 we have to take care of service set_temperature or set_range
        target_temp = self.cap_sent_value(temperature)

        if (
            ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
            in self._underlying_climate.supported_features
        ):
            data = {
                ATTR_ENTITY_ID: self._entity_id,
                "target_temp_high": target_temp,
                "target_temp_low": target_temp
            }
        else:
            data = {
                ATTR_ENTITY_ID: self._entity_id,
                "temperature": target_temp,
            }

and action form (on the underlying climate) : image In Heat or Cool mode : when not setting "Temperature", nothing append on the climate (and no errors are logged). In Heat_Cool mode : it works with low and high temperature.

I quickly fix the code for a live test, and doing this works well :

        # Issue 508 we have to take care of service set_temperature or set_range
        target_temp = self.cap_sent_value(temperature)
        if (
            ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
            in self._underlying_climate.supported_features
        ):
            data = {
                ATTR_ENTITY_ID: self._entity_id,
                "target_temp_high": target_temp,
                "target_temp_low": target_temp,
                "temperature": target_temp  # Line added
            }
        else:
            data = {
                ATTR_ENTITY_ID: self._entity_id,
                "temperature": target_temp,
            }

Maybe you was not able to test it ?

jmcollin78 commented 1 month ago

Thank you @jdeksup , you are totally right, the temperature is missing in TARGET_TEMPERATURE_RANGE data structure. I cannot test that myself because I don't have such thermostat but you have found the trick. Many thanks for this. I will fix that rapidly tomorrow.

The VTherm of @sapphonie have the same capability (TARGET_TEMPERATURE_RANGE), so I guess this will fix also its case.

jmcollin78 commented 1 month ago

I have put the fix into a beta release https://github.com/jmcollin78/versatile_thermostat/releases/tag/6.3.4.beta2

Because I cannot test it myself, can you please give it a try and let me know if it fixes the bug ?

jmcollin78 commented 1 month ago

Please give a try to this release and let me know if the issue is still there. I hope not becaue of the important fixes this release contains: https://github.com/jmcollin78/versatile_thermostat/releases/tag/6.3.4

I keep it open for one or two weeks

jdeksup commented 1 month ago

@jmcollin78 you're welcome ! Many thanks for this project as it is very useful and thanks for the fix. I tried 6.3.4 today and it works as espected with my AC.

sapphonie commented 1 month ago

Works as expected here too. Tysm!

On Sun, Oct 13, 2024, 4:26 PM jkreiss-coexya @.***> wrote:

@jmcollin78 https://github.com/jmcollin78 you're welcome ! Many thanks for this project as it is very useful and thanks for the fix. I tried 6.3.4 today and it works as espected with my AC.

— Reply to this email directly, view it on GitHub https://github.com/jmcollin78/versatile_thermostat/issues/518#issuecomment-2409113661, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU3EGIAKYLAO74EHMHARU3Z3LJRDAVCNFSM6AAAAABPG3M3BSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBZGEYTGNRWGE . You are receiving this because you were mentioned.Message ID: @.***>

sapphonie commented 1 month ago

Errrrrrrrrrr... Maybe not, I'm seeing a lot of sudden weird behavior where my thermostat will get yanked like, 6 degrees lower from a manual set target temp, and also seeing 429 errors in my logs... there may be more work to do haha

jmcollin78 commented 1 month ago

Errrrrrrrrrr... Maybe not, I'm seeing a lot of sudden weird behavior where my thermostat will get yanked like, 6 degrees lower from a manual set target temp, and also seeing 429 errors in my logs... there may be more work to do haha

What are the errors please ?

sapphonie commented 1 month ago

Latest vers

Traceback (most recent call last):
File "/config/custom_components/versatile_thermostat/thermostat_climate.py", line 696, in _async_climate_changed
(new_target_temp - under.last_sent_temperature) if new_target_temp else 0
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
2024-10-14 09:15:51.710 WARNING (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - don't send regulated temperature cause VTherm target_temp (None) is None. This should be a temporary warning message.

<snip>

2024-10-14 09:15:56.789 WARNING (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - don't send regulated temperature cause VTherm target_temp (None) is None. This should be a temporary warning message.
2024-10-14 09:15:56.791 WARNING (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Den Thermo - don't send regulated temperature cause VTherm target_temp (None) is None. This should be a temporary warning message.

429s are likely a result of me "fighting" it and pulling the temp back down to intended values

sapphonie commented 1 month ago

Seems to only happen on manual preset, setting to comfort/etc I don't see any strange behavior, at least so far

sapphonie commented 1 month ago

Can also see

Logger: homeassistant.core
Source: core.py:2781
First occurred: 9:36:41 AM (4 occurrences)
Last logged: 9:36:54 AM

Error executing service: <ServiceCall climate.set_temperature (c:<SNIP>): entity_id=['climate.den_thermostat'], target_temp_high=69.0, target_temp_low=69.0, temperature=69.0>
Error executing service: <ServiceCall climate.set_temperature (c:<SNIP>): entity_id=['climate.den_thermostat'], target_temp_high=69.5, target_temp_low=69.5, temperature=69.5>
Error executing service: <ServiceCall climate.set_temperature (c:<SNIP>): entity_id=['climate.den_thermostat'], target_temp_high=68.0, target_temp_low=68.0, temperature=68.0>
Error executing service: <ServiceCall climate.set_temperature (c:<SNIP>): entity_id=['climate.den_thermostat'], target_temp_high=69.0, target_temp_low=69.0, temperature=69.0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/google_nest_sdm/auth.py", line 132, in _raise_for_status
    resp.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1121, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url='https://smartdevicemanagement.googleapis.com/v1/enterprises/<SNIP>:executeCommand'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/nest/climate.py", line 307, in async_set_temperature
    await trait.set_heat(temp)
  File "/usr/local/lib/python3.12/site-packages/google_nest_sdm/thermostat_traits.py", line 111, in set_heat
    return await self.cmd.execute(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/google_nest_sdm/traits.py", line 55, in execute
    return await self._auth.post(f"{self._device_id}:executeCommand", json=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/google_nest_sdm/auth.py", line 113, in post
    return await AbstractAuth._raise_for_status(resp)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/google_nest_sdm/auth.py", line 137, in _raise_for_status
    raise ApiException(": ".join(detail)) from err
google_nest_sdm.exceptions.ApiException: Error from API: 400: FAILED_PRECONDITION: sdm.devices.commands.ThermostatTemperatureSetpoint.SetHeat command not allowed in current thermostat mode.: Bad Request

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2781, in _run_service_call_catch_exceptions
    await coro_or_task
  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 1029, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/nest/climate.py", line 309, in async_set_temperature
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Error setting climate.den_thermostat temperature to {'entity_id': ['climate.den_thermostat'], 'target_temp_high': 20.555555555555554, 'target_temp_low': 20.555555555555554, 'temperature': 20.555555555555554}: Error from API: 400: FAILED_PRECONDITION: sdm.devices.commands.ThermostatTemperatureSetpoint.SetHeat command not allowed in current thermostat mode.: Bad Request

when manually changing heat cool mode

jmcollin78 commented 1 month ago

(new_target_temp - under.last_sent_temperature) if new_target_temp else 0


TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

This is possible if the device sends its state before any setpoint command are send to it before. I imagine this is rare but possible. I will add more test for this case.

jmcollin78 commented 1 month ago

homeassistant.exceptions.HomeAssistantError: Error setting climate.den_thermostat temperature to {'entity_id': ['climate.den_thermostat'], 'target_temp_high': 20.555555555555554, 'target_temp_low': 20.555555555555554, 'temperature': 20.555555555555554}: Error from API: 400: FAILED_PRECONDITION: sdm.devices.commands.ThermostatTemperatureSetpoint.SetHeat command not allowed in current thermostat mode.: Bad Request

For this error, the code of Nest component is the following:

async def async_set_temperature(self, **kwargs: Any) -> None:
        """Set new target temperature."""
        hvac_mode = self.hvac_mode
        if kwargs.get(ATTR_HVAC_MODE) is not None:
            hvac_mode = kwargs[ATTR_HVAC_MODE]
            await self.async_set_hvac_mode(hvac_mode)
        low_temp = kwargs.get(ATTR_TARGET_TEMP_LOW)
        high_temp = kwargs.get(ATTR_TARGET_TEMP_HIGH)
        temp = kwargs.get(ATTR_TEMPERATURE)
        if ThermostatTemperatureSetpointTrait.NAME not in self._device.traits:
            raise HomeAssistantError(
                f"Error setting {self.entity_id} temperature to {kwargs}: "
                "Unable to find setpoint trait."
            )
        trait = self._device.traits[ThermostatTemperatureSetpointTrait.NAME]
        try:
            if self.preset_mode == PRESET_ECO or hvac_mode == HVACMode.HEAT_COOL:
                if low_temp and high_temp:
                    if high_temp - low_temp < MIN_TEMP_RANGE:
                        # Ensure there is a minimum gap from the new temp. Pick
                        # the temp that is not changing as the one to move.
                        if abs(high_temp - self.target_temperature_high) < 0.01:
                            high_temp = low_temp + MIN_TEMP_RANGE
                        else:
                            low_temp = high_temp - MIN_TEMP_RANGE
                    await trait.set_range(low_temp, high_temp)
            elif hvac_mode == HVACMode.COOL and temp:
                await trait.set_cool(temp)
            elif hvac_mode == HVACMode.HEAT and temp:
                await trait.set_heat(temp)                   <----------------------------- it fails here
        except ApiException as err:
            raise HomeAssistantError(.                     <----------------------------- it fails here
                f"Error setting {self.entity_id} temperature to {kwargs}: {err}"
            ) from err

the error is when calling: trait.set_heat(temp) but I have no idea of why this calls fails in HEAT mode. I suggest to open an issue directly to the Nest team (in HA core github)

jmcollin78 commented 1 month ago

For the first error message: https://github.com/jmcollin78/versatile_thermostat/releases/tag/6.4.0

sapphonie commented 1 month ago

Have not seen any errors or strange issues since updating to latest version as of now. Also recreated my config for good measure.

Probably good to close.

sapphonie commented 1 month ago

(new_target_temp - under.last_sent_temperature) if new_target_temp else 0

TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

This is possible if the device sends its state before any setpoint command are send to it before. I imagine this is rare but possible. I will add more test for this case.

Still seeing this:

Logger: homeassistant
Source: util/unit_conversion.py:540
First occurred: October 18, 2024 at 4:31:49 PM (146 occurrences)
Last logged: October 21, 2024 at 11:35:39 PM

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/report_state.py", line 123, in _async_entity_state_listener
    entity_data = entity.query_serialize()
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/helpers.py", line 698, in query_serialize
    deep_update(attrs, trt.query_attributes())
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 1250, in query_attributes
    TemperatureConverter.convert(
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 82, in convert
    return cls.converter_factory(from_unit, to_unit)(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 540, in _fahrenheit_to_celsius
    return (fahrenheit - 32.0) / 1.8
            ~~~~~~~~~~~^~~~~~
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

when trying to use heat_cool mode w/ Nest, lmk if you want me to close this and create a new issue instead, ty!

jmcollin78 commented 3 weeks ago

Hello @sapphonie ,

This is not in VTherm code. The error message in VTherm code is now fixed.

when trying to use heat_cool mode w/ Nest, lmk if you want me to close this and create a new issue instead, ty!

Huuum, heat_cool is a very bad idea (from what I see on my side). Sometimes you wil lhave some issue like:

  1. it starts to heat,
  2. then the device think it is too hot and stars to cool,
  3. then the device think it is too cold and restart to heat.

So i'm not sure this hvac_mode works because as far as I know nobody uses this. VTherm have been tested with COOL or HEAT but not with HEAT_COOL.

I will close the issue now, please reopen if you think it is necessary