Automation based on humidity changes (one overides the other one..)

Hi folks, I have a bathroom fan (entity: switch.guest_bathroom_fan_switch) that kicks in when the humidity (entity: sensor.shower_humidity) reaches 80%. The humidity can go as high as 92% when I take a shower. I want to create another automation that turns off the fan when the humidity dropes back down under 87% but the problem is that the fan kicks back in even if the humidity is under 87% because the condition that checks if the humidity is above 80% engages! How could I remedy this? Thanks a bunch!

Post the current Automation… it sounds like you might be using the wrong trigger type.

Hi Drew,
One does this (turn on fan):

alias: When Guest Bathroom Humidity Reaches a Certain Level
platform: numeric_state
entity_id:

  • sensor.shower_humidity
    above: 80

The other one turns it off:

alias: Turn Off Guest Bathroom Fan When Humidity Goes Down To A Certain Level
platform: numeric_state
entity_id:

  • sensor.shower_humidity
    below: 87

Please format it properly:

You didn’t post any conditions. Please post the complete automation for both if you mean condition:.

You’re right in what you say: provided the sensor changes smoothly it shoudl do what you want if there is no other code you haven’t included. Can you post a state graph for the humidity sensor? If that is “noisy” you might have problems that you could fix with a “for: "00:01:00"” or similar.

That can get a bit tricky to do, you might need to create a helper entity that records the humidity level when it turns on, that way you use that helper entity for the threshold on the next trigger.

I.e.,:

  • Create the number helper set to 80 (and I would also create automation that resets it back to 80 daily at some point)
  • Your automation compares the current humidity to the threshold set in the helper, in this case 80%, and kicks on
  • On the next trigger you check if the humidity has increased and the fan is on, i.e., getting up to 93% as you shower, and you update the threshold helper to the current value of 93%
  • Your automation monitors the threshold and when it goes below 80 it resets to 80 again and turns off the fan

That’s just a spitball idea, but one nonetheless.

You could also use a differential helper on the humidity if it’s +ve at a decent amount then you are showering, if it starts to go -ve (shower is off and humidity begins to drop) when it levels out to a small amount you can turn off the fan. That way the actual humidity level isn’t required.

1 Like

Hi @Troon, thanks for the constructive feedback. I’m very new to all of this and I’m not at all a programmer. For the moment I do not have any conditions. Maybe that’s what I’m missing. My first automation has this in the ‘‘When’’ with no conditions. Then the action is to turn on the fan and that works fine.

alias: When Guest Bathroom Humidity Reaches a Certain Level
platform: numeric_state
entity_id:

  • sensor.shower_humidity
    above: 80

My second automation basicaly turns off the fan when humidity is under a specific threshold and looks like this ‘‘When’’ with no condition:

alias: Turn Off Guest Bathroom Fan When Humidity Goes Down To A Certain Level
platform: numeric_state
entity_id:

  • sensor.shower_humidity
    below: 87

Please help me out in explaining to me how I should format future questions or do let me know if this forum is not to help out with building proper automations within Home Assistant. Like I said, tiis is all new to me (HA, HA community…)

Thanks!

Great idea! Thanks for the feedback.

Read the linked topic about how to properly post code. Specifically item 11, that is what the issue is. You need to encapsulate your code between two sets of three tick marks so it formats properly (usually the same key as tilde, under escape).

I.e.,

This is my properly formatted code string

Ok, thanks!

Thanks again @Neil_Brownlee. Using the derivite helper, I was able to accomplish in a much better way what I was originaly trying to achieve!

2 Likes