I currently have a bathroom fan automation that will turn the fan on if the delta between the bathroom humidity and house humidity is over a certain %. I have a 2nd one for turning the fan off when the humidity falls below the threshold.
Recently I added a condition to them as the threshold % will be different if the AC is on vs. heat vs. nothing on.
I would like to ultimately see if I can bundle this into 1 automation with all the new enhancements of late, but I am need some expertise.
- id: '1595463904722'
alias: Master Bathroom - Humidity High (AC)
description: Only trigger if AC is running
trigger:
- above: '7'
entity_id: sensor.mb_humidity_59
platform: numeric_state
value_template: '{{ state.state|float - states(''sensor.main_floor_humidity'')|float
}}'
condition:
- condition: state
entity_id: climate.main_floor
state: cool
action:
- data: {}
entity_id: switch.master_fan_107
service: switch.turn_on
mode: single
- id: '1595464068059'
alias: Master Bathroom - Humidity Normal (AC)
description: ''
trigger:
- below: '7'
entity_id: sensor.mb_humidity_59
platform: numeric_state
value_template: '{{ state.state|float - states(''sensor.main_floor_humidity'')|float
}}'
condition:
- condition: state
entity_id: climate.main_floor
state: cool
action:
- data: {}
entity_id: switch.master_fan_107
service: switch.turn_off
mode: single
Any suggestions for
How to combine into a single automation
Is there way to have the trigger basically say
if heating is on, or system is off AND delta > 15%, turn on fan.
If AC is ON AND Delta > 7% turn on fan.
If either of those 2 cases is true and Delta % drops back below thresholds, turn back off fan
I think with the 0.115 release, you can do all of that. Just to spitball some ideas:
You can trigger the automation with each
above 7%
above 15%
below 7%
below 15%
Then use a template to call either switch.turn_on or switch.turn_off using both logic and conditions
If HD (humidity delta) < 7 -> call switch.turn_off
Else if HD > 7 and cooling on -> call switch.turn_on
Else if HD < 15 and (AC off or heating on) -> call switch.turn_off
Else if HD > 15 -> call switch.turn_on
This logic can probably be streamlined in the template. To make this somewhat easier and more readable, you could save the humidity delta as a variable in the automation.
@Dan_W I was able to get the automation setup (minor issue at end… endif fixed it). It doesn’t appear though to be working though in terms of triggers. I removed the ‘ around the above/below pieces in triggers as VS Code flagged that, but not sure if that is making any difference or not.
I got around to testing it and (besides the endif and data structure typos) I was able to get it working. However, I wasn’t able to use the variables in the trigger value templates. This should work, even if it isn’t the cleanest:
Found out from Paulus that variables are NOT supported for Triggers, so that is answers one of the questions.
I am seeing some issues with the automation code where it is NOT turning off the fan when the humidity drops back down. I believe it is only occurring when Heat/Off states.
Any ideas? I looked over the code and seems like the nesting is correct.
You are welcome! It was fun learning how (and how not) to use the variables.
As for your issue, I’m not sure. Can you tell if the automation is being triggered and the switch isn’t turning off or if the automation just isn’t being triggered as humidity drops below the threshold?