zacs / ha-dualmodegeneric

Generic thermostat capable of heating and cooling
68 stars 26 forks source link

[Feature Request] Ventilator/Dehumidifier Mode #3

Closed alexvenom closed 3 years ago

alexvenom commented 4 years ago

This work is AWESOME and I've been using it with my reverse-cycle HVACs for weeks now. One thing that would make it even more awesome is to have a heater, cooler AND ventilator switch, so we can pick from the thermostat itself if we want to cool the environment using the AC (faster, more power hungry) or using the ventilator (slower, less power hungry). Congratulations on the great work!

zacs commented 4 years ago

Thanks @alexvenom. Just to be clear, you'd want the ventilator mode to act like a cooler? I would just need to know in order to do the logic for target temp (as in, I would have to expect the temp to be higher than target, and get cooler). I think it would be fairly trivial to add as an optional feature.

alexvenom commented 4 years ago

Hey @zacs ! Ventilator working as a cooler would be perfect! Thank you so much for looking into this! Your work is awesome!

david-kalbermatten commented 4 years ago

@zacs As much as I want a ventilator/fan mode, I disagree that running an HVAC in ventilator mode always results in a lower temperature (it depends on the outside temperature when running a mobile unit). Please make the ventilator mode runnable without temperature control or maybe add an additional attribute like this in the config, where "neutral"-mode just turns the switch/input_boolean for the ventilator on.

- platform: dualmode_generic
  name: Bedroom Thermostat
  cooler: input_boolean.air_conditioner
  heater: input_boolean.space_heater
  dehumidifier: input_boolean.dehumidifier # <--- Dehumidifier Switch
  ventilator: input_boolean.ventilator # <--- Ventilator Switch
  ventilator_mode: [cool, heat, neutral] # <--- This defines the behaviour of the ventilator
  target_sensor: sensor.shelly_shht_1_f03be6_temperature
  target_temp: 20.0
  min_temp: 16
  max_temp: 30
  cold_tolerance: 0.4
  hot_tolerance: 0.4
  min_cycle_duration:
      minutes: 2

Edit: Since you called this issue "Ventilator/Dehumidifier", it would make sense to add a ventilator AND dehumidifier mode

bbbates commented 4 years ago

Could you not just determine what mode to put the unit into in the cooler switch, rather than having a different mode altogether?

You could also have a couple of automations to switch between the two as the temp (or humidity, if you have a sensor) changes.

david-kalbermatten commented 4 years ago

@bbbates Since you didn't tag anyone, I'll try to answer the question. @alexvenom wanted a ventilator mode where he could run his HVAC in ventilator mode (not cooling mode) in order to slowly cool down his house/room and still have it controlled by the thermostat. I added that depending on your HVAC-setup the temperature might actually rise from running in ventilator mode. Hence why I proposed a way to define the ventilation_mode further (basically telling the thermostat whether to actively control the ventilator_switch when in ventilator mode or to just run independently of the temperature set in the thermostat, always-on/manual mode).

And I think adding the ventilator and dehumidifier mode as optional attributes would make this custom integration all the more powerful.

alexvenom commented 4 years ago

Hey guys! I didn't put much thinking on it but now that @david-kalbermatten explained what's in his mind, it seems much better and makes a lot of sense.

bbbates commented 4 years ago

@david-kalbermatten I didn't tag anyone as it was a general question to the watchers of this issue.

@alexvenom did you try setting up 2 thermostats? A built-in Generic Thermostat (https://www.home-assistant.io/integrations/generic_thermostat/) which could control the Ventilator/dehumidifier, and a dual-mode thermostat (controlling the heating and cooling)? With some automations, you could easily make sure they are operated exclusively from one another (when one turns on, the other turns off).

IMO besides the triviality of having to rename the component (from "dual mode" to "tri" or "quad mode"), this additional feature places a lot of assumptions on the functionality of the device(s) that the thermostat is controlling, beyond just being about heating and cooling a room. I think there are probably smarter ways to control the mode of the underlying heating and cooling devices that this thermostat component interacts with than just adding an extra selectable mode, but as long as it's an optional feature, it's probably fine.

zacs commented 4 years ago

@bbbates I tend to agree with you here. The whole point of the plugin at first was "one switch for up, one switch for down" and the fact that they happen to be called heater and cooler was meant to be vague (eg. a cooler can be an AC unit or it can be a dehumidifier). I can see this snowballing into adding a fan (quintuple mode!) and probably others as well.

Another option would be to use a switch template as your cooler (or heater), which manages the actual mode of the AC unit/ventilator, and then have an input_boolean exposed that allows the user to determine the template switch's mode. That seems like it would make sense to me.


climate:
  - platform: dualmode_generic
    name: My Thermostat
    heater: switch.heater
    cooler: switch.cooler_switch
    target_sensor: sensor.my_temp_sensor

input_boolean:
  ventilator_only: 
    name: "Only use ventilator for cooling" 

switch:
  - platform: template
    switches:
      cooler_switch:
      # logic for turning on/off AC if ventilator_only==False, otherwise turn on ventilator
david-kalbermatten commented 4 years ago

I made the necessary changes for the hvac_mode_ventilator to be working as a cooler and dropped my own suggestion of defining the behavior in the config file. And I also dropped the idea of having a Dehumidifier mode :D

Pull request: #8

- platform: dualmode_generic
  name: Bedroom Thermostat
  cooler: input_boolean.air_conditioner
  heater: input_boolean.space_heater
  # not implemented dehumidifier: input_boolean.dehumidifier
  ventilator: input_boolean.ventilator # <--- Ventilator Switch
  # not implemented ventilator_mode: [cool, heat, neutral]
  target_sensor: sensor.shelly_shht_1_f03be6_temperature
  target_temp: 20.0
  min_temp: 16
  max_temp: 30
  cold_tolerance: 0.4
  hot_tolerance: 0.4
  min_cycle_duration:
      minutes: 2

Fan Mode: Idle

image

Fan Mode: Active

image

zacs commented 4 years ago

@david-kalbermatten I really like the idea of leveraging the fan properties of the climate entity. I think in general this component can/should turn into a more complete representation of that entity (and i should add the ability for folks to declare a humidity sensor, etc).

Apologies for the back and forth, but do you think you could rename your ventilator property to fan so that it maps more directly to the climate entity?

david-kalbermatten commented 4 years ago

@zacs sure, no problem. I'll probably add the "fan_behaviour" property tomorrow as well, which would then allow you to define whether it acts like a heater, a cooler or just stays on i.e. not controlled by the thermostat.

bbbates commented 4 years ago

I would suggest if something isn't going to be controlled by the thermostat, then it shouldn't in the thermostat component - I think it would be confusing to leave in.

david-kalbermatten commented 4 years ago

@bbbates In a way, it's going to be controlled by the thermostat just not by the temperature set for it (if running with neutral behavior). In some cases, you may want to be able to just 'tell' the thermostat that you want the fan to run independently of the temperature to have air circulation. And if we think of the climate entity as one real-life device it makes sense to have this included as it prevents the device from accidentally being trigering by two switches belonging to the same device.

In my case, the mobile HVAC cannot be in state fan and state cooling at the same time (of course the fan does run while running in cooling mode, however the state fan is another state the HVAC can be in)

david-kalbermatten commented 4 years ago

Update

@zacs @bbbates @alexvenom Alright, I have an update for you guys! I finished the implementation of the fan-mode and dryer/dehumidifier-mode and also reworked the reverse_cycle-option (I'll let @bbbates be the judge whether my implementation of reverse_cycle passes :D)

Sample Config

- platform: dualmode_generic
  name: Your Thermostat Name
  cooler: input_boolean.your_air_conditioner
  heater: input_boolean.your_space_heater
  fan: input_boolean.your_fan
  fan_behavior: cooler
  dryer: input_boolean.your_dehumidifier
  dryer_behavior: heater
  reverse_cycle: heater, cooler
  target_sensor: sensor.your_temperature_sensor
  [...]

fan_behavior and dryer_behavior

Possible values: heater, cooler, neutral Default: neutral i.e. "Always-On when selected in thermostat"

These config-properties define the wanted behavior of the fan and dryer. If you have a dehumidifier that heats up the room while running, you can have it run like a heater which means that the dryer is controlled by the temperature of the sensor/thermostat.

reverse_cycle

Possible values: heater, cooler, fan, dryer Default: <-- Empty List

The reverse_cycle is now a comma-separated list of operation modes. This means all values you set for this property will be treated as one device (at least this is my understanding of the mode...)

So, if you have an HVAC that can act as a cooler and heater, you add the following:

reverse_cycle: cooler, heater

Pictures

heating cooling drying fan

bbbates commented 4 years ago

Thanks for the effort @david-kalbermatten.

As I mentioned in the PR, I really don’t think this is the right approach for this component. From reading @david-kalbermatten ’s notes on what he’s trying to get working, it seems like the component he’s missing from home assistant is a “Template HVAC” integration, one that implements the set of Climate services (https://www.home-assistant.io/integrations/climate/) and represents the commands that your IR transmitter needs to send to your portable HVAC device to get it to operate - similar to(but probably more complicated than) the Template Fan (https://www.home-assistant.io/integrations/fan.template/). Doing this will give you the nice HVAC Lovelace panel that I think you’re trying to get from using this Thermostat component. I reckon this would be a pretty addition for the community - might even be able to get it into the core project! If you get that Template HVAC device working, you could still definitely make use of this Thermostat component for controlling the temperature, by providing switches that set the right mode on your new device.

Obviously, this isn’t my component 🙂 so I’ll leave it to @zacs to decide how to proceed.

david-kalbermatten commented 4 years ago

@bbbates Yea, I see your point and I might actually be crazy enough to make a climate template in the style of the fan template. As a matter of fact, I actually set up my bedroom fan using the fan template :D

However, this doesn't change that adding these modes to this integration is valuable as well. Right now we think of the most common use case, people using this integration to control ONE physical device i.e. an HVAC. But it is important to keep in mind that not every HVAC unit has a reversible heat pump. Some, like mine, can only cool, dehumidify and run as a fan. So I might want to run a space heater or toggle a smart valve of one of the radiators which are part of the central heating system in my house (very commonplace in Switzerland).

TDLR; Only because you might not see a good use case for these additions (they are optional after all...) doesn't mean no one sees one ;D

And in case you're concerned that people who update the integration run into the inevitable issue of having to update the config, I added True\False as a placeholder for heater, cooler\[] which allows keeping the old configuration values for reverse_cycle: as is.

bbbates commented 4 years ago

Right now we think of the most common use case, people using this integration to control ONE physical device i.e. an HVAC. But it is important to keep in mind that not every HVAC unit has a reversible heat pump. Some, like mine, can only cool, dehumidify and run as a fan. So I might want to run a space heater or toggle a smart valve of one of the radiators which are part of the central heating system in my house (very commonplace in Switzerland).

But, you can do that all right now with the current version of this component.

To use your example, if you want the central heating and space heater to come on when in heat mode, you can specify that in your heater switch. Something like:

switch:
- platform: template
  switches:
    heat_the_house:
      value_template: "{{ is_state('climate.central, 'heat') and is_state('climate.bar', 'heat') }}"
      turn_on:
        service: script.heat_house
      turn_off:
        service: script.heaters_off

script:
  heat_house:
    alias: Heat house
    sequence:
    # turn on central heat
    - service: climate.set_hvac_mode
      data:
        entity_id: climate.central
        hvac_mode: heat
    # turn on bar heater
    - service: climate.set_hvac_mode
      data:
        entity_id: climate.bar
        hvac_mode: heat

  heaters_off:
    alias: Heaters off
    sequence:
      - service: climate.turn_off
        data:
          entity_id: climate.central
      - service: climate.turn_off
        data:
          entity_id: climate.bar
brandondb1 commented 4 years ago

Hi All, this looks really great, and thanks for the component. I'm finally done with my Nest, and building my own stat based on a relay block and ESP.

For my $0.02, the fan is more of a temperature equalizer, so it neither heats nor cools, but redistributes air throughout the house. I live in Canada and have south facing windows, so in the winter my living room can be 30C, while the basement is 15C - no need to run the furnace, just mix the air to cool the living room and warm the basement. Same in the summer, upstairs is hot, downstairs is cool(er), so mixing the air is the efficient way to make all the space comfortable.

Also, we have a central humidifier in the winter (always run in tandem with heat), so if you are implementing a dehumidifier, maybe a humidifier as well, working on the same line as heat/cool around a target humidity value?

Anyway, just ideas. Humidity in my system is on a separate relay switch, so that's an easy automation, as is the fan, but it would be nice to have all the controls and a humidity setpoint in the thermostat rather than another input_number and a separate card beneath it.

Thanks again for your work on this, and for getting me out from under my !%$#& Nest.

Brandon

david-kalbermatten commented 4 years ago

@brandondb1 What you're asking is an entirely new feature request and as such, you should open a new issue for that. Also, I saw pull-requests to the core of home assistant for various humidifier/dehumidifier related entities as default components. https://github.com/home-assistant/core/pull/28693

Also, we have a central humidifier in the winter (always run in tandem with heat), so if you are implementing a dehumidifier, maybe a humidifier as well, working on the same line as heat/cool around a target humidity value?

Yea, that's called a hygrostat.

[...]so that's an easy automation, as is the fan, but it would be nice to have all the controls and a humidity setpoint in the thermostat rather than another input_number and a separate card beneath it.

And it sounds like a cool idea for the future, to have a single UI-Element with all the climate controls, including humidity control. However, I fear this is way out of scope for this integration.

Kind regards, David

brandondb1 commented 4 years ago

Hi David,

Thanks for the reply. It wasn't my intent to suggest new features per se (although I see that I kind of did) - more just another context. As I've been figuring this all out, it's apparent to me that there are a vast range of configurations in HVAC, and particularly that Europe an North America have vastly different systems that would be hard to make work under one 'roof', so I agree that making one all-encompassing integration is likely out of scope, and perhaps not even possible.

As far as the fan goes, It was just a convenience thing to be able to turn it on manually and show it's state from within the stat card, and my opinion on fan as temperature control device...

Let me know if you need help testing anything.

Brandon

david-kalbermatten commented 3 years ago

@zacs I think this issue can be closed now since you merged #8

zacs commented 3 years ago

Correct! Closing as added in #8.