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

Percentage of valve opening blocked between 0 and the regulation threshold #533

Closed Kumalo closed 1 month ago

Kumalo commented 1 month ago

Version of the custom_component

V6.2.1

Describe the bug

I am using a SONOFF TRVZB as a thermostat_over_valve and a Nodon switch for the boiler

The problem occurs when the calculated % of the TRV decreases and the set value is between 0 and the regulation threshold: this value is blocked and the boiler is no longer turned off if the temperature in the room is no changing or increases.

Example: If for the TVR, the opening percentage is 7% and the regulation threshold is 10%, we obtain:

As dpercent is lower than the regulation threshold, new_valve_percent is not applied to the TVR valve and remains frozen as long as the chamber temperature does not decrease.

To work around my problem, I modified thermostat_valve.py (L243 and L247) by adding:

If new_valve_percent is less than or equal to auto_regulation_dpercent, update new_valve_percent to 0 Added new_valve_percent != 0 to avoid “do not calculate TPI because regulation_dpercent (-7.0) is not exceeded” :arrow_forward: This avoids having my TRV with an opening percentage between 0 and the regulation threshold

Debug log


2024-10-04 08:23:06.876
recalculate the open percent
heating percent calculated for current_temp 18.9, ext_current_temp 6.6 and target_temp 19.5 is 0.49, on_time is 440 (sec), off_time is 459 (sec)
Setting valve ouverture percent to 49

2024-10-04 08:41:06.958
recalculate the open percent
No heating period due to heating period too small (59.400000 < 300.000000)
heating percent calculated for current_temp 19.3, ext_current_temp 6.6 and target_temp 19.2 is 0.07, on_time is 0 (sec), off_time is 900 (sec)
Setting valve ouverture percent to 7

2024-10-04 08:58:06.714
recalculate the open percent
heating percent calculated for current_temp 19.7, ext_current_temp 6.8 and target_temp 19.2 is 0.00, on_time is 0 (sec), off_time is 900 (sec)
do not calculate TPI because regulation_dpercent (-7.0) is not exceeded

2024-10-04 09:11:04.734
recalculate the open percent
heating percent calculated for current_temp 19.7, ext_current_temp 7.1 and target_temp 19.2 is 0.00, on_time is 0 (sec), off_time is 900 (sec)
do not calculate TPI because regulation_dpercent (-7.0) is not exceeded

:arrow_forward: the last two messages are indefinitely repeated as long as the temperature in the room no longer decreases → the boiler remains turn on.

ludog31 commented 1 month ago

Hello,

I am using BOSCH TRV (BTH-RA) as a thermostat_over_valve and a aqara switch for the boiler Version of the custom_component: 6.3.2 Same problem/comment as [Kumalo] I modified thermostat_valve.py in another way:

An addional comment : could be usefull to enable a lower limit "not to go lower" in % for some valves that are not well calibrated. For instance, mine starts really to open at 15%...If regulation is at 10% by the algorithm, then my valve is actually closed, but boiler continues heating.

Kumalo commented 1 month ago

Hello @ludog31 ,

The aim of my code solution was also to avoid turning on the boiler if the valve was almost closed. It's a slightly different approach (more economic but less confortable) that I explain in #536.

Line 243:

if new_valve_percent <= self._auto_regulation_dpercent:
    new_valve_percent = 0

Line 247:

    and new_valve_percent != 0

Result with some more :logs

new_valve_percent = round(
    max(0, min(self.proportional_algorithm.on_percent, 1)) * 100

_LOGGER.info(
    "%s Check id the calculated new_valve_percent (%.1f) is greater than the auto_regulation_dpercent (%.1f).",
    self,
    new_valve_percent,
    self._auto_regulation_dpercent,
)

if (
    new_valve_percent <= self._auto_regulation_dpercent
   ):
    _LOGGER.info(
        "%s Force new_valve_percent to 0",
        self,
    )
    new_valve_percent = 0

dpercent = new_valve_percent - self.valve_open_percent

if (
    dpercent >= -1 * self._auto_regulation_dpercent
    and dpercent < self._auto_regulation_dpercent
    and new_valve_percent != 0
):
    _LOGGER.debug(
        "%s - do not calculate TPI because regulation_dpercent (%.1f) is not exceeded",
        self,
        dpercent,
    )

    return

Best regards,

jmcollin78 commented 1 month ago

Understood. Than you for the report.

jmcollin78 commented 1 month ago

I take this approch suggested by @Kumalo .

If the new calculated is < regulation precision (_auto_regulation_dpercent) then I set it to 0, The filter to not send new regulated temps is not done if 0 so that VTherm can now set a real 0 to the underlying valve number and then close the central boiler.

I will do a beta release, because I'm not able to test this at home in real conditions. Can you please, give me a feedback on this beta release ?

Thank you in advance

jmcollin78 commented 1 month ago

https://github.com/jmcollin78/versatile_thermostat/releases/tag/6.3.4.beta1

Kumalo commented 1 month ago

Hello @jmcollin78, Thank you for the quick fix : I have just installed it and I will give you feedback asap.

Kumalo commented 1 month ago

I did some tests yesterday afternoon with virtual entities and during the night in real conditions and everything seems to work correctly: The valve has never been blocked between 0 and the regulation threshold.

Thanks,

JanickGers85 commented 3 weeks ago

@Kumalo I know I am off topic here under this issue, but I read you use thermostat over valve on SONOFF TRVZB, which I'm now using as thermostat over climate.

I would really like to use it with partial opening, can I kindly ask you how you achieved it? Do you sue the valve opening percentage? In that case, do you keep the valve always on and let VTherm just regulate the valve opening?

Kumalo commented 3 weeks ago

@Kumalo I know I am off topic here under this issue, but I read you use thermostat over valve on SONOFF TRVZB, which I'm now using as thermostat over climate.

I would really like to use it with partial opening, can I kindly ask you how you achieved it? Do you sue the valve opening percentage? In that case, do you keep the valve always on and let VTherm just regulate the valve opening?

Hello @JanickGers85 ,

Yes, I use a Vtherm over valve and I put the TRVZB.valve_opening_degree entity as underline entity but :.

An other way is to lock the occupied_heating_setpoint to 35 See my post here and there

Kumalo commented 3 weeks ago

Hello @JanickGers85 , I have created a blueprint to facilitate the use of a vtherm over valve with Sonoff trvzb: You can give a try

jmcollin78 commented 3 weeks ago

Hello @JanickGers85 , I have created a blueprint to facilitate the use of a vtherm over valve with Sonoff trvzb: You can give a try

Let me know if you think it is important to reference this blueprint in the readme.

JanickGers85 commented 3 weeks ago

Thanks a lot @Kumalo! I'll try in a few hour, so happy to benefit valve modulation.

Kumalo commented 3 weeks ago

Hello @JanickGers85 , I have created a blueprint to facilitate the use of a vtherm over valve with Sonoff trvzb: You can give a try

Let me know if you think it is important to reference this blueprint in the readme.

Hello @jmcollin78 , It's could be a good idea but I would preferred to do some more tests before and it will be nice to get some feedback from @JanickGers85 too

JanickGers85 commented 3 weeks ago

@Kumalo I'll do it for sure, but I'll return back home tomorrow so I plan to put hands on the configuration this evening and test real case scenario tomorrow.

I'll keep you both updated.

JanickGers85 commented 3 weeks ago

@Kumalo I've managed to create the automations using the blueprint: I had a bit of difficulties since I don't use blueprint/HA automation so it's just because I'm a bit uncomfortable.

A little note: since I have two valves in one room mapped to a single VTherm I've created two automations, one for each TRVZBs so they will be synched both.

As said tomorrow I'll be home (it's 19:22 here right now) so I'll test if everything works as expected.

image

Edit: tried to switch on one valve for a while and I've seen that the bolier has been started with some delay with I think it's OK (it was something like 30 seconds or so). Not that the valve is switched off I see this

image

With temperature calibraton to -7°C and valve closing/opening degree as it follow, which makes sense to me

image

Can't test anymore without being in house, so I'll try again tomorrow evening.