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
128 stars 21 forks source link

[feat] Fan speed #196

Closed Bergoglio closed 3 months ago

Bergoglio commented 6 months ago

Hi,

the fan option is a good news. My question is : can You develop also a fan speed manager inside Dual-smart-thermostat ? For example I have this setup : I have only fan-coils (two types, this Aermec fix speeds with 3 fixed fan speeds plus 0 and this Aermec inverter with variable fan speed from 0 to 100% that are both heater + cooler) ; I used on inverter type an ESP32 Chinese electronic board with ESPHome firmware and on fixed speeds type a Shelly relè. It will be awesome if Dual-smart-thermostat can also calculate and publish the right fan speed. My idea is :

  1. first parameter > fan coil fixed speed or fan coil inverter
  2. if fan coil fixed speed > parameter : max difference between target temperature and real temperature to choose speed 1, max difference between target temperature and real temperature to choose speed 2, etc. (max five speeds) The logic is : in heating Dual-smart switch on toggle for heating so trough an automation is possible to give order to fan coil to open hot water valve (via relè, via modbus, etc.) and also Dual-smart publish the right speed (1, 2, 3 or so on) and trough an automation is possible to give order to fan coil to switch the right fan speed (via relè, via modbus, etc.) ; in cooling Dual-smart switch on toggle for cooling so trough an automation is possible to give order to fan coil to open cold water valve (via relè, via modbus, etc.) and also Dual-smart publish the right speed (1, 2, 3 or so on) and trough an automation is possible to give order to fan coil to switch the right fan speed (via relè, via modbus, etc.)
  3. if fan coil inverter > parameter : minimum percentage for speed, max percentage for speed, difference between target temperature and real temperature to choose max percentage for speed The logic is : in heating Dual-smart switch on toggle for heating so trough an automation is possible to give order to fan coil to open hot water valve (via relè, via modbus, etc.) and also Dual-smart publish the percentage for speed (a calculation, if I set that 20% min speed + 80% max speed + difference for max speed is 1 degree and the difference target / real is 0.6 the published percentage will be 56%) and trough an automation is possible to give order to fan coil to switch the right fan speed (via relè, via modbus, etc.); the same for cooling.
  4. the maximum will be also if it is possible to define an external switch for quiet mode that limits the max speed > for example a "good night" switch that I manually activate for the night...
swingerman commented 6 months ago

At this point, we can turn on/off the switches from the thermostat. I can create extra attributes for speed steps or percentages, which one can use in automation. Regarding the quiet mode, extending the preset modes with fan speed should be the way to go. You will be able to choose a preset, like "sleep," and it will set everything for you.

swingerman commented 6 months ago

I would suggest making use of the built-in fan_mode support of the climate platform in home assistant: https://developers.home-assistant.io/docs/core/entity/climate/#fan-modes This will make it easier to implement as the fan_mode is already a defined attribute on which you could build automation.

Bergoglio commented 6 months ago

I don't know what is the best solution (I'm not a developer).... For now I made this solution :

swingerman commented 6 months ago

Ok. The logic to set proper fan speed can be tricky though. In your setup you step up the speed by 0,2 degree difference. So I will set up the logic around that and will make it configurable.

Bergoglio commented 6 months ago

Two elements :

  1. I think that is better if in the yaml configuration there will be two parameters > number of speeds (some fan coil as 2 speeds + 0, others 3 speeds + 0, others 5 speeds + 0, etc. we cannot make a general rule) and degree difference step between speeds (like You told)
  2. starting from my experience, I understood one limit of my automation : if the necessary speed change during a cycle nothing changes on the fancoil; example : night preset is on (20 C degree), real temperature goes to 19,9° C, Dual-smart switches on heating and the speed by my automation is 1, then Simple-scheduler changes preset to comfort (21° C) and the necessary speed is 3 but nothing happens and the fancoil remains in speed 1...... So, it is good if Dual-smart publishes the necessary speed and that it changes continuously the speed if there is an increase until the real temperature matches the target temperature.
swingerman commented 6 months ago

Just to clarify:

The thermostat will not control the switches but will provide the required speed stage and percentage.

Configuration options:

hvac_speed_step: 0.2 # <- temperature step
hvac_speed_steps: 3 # <- fan stages

Note: I prefer not to use literal fan speed to avoid limiting the feature to fan devices.

Provided state attributes:

The speed per cent can be tricky. I will need to use the hvac_speed_step to calculate the percentage or maybe the difference from the tolerance. I'm not sure. If there is only a 1-degree difference, the percentage will be 100%, and if there are 2 degrees, it will still be 100%. What if the system will never reach the target temperature if it is below 10%?

Bergoglio commented 6 months ago

Just to clarify: The thermostat will not control the switches but will provide the required speed stage and percentage.

Yes, You are right !

By my point of view : First configuration option hvac_fan_type: fixed or percentage so there will be hvac_fan_type: fixed hvac_speed_step: 0.2 # <- temperature step hvac_speed_steps: 3 # <- fan stages or hvac_fan_type: percentage hvac_min_start: 20 # <- minim percentage for hardware to start the fan hvac_max_stop: 80 # <- percentage for hardware to achieve max fan speed hvac_start_percentage: 30 # <- percentage when starting diff_max_speed: 1 # <- tolerance where the fan speed must be max

I think the difference from the tolerance is the best way to calculate the percentage, this is the reason of diff_max_speed: : "at what difference the speed must be max ? At 1 degree, at 1.4, at 2, etc." .

If there is only a 1-degree difference, the percentage will be 100%, and if there are 2 degrees, it will still be 100%

Obviusly I agree (and I like)

What if the system will never reach the target temperature if it is below 10%?

We can define a minim percentage when the fan coil must start The formula can be this :

A > calculated percentage B > hvac_start_percentage: C > percentage for every 0.1 difference D > 0.1 steps of difference detected E > hvac_max_stop: F > hvac_min_start: G > number of 0.1 steps from yaml setup H > target temperature I > detected temperature L > diff_max_speed:

hvac_speed_percent = the greater between A and B only when is necessary to heat or cool, when heating and cooling are off the value is 0 where A is A = the greater between E and C * D + F C = (E - F) / G D = (H - I) / 0.1 for heating and (I - H) / 0.1 for cooling G = L / 0.1

Bergoglio commented 4 months ago

Hi,

how are You ? Do You have any news, idea, doubt or plan about fan speed ? I don't want to press, only I think that enhancement will be very usefull for others like for me. I found ready-made boards that can control directly the fancoils, they are based on ESP32 chip and I'm working on the firmware ESPHome : the board will take speed from the thermostat, pay attention to water temperature inside the fancoil and then set the fan speed directly to the fancoil engine in 0-10v. When all will be running, if You want, I can send You a video of the "case history" :) : a kitchen with heating/cooling fancoil, mvhr ventilation and cooker hood all working together......

swingerman commented 4 months ago

I need to finish up other features and I will focus on this one.

swingerman commented 3 months ago

I am implementing a more generic solution that doesn't depend on fan mode, and I will call it hvac_power.

hvac_power_levels: 5
hvac_power_min: 1
hvac_power_max: 4

I am also thinking of including the min/max in the presets so a simple preset change can apply new settings.

Bergoglio commented 3 months ago

I don't understand at 100%..... In this way (hvac_power) it will be fine for fancoils with static speeds ( something like this Aermec 3 speeds ) but in inverter fancoils ( something like this Aermec inverter ) You lose the advantage of an inverter fancoil > the possibility to range fan speed continuously

swingerman commented 3 months ago

I will calculate a percentage and a power level, which will be available at all times.

swingerman commented 3 months ago

There is no need to set which mode to use as both modes will be calculated and provided in the state of the thermostat.

Bergoglio commented 3 months ago

Ok, now I understand. Good, I like it.

swingerman commented 3 months ago

Please check https://github.com/swingerman/ha-dual-smart-thermostat/releases/tag/v0.9.8.beta-3

Note: the feature is not covered with test yet, so there can be bugs

It uses fallback values fo everything defaults: hvac_power_levels: 5 hvac_power_min: 1 hvac_power_max: 5 hvac_power_tolerance: 1 or 33 (based on the metric system of HA)

To enable you need to set either hvac_power_levels or hvac_power_tolerance

hvac_power_tolerance sets the sensitivity. The maximum difference between the current temp and the target temp. In other words the levels and percentages will be calculated inside this tolerance.

Bergoglio commented 3 months ago

Ok, quite late I start tests.... One question out of this item : I saw the function "sensor_stale_duration", but how must I write the time in yaml code ?

swingerman commented 3 months ago

hh:mm:ss

Bergoglio commented 3 months ago

Ok, thanks