I’ve seen a few automations with this functionality, but they are all missing one crucial part that I need, the ability to manually turn the fan on, then off after x minutes.
I’m in the process of migrating from SmartThings thanks to Samsung bricking my 2013 hub. I’ve got all my automation recreated except this one. The fan in question is in the bathroom. The reason I created this automation in the first place was because I started to have moisture problems when I forgot to turn on the fan for a shower. But the fan is also useful for those not-so-humid-smelly times. So in Smarthings I created a smart app to start/stop by humidity, but also if the switch is pressed manually, to turn off after x minutes. I could do this because I could save the time it was manually started and turn off at the appropriate time. I haven’t been able to find an equivalent (there is some scene saving, but I couldn’t find a custom time saving). So now I’m trying to figure out something that will work similarly.
The best approach I’ve thought of so far is 2 different automations.
Triggers when humidity > {x}, start the fan
Single/Repeat mode, Triggers when humidity < {x} or when Fan turns on, then delays {y} minutes, then turns off fan.
This will make it so the fan continues to run after reaching desired humidity, but at least I get closer. I’m torn on Single vs Repeat. Repeat because if the fan is manually turned off, then back on, it should honor the new delay time. But that has the problem of every time the humidity changes the delay gets reset. Single so as to not reset the delay, but if the fan is manually turned off then back on, the original delay is still going and will be used.
I feel like there is probably some simpler way of automating this that I am missing. Can I get some suggestions?
You can make use of the wait_for_trigger define a time-out and it will wait until the humudidy has dropped, or the timeout has passed. Something like this:
I’m not sure if this should be a different thread, but I don’t want to spam the channel, so I’ll just ask here first.
This solution is working, I now want to make this into a blueprint. I get a warning that I suspect that something is wrong with the yaml, but I’m not seeing it.
blueprint:
name: Humidity Fan/Timer
description: Turn on fan in high humidity, turn off after x minutes or after humidity drops
domain: automation
input:
humidity_sensor:
name: Humidty Sensor
selector:
entity:
device_class: humidity
fan_switch:
name: Fan Switch
selector:
entity:
domain: switch
trigger:
- platform: device
type: turned_on
entity_id: !input fan_switch
- platform: numeric_state
entity_id: !input humidity_sensor
above: '60'
condition: []
action:
- type: turn_on
entity_id: !input fan_switch
- wait_for_trigger:
- platform: numeric_state
entity_id: !input humidity_sensor
below: '60'
timeout: 0:20
- type: turn_off
entity_id: !input fan_switch
mode: single
Error is:
Logger: homeassistant.components.automation
Source: components/automation/__init__.py:626
Integration: Automation (documentation, issues)
First occurred: April 25, 2021, 8:53:56 PM (8 occurrences)
Last logged: 5:04:25 PM
Blueprint Humidity Fan/Timer generated invalid automation with inputs OrderedDict([('humidity_sensor', 'sensor.basement_bathroom_sensor_humidity'), ('fan_switch', 'switch.basement_bathroom_fan_switch')]): extra keys not allowed @ data['action'][0]['type']. Got None
Blueprint Humidity Fan generated invalid automation with inputs {}: extra keys not allowed @ data['action'][2]['domain']. Got None extra keys not allowed @ data['action'][2]['type']. Got None