Generic_thermostat for Humidity

Here is how I understand this system works:

  • D = Desired humidity
  • LO = Low humidity threshold (D - 2.5)
  • HI = High humidity threshold (D + 2.5)
           LO    D     HI
-----------|-----|-----|------------
    OFF    |  CURRENT  |     ON
OFF>>>>>>>>>>>>>>>>>>>>|
           |<<<<<<<<<<<<<<<<<<<<<<ON

There are three operating states:

  • OFF: Ambient humidity is less than LO so the dehumidifier is set to off.
  • ON: Ambient humidity is greater than HI so the dehumidifier is set to on.
  • CURRENT: Ambient humidity is within the range set by LO and HI. The off and on states overlap within the range (it can be either on or off within this range). It depends on whether the dehumidifier is currently on and decreasing the humidity from HI to LO, or if the dehumidifier is off and allowing humidity to rise from LO to HI.

Here’s an example:

  • Desired humidity is 55 so LO=53.5 and HI=57.5
  • Ambient humidity is 57.
  • Dehumidifier is off.
  • Humidity rises to 58 and triggers the automation.
  • Humidity now exceeds HI so the dehumidifier will be set to on.
  • Humidity falls to 57 and triggers the automation. Humidity is less than HI but more than LO. The dehumidifier is set to its CURRENT state which is on (the automation is obliged to assign a value to service_template) .
  • Humidity falls to 56 and triggers the automation. It is still within range and the humidifier is set to its CURRENT state. This pattern repeats until the humidity reaches the LO threshold.
  • Humidity falls to 53 and triggers the automation. It is now less than LO so the dehumidifier is set to off.
  • Humidity rises to 54 and triggers the automation. It is now higher than LO but less then HI. The dehumidifier is set to its CURRENT state which is off. This behavior continues until humidity exceeds HI and then the dehumidifier is set to on.

The following automation implements the behavior I just described. It is triggered either by changes to the sensor or to the input_number. It computes LO and HI thresholds and then determines if the humidity is below, within, or above the range. Depending on the result, it will call the correct service.

  • If humidity < LO then call switch.turn_off
  • If humidity > HI then call switch.turn_on
  • If humidity is between LO and HI then call the service corresponding to the dehumidifier’s CURRENT state.
- id: steckdose1_luftfeuchtigkeit
  alias: 'Steckdose 1 Luftfeuchtigkeit'
  trigger:
    platform: state
    entity_id:
      - input_number.schieber_steckdose1
      - sensor.steckdose1_am2301_humidity
  action:
    service_template: >-
      {% set hi = (states('input_number.schieber_steckdose1') | float) + 2.5 %}
      {% set lo = hi - 5 %}
      {% set humidity = states('sensor.steckdose1_am2301_humidity') | float %}
      {% if humidity > hi %}
        switch.turn_on
      {% elif humidity < lo %}
        switch.turn_off
      {% else %}
        switch.turn_{{states('switch.steckdose1') | lower}}
      {% endif %}
    entity_id: switch.steckdose1
5 Likes