Automation - Bathroom (Humidit

Hi there,
I have a bathroom setup that I need some help with
The setup is as follows:Bathroom.yaml (1.1 KB)

  • Bathroom Extractor Fan ( Connected via ESPBathroom )
  • ESPBathroom also has a DHT22 for Temp and Humidity readings
  • Door Sensor
    (ESPBathroom is a Sonoff)

I’d like to setup an automation that can turn the Extractor Fan on when the door is closed and turn it off when the door is open depending on the status of the humidity of the DHT22
If the door is open and the humidity is above a specified threshold then the Extractor Fan must be on.
If the door is open and the humidity is below a specified threshold then the Extractor Fan must be off.
If the door is closed the Extractor fan must be on

The humidity sensor values vary depending on the weather, so it’s rather fickle
Which sensor should I be using to dynamically adapt to humidity during weather fluctuations?
Is the approach I’m using reliable or should I maybe take another into consideration?
I’d like to use the least amount of automations to achieve the desired results, how many am I looking at?

Attached is the config I’m running, which doesn’t take the door sensor into the equation. The uncommented automation for the Door Open/Close turn Fan On/Off gave mixed results when all were enabled

I’m doing something similar in my bathroom as well with a setup not that different to yours. The DHT22 is definitely a good choice for it’s accuracy in readings.

The question I would have is do you really need to incorporate the status of the door into the automations or would it be easier to simply just have the fan go on if the humidity was above your threshold and go off it it was below a threshold. If the door happens to be open then the fan would probably be on less time and conversely if the door is closed the fan will be on more time to bring the humidity back down. Either way the purpose is to have the fan come on and stay on til the humidity gets below a level.

I think the physical placement of the DHT22 would be the most important part of making it all work as efficiently as possible.

for humidity you would need another sensor outside the bathroom to give the normal readings. the difference in humidity would be the threshold

- id: Guest_Bathroom_Humidity_High
  alias: Guest Bathroom Humidity High
  trigger:
  - platform: numeric_state
    entity_id: sensor.guest_bathroom_humidity
    value_template: '{{ sensor.guest_bathroom_humidity - sensor.house_humidity }}'
    above: 10
action:
 - service: homeassistant.turn_on
   entity_id: switch.guest_bathroom_fan

- id: Guest_Bathroom_Humidity_Normal
  alias: Guest Bathroom Humidity Normal
  trigger:
  - platform: numeric_state
    entity_id: sensor.guest_bathroom_humidity
    value_template: '{{ sensor.guest_bathroom_humidity - sensor.house_humidity }}'
    below: 5
  action:
  - service: homeassistant.turn_off
    entity_id: switch.guest_bathroom_fan

you would need another humidity sensor called sensor.house_humidity
I know you need a value template to take two comparitors and use the difference as your trigger.

6 Likes

Hi Guys,

Thanks alot for the responses!
@jonathanp I’d need to incorporate the status of the door as when someone uses the loo, humidity may not go up enough to cause the fan to turn on :smile:
Any ideas how to implement?

@HickHackerz That sounds really good. Would the mold indicator ( https://home-assistant.io/components/sensor.mold_indicator/ ) also be an option as a sensor?
It’ll take a while just to get some trend analysis to find the sweet spot to trigger the fan.

That setup needs 2 temp sensors, one outdoors and other indoors as well as a humidity sensor. That is exactly what the bathroom fan setup is supposed to do, with a humidity sensor in the bathroom vs rest of the house.

I’m not sure the door sensor really has a place in this automation, humidity is same door open or closed. Now air pollutants or smell is a different story, just have the fan run while door is closed…:stuck_out_tongue_closed_eyes:

Ok cool,

Agreed, but how would I run the fan when the door is closed when incorporating it into the automation or would that be a separate one?

I have this exact same setup except using the Aeotec sensor, and the outside humidity sensor being my Ecobee that is right outside the bathroom door. Since I also have a motion sensor and disable it when the door is closed to prevent the “wave arms in the air on the toilet” scenario, it took me 4 automations.

I’d be interested in how to make use of the mold sensor for the bathroom. Do you use outdoor temperature from outside the house or from the rest of the house when calculating bathroom mold indicator?

alias: "Bathroom Humidity High"
trigger:
  platform: numeric_state
  entity_id: sensor.bathroom_motion_relative_humidity
  above: 70
action:
  - service: switch.turn_on
    entity_id: switch.bathroom_fan_switch
  - service: input_boolean.turn_on
    entity_id: input_boolean.humidity_purge
  - service: automation.turn_off
    entity_id: automation.bathroom_motion_sensor_off

alias: "Bathroom Humidity Low"
trigger:
  - platform: numeric_state
    entity_id: sensor.bathroom_motion_relative_humidity
    below: 66
  - platform: template
    value_template: "{{ states.sensor.bathroom_motion_relative_humidity.state | float - states.climate.ecobee.attributes.actual_humidity | float < 9 }}"
condition:
  condition: and
  conditions:
    - condition: state
      entity_id: input_boolean.humidity_purge
      state: "on"
    - condition: state
      entity_id: binary_sensor.bathroom_door_sensor
      state: "on"
action:
  - service: input_boolean.turn_off
    entity_id: input_boolean.humidity_purge
  - service: switch.turn_off
    entity_id: switch.bathroom_sink_switch
  - service: switch.turn_off
    entity_id: switch.bathroom_fan_switch
  - service: automation.turn_on
    entity_id: automation.bathroom_motion_sensor_off

alias: "Open Bathroom Door With Humidity"
trigger:
  platform: state
  entity_id: binary_sensor.bathroom_door_sensor
  to: "on"
condition:
  condition: state
  entity_id: input_boolean.humidity_purge
  state: "on"
action:
  - service: automation.turn_on
    entity_id: automation.bathroom_humidity_low

alias: "Open Bathroom Door No Humidity"
trigger:
  platform: state
  entity_id: binary_sensor.bathroom_door_sensor
  to: "on"
condition:
  condition: state
  entity_id: input_boolean.humidity_purge
  state: "off"
action:
  - service: automation.turn_on
    entity_id: automation.bathroom_motion_sensor_off
  - service: automation.turn_on
    entity_id: automation.bathroom_humidity_low
2 Likes

Geez, ok cool, I see where you’re going with your setup. Pretty interesting…
Its gonna take some time to get some stats on the mold indicator, but yes, I’m currently using the outdoor temp as a variable.
Look, the gist of the whole automation is to be able to do the following:

  1. When the door is Open the Fan needs to be On; however;
    a) If the Humidity is above a threshold, the Fan needs to be stay On
    b) If the Humidity is below a threshold, the Fan needs to be Off
  2. Close the Door and the Fan turns On (Regardless of Humidity)

How one achieves the sweet spot wrt humidity is dependant on what devices you have and as @HickHackerz said, some math and trend analysis would be needed.
I’d just like to know if one should be using 4 automations to achieve the above, or if one could just use 2 or possibly one.
To me the whole trigger, condition, action logic is a bit bizarre and I’d like to kill 4 or maybe 2 birds with one stone

1 Like

think of the automations as switches. Would you have 2 automations, one for humidity concerns and the other for normal bathroom duties?

Makes it easy to see what automation is running and what is not.

Aah ok!
So in your case you’d have 4?

  1. Door Open
  2. Door Closed
  3. Humidity High
  4. Humidity Normal

Just worried that they may conflict…

I actually have 6 because I also have motion on, motion off. And there were conflicts, which is why when you look at my automations posted above, I have the automations disabling other automations.

Top priority is the door. If the door is closed, I never, under any circumstances want the light to turn off. So when door closed automation triggers, it disables no_motion and humidity_low. It enables them when the door is open. No_motion would then turn the light off as normal, which has the added bonus of giving a 3 minute odor purge.

Next is humidity. If the humidity is high, disable no_motion. If it is low, enable no_motion.

And last priority is the motion sensor which doesn’t disable anything.

These methods were developed over 6 months of regular use and finding scenarios when the light would turn off when I didn’t want it to turn off.

Just a small remark from my experience. I have 4 * DHT22, they definitely are accurate, but after(about) 1 year the humidity sensors got stuck on 1%. On all of them. Temp is working fine. So for sure I won’t rely on them in the future.

Hi all, thanks for the replies!
@bogdan Noted man, I’ll keep an eye on them

@cexshun Yeah, it seems like quite a mission! Surely the automation logic needs to be looked at again, especially when taking multiple variables into consideration. I mean, what you have to do to get the desired effect is ridiculous!
Unless we’re just doing it wrong :wink: