Hello, and thanks in advance for any pointers that might help me accomplish what I’m trying to do - forgive the long-winded description also.
I’m running HASSIO and have a variety of sensors around the place measuring temp, humidity and controlling my oil boiler. All running via ESP32’s on ESPHome.
However, trying to automate the operation of a bathroom fan, based on humidity levels - this has not worked out too well as during the winter here and with relative humidity levels, setting a fixed upper and lower humidity level to trigger the fan is not working. Today humidity might start at 85% but be 60% by evening when heating kicks in.
What I really want to do is trigger the fan when a humidity spike is registered, and then run the fan, say for 30mins - don’t necesarily worry about what the end humidity level is, then start the process again.
Ideally I’d do this directly on the ESPHome device so that the fan would run autonomously and only report status and values to HA, but when I tried to use the -platform: trends in ESPHome I realised this was only applicable to HomeAssistant, and I have yet to use the automations aspect of HA - my setup is quite static.
I begin looking at the trends option and have started writing the code to catch a sudden increase in humidity, but am now confused as to what to do with this value once I have captured it - do I create an automation in automations.yaml (and if so how), or do I try to use a Lambda in ESPHome.
Furthermore, in either of these instances, how does the system deal with the potential of the fan being on already, or how does the time delay work if a subsequent trigger is received while the previous countdown is operating.
here is my current ESPHome Fan Controller code, with the fixed humidity control values commented out: -
sensor:
- platform: dht
pin: GPIO14
model: SI7021
temperature:
name: "Bathroom Temperature"
humidity:
name: "Bathroom Humidity"
# on_value_range:
# - above: 85.0
# then:
# - switch.turn_on: relay
# - below: 83.0
# then:
# - switch.turn_off: relay
# filters:
# - lambda: return x * 1;
# - sliding_window_moving_average:
# window_size: 1
# send_every: 1
# update_interval: 10s
binary_sensor:
- platform: template
name: "Fan Status"
lambda: !lambda |-
if (id(relay).state) {
return true;
} else {
return false;
}
This is my attempt at creating a trend monitor in configuration.yaml
binary_sensor:
# Tracks 20 humidity readings over 1 minute. If the change is greater than 3%, evals to true. (3/(60*))
- platform: trend
sensors:
bathroom_high_humidity:
max_samples: 20
entity_id: sensor.bathroom_humidity
sample_duration: 60
min_gradient: 0.05
Any assistance that can be provided I would be most grateful - or opinions on the best way to achieve what I’m trying to do.
Thank you in advance.
Ger