Hi
Still learning homeassistant
can someone help me or guide how to make a automation that does:
Turn on light and fan when there is motion in bathroom and turn off light and after 120sec and fan after 360sec with no motion. but if the humdity is above 60% then dont turn off fan until humidity is under 60%.?
I have now changed it so the fan only starts when humidity level is XX% and not with the lights, no need for the fan to turn on everytime someone is in the bathroom and not using the shower. it also saves med som $ on the electical bill but thanks for the help
Depending on the actual use case, I prefer to use timers for this rather than simply triggering off directly and turning it off after its been on for ‘x’ minutes. You can create a helper timer and then start the timer each time there is motion (or other trigger) and then the light won’t go out on you till ‘x’ minutes after the last motion was detected. Otherwise this will likely be turning off while you’re brushing your teeth. The humidity sensor will help keep it on better but i’m guessing it will still happen.
(and formatting your post here so people can actually read the code will be helpful)
Now i have the lights turn on with motion, and if no motion is detectec in 180 seconds, the light turns off. And new automation for the fan/ventilator so it only turns on when humitidy level is above 55%. it works great now.
Love @123’s solution here. FWIW. I added a statistics average sensor to calc the average humidity over the last 24 hours and use this instead of hard-coding the above/below numeric values. Allows for seasonality / rainy days etc. I also use a threshold above the average, so when humidity > (average + threshold ) the fan turns on and then back off when it’s back below the (threshold + buffer).
I created a binary_sensor that triggers my fan toggle automation:
master_bath_fan_sb:
friendly_name: Master Fan S/B Status
value_template: >-
{% set humid = states('sensor.master_bathroom_sensor_relative_humidity_measurement')|int(default=0) %}
{% set avg = states('sensor.master_bathroom_humidity_average')|int(default=0) %}
{% set thresh = states('input_number.master_bath_humidity_threshold')|int(default=0) %}
{% if states('climate.6900_master') == 'cool' and avg > 49 %}
{% set thresh = thresh / 2 %}
{% endif %}
{{ (humid - avg) > thresh }}
I use an input_number to more easily save / update the threshold and also of not that if my AC is on, then I leave the fan on a little longer to take more humidity out before turning off.