🚿 Bathroom Humidity Exhaust Fan

Bathroom Dimmer turned off triggered by automation Bathroom Humidity Exhaust Fan triggered by numeric state of Bathroom De-Humifier

Not sure why the light was turned off. I don’t see where I set it to do that? Is this not configurable? Thanks.


Hi Richard

Could you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on “</>” and paste code in there.

Then I will be able to see what is happening with your automation.

Blacky :smiley:

New update 1.7

Bugs Fixes :bug:

  • Fixed an error in light transition as shown below. This was probably when you are using zigbee2mqtt.
Transition value 0 is not valid.

If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:


Blacky :grinning:

Hi @Blacky,

First of all what a good Blueprint just what I was looking for. Until yesterday my extractor fan was controlled by my plc, because a remote IO station has broken (which has a long delivery time), I came across this Blueprint which does almost exactly the same as what I programmed in the plc. Only when I took a shower this morning did I notice that the fan wouldn’t come on and I turned it on manually to check the logs later. Now I suspect I did something wrong somewhere because I get the following error every time the automation is triggered.

Error log:

Logger: homeassistant.components.automation.hvac_bathroom_humidity_exhaust_fan
Source: components/automation/__init__.py:608
Integration: Automation (documentation, issues)
First occurred: 11:06:59 (6 occurrences)
Last logged: 12:20:26
Error rendering variables: UndefinedError: 'dict object' has no attribute 'entity_id'

Config in :point_right: /config/automations.yaml:

- id: '1692464664570'
  alias: 'HVAC: Bathroom Humidity Exhaust Fan'
  description: ''
    path: Blackshome/bathroom-humidity-exhaust-fan.yaml
      trigger: sensor.bathroom_humidity_derivative
        - fan.fan_bathroom_on_off
      bathroom_humidity_sensor: sensor.temperature_and_humidity_sensor_bathroom_humidity
      time_delay: 15
      include_max_humidity: maximum_humidity_disabled
      time_out: 45
      falling_humidity: -1

I must have done something stupid but I can’t see it at the moment :sweat_smile:

@Hert [quote=“Hert, post:184, topic:509992”]
First of all what a good Blueprint just what I was looking for

No problem, your welcome.

Thanks for letting me know and providing all the information I needed :+1:. Not your fault, I did something stupid :sweat_smile:

Fixed it please update to Version 1.8

It had to do with not entering a light entity. Sorry for the brain fart.

Blacky :smiley:

New update 1.8

Bugs Fixes :bug:

  • Fixed an error in light if nothing was selected. It would prevent the automation from running and throw the below error.
Error rendering variables: UndefinedError: 'dict object' has no attribute 'entity_id'

If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:


Blacky :grinning:


Yes this has solved the problem and I have tested it a few times and everything works properly. This is great now I don’t have to make anything myself to control my fan and you have thought of a lot of things I saw when I was browsing your code. Good job.

But I have one question:
While browsing through your code I saw some nice places here and there to add a function to adjust the fan speed. My fan can run at 2 speeds (high and low). What I would like to see is if the function “Turn on the fan” is called and before “Check if the lights are enabled” there is an option to set the low/high bit high, and then after “Wait until Humidity Derivative Sensor drops or it times out” to set the bit low again. So basically when the timer runs “Wait the number of minutes that has been set for the time delay” the fan then runs at low speed, and then of course after this time the fan simply turns off.

I actually programmed almost exactly the same in my PLC as you did here in this blueprint, only this is the difference with what I made.

Also, the humidity had to be close again before I started showering (I took a snapshot of the value 10 min before I started showering and it also had to have dropped within a certain window, I don’t know the percentage value now) otherwise the timer restarted and repeated a maximum of 3x. I do not attach much value to the latter because you have the option to set a maximum humidity and a time out value can be entered.

But don’t get me wrong this is not an accusation or that I see it as a shortcoming. The blueprint is awesome in itself, just thought before I start experimenting with your blueprint I’ll drop the idea here :sweat_smile:


Thanks for the update, nice to know it working again :+1:

I am working on this blueprint so I will consider your suggestion but it will be some weeks before I release the next new features. I to have a 2 speed fan but only use one speed. Maybe check in again next month.

Blacky :smiley:


Oh see that’s good news. I don’t really care that it will take a while, I’m going to test the values of the humidity (decreasing and rising value) first, then I will be a week further haha. I’ve already changed your blueprint to what I said in my previous post.

What did I do:
I actually copied your include_fan_speed_off and fan_speed literally and called it “speed_switch”

After this I put a choose for the “fan_on” function if an entity is selected for speed switch then it will execute otherwise not

And for switching to the Timer I did the same, only of course with homeassistant.turn_off

I didn’t make this neatly, I looked that I can get it made in the easiest possible way in my situation. Your other flow “For winter mode when enabled and within the set winter months” I have not changed. For now I have more than enough with this and I am still experimenting with the settings. I’ll keep an eye out for your updates, I’m curious about your upcoming implementations


1 Like

I have a request about time delay, ATM TimeDelay starts when the -level is reached ie -1, but if the level drops again after say 5 mins the timer is not reset, so, once the timer end the fan turns off, so it can cause the room humidity to start going up as it has not really had time to level out.

So could you code it so it resets the timer or add an option to reset it if falls below the point where the Delay Timer started.

see attached.

The delay Time started at Orange arrow, but the derivative was still dropping (Pink and Blue), the Delay Time out ended and fan turn off at Green Arrow, which cause the the room humidity to raise again and eventually start the fan again once it reached the derivative high point (Yellow arrow). Restarting the timer each time the derivative goes lower than the set point would help stop this.


Hi Andy,

At what point did you stop having a shower?

I know you would of read the settings guide Click Here.

If the humidity rises again it is a balancing act to get all your settings correct. I have mine so when the fan goes OFF the humidity will rise but not enough for the fan to come back ON. Then the humidity fall again. Good to also add your humidity sensor in your chart as it can help to understand what is happening and if you should run the fan longer. Here are my settings if your interested.



Blacky :smiley:


I saw this happening to me today too and I think it’s kind of the same problem. Only I think jumping back is not that simple, maybe a timer for the trigger would help a lot and in my opinion it is not that difficult to implement.

Could you please take a look (this is the place in my case) on line 1708 here you call the function “Wait until Humidity Derivative Sensor drops or it times out”. If you add a “for x time condition” to this with a variable input, don’t you think we can dampen this out.

Here’s my graph:

On the red line is where he passed over to the timer

Got out of show about 19:37, here the graph with humidity sensor.


Looks like your sensor location is ok. Try lowering your “Falling Humidity”. Then you may be able to adjust your “Time Delay”. It is a bit of a “Love Affair” and it could take 20 showers to get it right, but once you do it works well. I have tried this but found getting the setting right stops the automation always going to the “Safe Guard - Maximum Run Time”.



Hi Andy :smiley:

Now we can see what is happening, … having your settings would be nice but no stress, let’s have a look at it. Below I have added a few things in the hope it will be more clear.

At point “A”. The red arrow (1.7 - 1.9) looks to be your “Rising Humidity”. Consider raising it to the yellow arrow (3.0). Because it is now 3.0 the point “B” (fan ON again) may not accrue (try it, see, adjust, try it see, adjust, etc). The red line is where you finished your shower. Point “1” (green arrow) should be your “Falling Humidity” around -2.0. Looks like your “Time Delay” is around 15 min so if we take orange line to the green line it is around 20 min but we have a stop / start of the fan so 15 min may be ok. First try and set your “Time Delay” to 25 min then look at the graph again to fine tune your run time as 25 min is way to long but we will be able to see what is happening. Then it is fine tuning, again, again and again of all your settings.

Sensor, sensor set up and sensor location is the main critical factor because that is the information we need to make it work perfectly. Having it inline with your fan inlet will stop all your problems (air flowing over it when the fan is ON). I also have my humidity sensor report every 60 seconds regardless. The data is not a problem it is the key and all this data gets purged in 10 days. In the past I had other sensors but once I set it up like this “BOOM” perfect.

As I said in the above post, It is a bit of a “Love Affair” and it could take 20 showers to get it right, but once you do, it works well. This is why winter and summers is realy nice feature as you can see by my settings it is so different and even 0.1 makes a difference.

Blacky :smiley:

thanks for taking the time, i’ll try to tweak i did have 25mins for delay, now reduce this to 10 mins, and raised the detect point to 3 (was 1) hopefully this will stop the re-actioning. thanks let thw fun begin tweaking.

Thanks Andy, thanks for persisting at it, this is one blueprint I realy love (Game Changer to home automation) and my family love it to. If you have any question I here to help.

1 Like


Yes, you are right, I actually have too little data. Anyway, I work with your original blueprint, I want to get the settings right first. I’ve set the falling humidity to -2, I’ve seen in history that it always falls below that.

But you are absolutely right when it comes to adjusting control loops, I myself work during the day as an Industrial Software Engineer and I program PLCs, Robots, safety systems and motion systems and I also regularly have to adjust control loops haha.

By the way, I’m curious how the transition from high speed to low speed will react, you can see exactly when the fan is switched on in the graph. It may then be too humid in the bathroom to switch to low speed. I remember when I made the function block in the PLC that there was something wrong with this and that is why I first wait until the falling humidity falls below an x value (now -2 in your blueprint for me) and then for x (I think 3 min) time the falling humidity in a window of 0.1 <> -0.1 and then the timer will be started and the fan will run at low speed. I also had a timeout, but I also looked at the absolute value of the humidity, otherwise it falls into timeout very often. But I think this is all getting way too hard and what you’ve made is more than enough (if you’ve implemented the 2 speed control, of course, just kidding). But I made all this 8 years ago or so and I borrowed some of the code from a project from a lab where they genetically manipulate plants (vegetables), here we made a fully automated system to simulate a certain climate and humidity was one.

But again, good Automation here we are also happy with it and what I write above are certainly not criticisms just wanted to share my experiences maybe this will help you, if not then see it as if I didn’t say anything


I have gone down a lot of rabbit holes, an so far this blueprint works.

Not to say we can’t make it better.

Haha, yeah, I noticed that too! While I was browsing through your code, it was clear that you’ve really thought things through. I totally understand where you’re coming from. When I was working on programming this in the PLC 8 years ago, I found myself going down the rabbit hole multiple times too. Your contribution here is awesome, and it’s a relief knowing I won’t have to tackle it all over again – thanks for saving me that “round two” experience :grinning_face_with_smiling_eyes:

Software is rarely a closed book; I’ve never encountered a completely flawless software package. Last year, I had to make a modification to a machine that I programmed a decade ago. When I looked at it, I thought, “What was I thinking back then?” But that’s the beauty of it – you can arrive at solutions in different ways, and you often gain new insights, aside from the physical changes, of course.

By the way,

  • So, I took a shower today and guess what? The fan decided to stick around for a good while after I tweaked the ‘humidity drop’ to -2. It happily hummed along for about 30 minutes this time. I must say, it wouldn’t hurt to have it running at low speed for another 30 minutes or so afterward. But hey, it’s working like a charm to run the fan on high speed. I’d probably dial down the high speed time a bit if I were to let it run at low speed afterward. The sweet part is, when it’s on low speed, it’s practically a ninja – no noise whatsoever. Super handy for those evening showers when someone’s already in bed.

  • I was thinking, what if I use the “Fan Speed - Switch Off” option to not actually turn off the fan, but instead start a script that lets the fan run at a low speed for x amount of time? Or maybe a switch helper that triggers the script and only resets after the script completes. Just an idea!