jmcollin78 / versatile_thermostat

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

thermostat_over_valve - Valeur d'ouverture maximale de la valve #249

Closed pereverti closed 11 months ago

pereverti commented 11 months ago

Bonjour,

Tout d'abord, merci pour cette merveilleuse intégration !

Je suis équipé de têtes de radiateurs Eurotronics Spirit Z-Wave dont on peut directement piloter les valves. Je rencontre l'erreur suivante : lors de l'ouverture maximale des valves (100%), ces dernières ne répondent pas. Lors d'une ouverture partielle, aucun problème. Je me suis penché sur le problème et j'ai trouvé dans les logs l'erreur suivante :

2023-12-07 07:56:38.699 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall number.set_value (c:01HH1H0TRDVJANNR72AFQ6VJDD): entity_id=['number.radiateur_cuisine_valve_control'], value=100.0>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2083, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 96, in async_set_value
    raise ValueError(
ValueError: Value 100.0 for number.radiateur_cuisine_valve_control is outside valid range 0.0 - 99.0

J'ai donc modifié la propriété valve_open_percent de la classe ThermostatOverValve du fichier thermostat_valve.py :

@property
    def valve_open_percent(self) -> int:
        """ Gives the percentage of valve needed"""
        if self._hvac_mode == HVACMode.OFF:
            return 0
        else:
            valvePercentage = round(max(0, min(self.proportional_algorithm.on_percent, 1)) * 100)

            if valvePercentage == 100:
                return 99
            else:
                return valvePercentage

Ceci est un dirty workaround qui me permet de solutionner mon problème. L'idée aurait été de rendre cela plus générique en récupérant la valeur maximale de l'ouverture admissible de la valve, car je pense que cette valeur doit changer en fonction des têtes de radiateur. Cela semble possible car cette valeur est remontée dans l'erreur (Value 100.0 for number.radiateur_cuisine_valve_control is outside valid range 0.0 - 99.0). Cette récupération de valeur maximale pourrait par exemple être faite au démarrage de l'intégration pour être stockée dans une constante afin d'être utilisée dans la propriété. N'étant pas familier de l'environnement tout comme de cette intégration, c'est la raison pour laquelle je me permets d'ouvrir ce ticket avec mes constations et mes réflexions.

Merci beaucoup pour ton aide.

jmcollin78 commented 11 months ago

Hello oui très bien !. Si des fois tu savais me faire une PR ce serait vraiment fabuleux. Ce pourcentage pourrait être mis dans la page de config spécial valve ou dans le mode expert donc directement dans le configuration.yaml pour éviter de surcharger l'UI.

Si tu ne sais pas faire, je le ferais c'est pas bien compliqué.

jmcollin78 commented 11 months ago

Peut être même que le number peut donner sa plage directement ? Tu peux regarder dans Outils de dev / Etats, tu choisis le number et regarde si des fois y a pas le min et max.

jmcollin78 commented 11 months ago

Chez moi un number: Capture d’écran 2023-12-08 à 16 17 59

pereverti commented 11 months ago

Salut Jean-Marc,

Merci pour ton retour et tes indications. Je vais essayer de faire au mieux pour trouver la valeur max. Je vais essayer de comprendre comment la mettre dans la config et comment aller la chercher dans la propriété. Et bein entendu je ferai un pull request si j'arrive à faire quelque chose de propre.

pereverti commented 11 months ago

J'arrive en effet à trouver les valeurs mini et maxi dans les outils développeur: Selection_007

jmcollin78 commented 11 months ago

Salut Jean-Marc,

Merci pour ton retour et tes indications. Je vais essayer de faire au mieux pour trouver la valeur max. Je vais essayer de comprendre comment la mettre dans la config et comment aller la chercher dans la propriété. Et bein entendu je ferai un pull request si j'arrive à faire quelque chose de propre.

Ce serait super. Du coup pas besoin de configuration, c'est juste très localisé comme code dans la methode class UnderlyingValve, methode set_valve_open_percent du fichier underlying.py .

Tu as l'entity_id du number dans init de cette même classe. Si tu initialise le min et max ici en le stockant en attribut de la classe, tu auras fait le taf.

Pour récupérer le dernier état connu d'une entité: hass.last_states.get(entity_id)

Si tu ne t'en sors pas, on s'en reparle ici.

DavidGeorge528 commented 11 months ago

Hi, was this issue intended to be fixed in v5?

As I noticed the other related issues were closed but this is still open and the issue still persists for me in the newest release Thanks

jmcollin78 commented 11 months ago

Hello, no. V5.0 was dedicated to the central configuration but the next 5.1 will take this into account. There is many open tickets on this particular point.

jmcollin78 commented 11 months ago

@pereverti was looking if it is possible to implement the check but I will do it myself because I have to generalize this check feature. @pereverti did you start dev ? If no, please don't start. I will take it.

DavidGeorge528 commented 11 months ago

Great thanks! This issue is the only thing that I have problems with using this integration, as I have to manually set my VTherms to turn them off so the temperature doesn't go too low on the underlying TRVs

If there is anything I can do to help, let me know, I'm a Python developer

jmcollin78 commented 11 months ago

When the implementation will be done, I will publish a beta. I would love if you could test it on your environement. I have no way to test it on my side (no TRV), only on unit tests.

DavidGeorge528 commented 11 months ago

Would be happy to! Let me know when it's ready

jmcollin78 commented 11 months ago

Hello, I publish the beta release just now: https://github.com/jmcollin78/versatile_thermostat/releases/tag/5.1.0.beta1

Can you please give it a try ?

pereverti commented 11 months ago

@pereverti was looking if it is possible to implement the check but I will do it myself because I have to generalize this check feature. @pereverti did you start dev ? If no, please don't start. I will take it.

Hi Jean-Marc,

I apologize for the delay. I tried to set up a test environment with AppDaemon without success and I had some difficulties to find how to interview TRVs to get the maximum allowed open value.

The only thing I can do is testing your beta version. I confirm you that it works. Now Versatile thermostat shows an opening of 100% and the TRV valve value is 99.

Thank you very much for your patch, and sorry again for not helping you more.

jmcollin78 commented 11 months ago

@hello @pereverti , that is exactly what was expected so, I wil release this patch maybe late on the afternoon. You can keep it in beta while.

DavidGeorge528 commented 11 months ago

I can confirm when the thermostat is set low or off the underlying TRV is set to the minimum value in the settings, however the same is not true for the max.

In my case my TRV goes up to 35C which is set in the VTherm settings. Setting the VTherm to 35 results in no message being sent to the TRV:

2023-12-20 15:38:34.361 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Bathroom - Set target temp: 35.0
2023-12-20 15:38:34.361 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Bathroom - Calling ThermostatClimate._send_regulated_temperature force=True
2023-12-20 15:38:34.362 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Bathroom - regulation calculation will be done
2023-12-20 15:38:34.362 DEBUG (MainThread) [custom_components.versatile_thermostat.pi_algorithm] PITemperatureRegulator - Error: 15.06 accumulated_error: 50.00 offset: 10.02 offset_ext: 0.00 target_tem: 35.0 regulatedTemp: 40.0
2023-12-20 15:38:34.362 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Bathroom - Regulated temp have changed to 40.0. Resend it to underlyings
2023-12-20 15:38:34.362 INFO (MainThread) [custom_components.versatile_thermostat.underlyings] VersatileThermostat-Bathroom-climate.bathroom_trv - Target temp have been updated due min, max of the underlying entity. new_value=35 value=40 min=5 max=35
2023-12-20 15:38:34.363 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Bathroom - recalculate all
2023-12-20 15:38:34.365 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Bathroom - Calling update_custom_attributes: {'is_on': True, 'hvac_action': <HVACAction.IDLE: 'idle'>, 'hvac_mode': 'heat', 'preset_mode': 'none', 'type': None, 'frost_temp': 7.0, 'eco_temp': 16.0, 'boost_temp': 25.0, 'comfort_temp': 21.0, 'frost_away_temp': 7.0, 'eco_away_temp': 16.0, 'boost_away_temp': 25.0, 'comfort_away_temp': 21.0, 'power_temp': 13.0, 'target_temperature_step': 0.5, 'ext_current_temperature': 11.0, 'ac_mode': False, 'current_power': None, 'current_power_max': None, 'saved_preset_mode': 'frost', 'saved_target_temp': 16.0, 'saved_hvac_mode': None, 'window_state': 'off', 'motion_state': None, 'overpowering_state': None, 'presence_state': None, 'window_auto_state': 'off', 'window_bypass_state': False, 'security_delay_min': 60, 'security_min_on_percent': 0.5, 'security_default_on_percent': 0.1, 'last_temperature_datetime': '2023-12-20T15:24:39.182362+00:00', 'last_ext_temperature_datetime': '2023-12-20T15:24:30.861834+00:00', 'security_state': False, 'minimal_activation_delay_sec': 10, 'device_power': 0.0, 'mean_cycle_power': None, 'total_energy': 0, 'last_update_datetime': '2023-12-20T15:38:34.363560+00:00', 'timezone': 'Europe/London', 'window_sensor_entity_id': 'binary_sensor.bathroom_window_contact_contact', 'window_delay_sec': 30, 'window_auto_enabled': True, 'window_auto_open_threshold': 3.0, 'window_auto_close_threshold': 0.0, 'window_auto_max_duration': 60, 'motion_sensor_entity_id': None, 'presence_sensor_entity_id': None, 'power_sensor_entity_id': None, 'max_power_sensor_entity_id': None, 'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>, 'is_device_active': False, 'ema_temp': 20.04, 'is_over_climate': True, 'start_hvac_action_date': None, 'underlying_climate_0': 'climate.bathroom_trv', 'underlying_climate_1': None, 'underlying_climate_2': None, 'underlying_climate_3': None, 'is_regulated': True, 'regulated_target_temperature': 40.0, 'auto_regulation_mode': 'auto_regulation_strong', 'regulation_accumulated_error': 50, 'auto_fan_mode': 'auto_fan_none', 'current_auto_fan_mode': 'auto_fan_none', 'auto_activated_fan_mode': None, 'auto_deactivated_fan_mode': None}
2023-12-20 15:38:34.365 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Bathroom - last_change_time is now 2023-12-20 15:38:34.365731+00:00
2023-12-20 15:38:34.366 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Bathroom - Checking new cycle. hvac_mode=heat, security_state=False, preset_mode=none
2023-12-20 15:38:34.366 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Bathroom - Window auto is on, check the alert. last slope is -0.980
2023-12-20 15:38:34.366 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Bathroom - power not configured. check_overpowering not available
2023-12-20 15:38:34.366 DEBUG (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Bathroom - checking security delta_temp=13.9 delta_ext_temp=14.1 mod_cond=True temp_cond=False climate_cond=False switch_cond=False
2023-12-20 15:38:34.369 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Bathroom - Calling update_custom_attributes: {'is_on': True, 'hvac_action': <HVACAction.IDLE: 'idle'>, 'hvac_mode': 'heat', 'preset_mode': 'none', 'type': None, 'frost_temp': 7.0, 'eco_temp': 16.0, 'boost_temp': 25.0, 'comfort_temp': 21.0, 'frost_away_temp': 7.0, 'eco_away_temp': 16.0, 'boost_away_temp': 25.0, 'comfort_away_temp': 21.0, 'power_temp': 13.0, 'target_temperature_step': 0.5, 'ext_current_temperature': 11.0, 'ac_mode': False, 'current_power': None, 'current_power_max': None, 'saved_preset_mode': 'frost', 'saved_target_temp': 16.0, 'saved_hvac_mode': None, 'window_state': 'off', 'motion_state': None, 'overpowering_state': None, 'presence_state': None, 'window_auto_state': 'off', 'window_bypass_state': False, 'security_delay_min': 60, 'security_min_on_percent': 0.5, 'security_default_on_percent': 0.1, 'last_temperature_datetime': '2023-12-20T15:24:39.182362+00:00', 'last_ext_temperature_datetime': '2023-12-20T15:24:30.861834+00:00', 'security_state': False, 'minimal_activation_delay_sec': 10, 'device_power': 0.0, 'mean_cycle_power': None, 'total_energy': 0, 'last_update_datetime': '2023-12-20T15:38:34.368085+00:00', 'timezone': 'Europe/London', 'window_sensor_entity_id': 'binary_sensor.bathroom_window_contact_contact', 'window_delay_sec': 30, 'window_auto_enabled': True, 'window_auto_open_threshold': 3.0, 'window_auto_close_threshold': 0.0, 'window_auto_max_duration': 60, 'motion_sensor_entity_id': None, 'presence_sensor_entity_id': None, 'power_sensor_entity_id': None, 'max_power_sensor_entity_id': None, 'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>, 'is_device_active': False, 'ema_temp': 20.04, 'is_over_climate': True, 'start_hvac_action_date': None, 'underlying_climate_0': 'climate.bathroom_trv', 'underlying_climate_1': None, 'underlying_climate_2': None, 'underlying_climate_3': None, 'is_regulated': True, 'regulated_target_temperature': 40.0, 'auto_regulation_mode': 'auto_regulation_strong', 'regulation_accumulated_error': 50, 'auto_fan_mode': 'auto_fan_none', 'current_auto_fan_mode': 'auto_fan_none', 'auto_activated_fan_mode': None, 'auto_deactivated_fan_mode': None}
2023-12-20 15:38:34.370 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Bathroom - Calling ThermostatClimate._send_regulated_temperature force=False
2023-12-20 15:38:34.370 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Bathroom - period (0.0) min is < 2 min -> forget the regulation send
2023-12-20 15:38:34.386 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Bathroom_security_state - climate state change
2023-12-20 15:38:34.386 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Bathroom_window_bypass_state - climate state change
2023-12-20 15:38:34.386 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Bathroom_window_state - climate state change
2023-12-20 15:38:34.387 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_last_temp_datetime - climate state change
2023-12-20 15:38:34.387 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_last_ext_temp_datetime - climate state change
2023-12-20 15:38:34.387 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_temperature_slope - climate state change
2023-12-20 15:38:34.387 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_ema_temperature - climate state change
2023-12-20 15:38:34.387 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_regulated_temperature - climate state change
2023-12-20 15:38:34.389 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Bathroom_security_state - climate state change
2023-12-20 15:38:34.393 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Bathroom_window_bypass_state - climate state change
2023-12-20 15:38:34.394 DEBUG (MainThread) [custom_components.versatile_thermostat.binary_sensor] Bathroom_window_state - climate state change
2023-12-20 15:38:34.394 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_last_temp_datetime - climate state change
2023-12-20 15:38:34.394 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_last_ext_temp_datetime - climate state change
2023-12-20 15:38:34.394 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_temperature_slope - climate state change
2023-12-20 15:38:34.394 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_ema_temperature - climate state change
2023-12-20 15:38:34.395 DEBUG (MainThread) [custom_components.versatile_thermostat.sensor] Bathroom_regulated_temperature - climate state change

The logs show that it doesn't send the update to the underlying TRV when the new temperature is above the max, but it also doesn't show any errors or logs saying it was too high, it just skips it. I don't believe this is desired

jmcollin78 commented 11 months ago

Hello @DavidGeorge528 ,

Your logs shows that the regulation have not been sent because a previous regulation have already been send just before (0 min before) :

period (0.0) min is < 2 min -> forget the regulation send

When the min max applied you should see that log:

Target temp have been updated due min, max of the underlying entity. new_value=99 value=100 min=0 max=99

When the min/max apply, the capped temperature is sent whatever does the capping.

jmcollin78 commented 11 months ago

https://github.com/jmcollin78/versatile_thermostat/releases/tag/5.1.0