How do I control bathroom fan run time with existing smart switches?

Hi all…
I’m a relative noob with all this so please bear with me :).

In my bathroom, I have a light and a fan, both controlled by z-wave switches. Currently, I have an automation that turns the fan off 30 minutes after the light is turned off. The idea is to ventilate bathroom after someone finishes a shower. This works fine. However, I would like to have something slightly trickier that allows some control over the fan run time. For example, maybe 30 mins after a shower but only 10 mins after someone uses the toilet.

Is there any way to use presses of the switches to signal which fan run time to use? For example, is there some way to tell that the switch “on” position was pressed while the device state was already on? Or, would I need to use the state changes of the devices to do the signaling? I’m guessing it’s the latter, but I wanted to make sure I wasn’t missing something.
Honestly, I don’t think anyone in the house (except perhaps me and maybe not even me :slight_smile: ) would be willing to toggle the light switch on and off to control what the fan does.

The other approach I’ve considered is to include a humidity or temperature measurement. I suppose it would go something like this:
-fan and light on with ambient humidity/temp, run fan for 10 mins after light is off
-fan and light on with elevated humidity/temp, run fan for 30 mins after light is off

I’ve read a lot about humidity sensors and using them here. It seems like a PITA :).

Not too much in my experience. Of course my experience may not carry over, but I just used ESPHome with a DHT22, and it was not a lot of work at all.

Ok, I just bought an ESP32 NodeMCU and the DHT22. I’ll play with it some and see how it goes. I wouldn’t mind getting some ideas for controlling the fan that don’t require humidity sensing, but I’m also curious to mess with new stuff :slight_smile:
And yes, I’m pretty sure the ESP32 is way overkill but I have other things I might want to build so I sprung for the more powerful CPU.

I know you were looking for different solutions but I have the following Trend Binary Sensor that reliably detects when a shower is being used based on a cheap Zigbee temperature/humidity sensor (this could easily be substituted by your NodeMCU). You might be able to migrate the YAML to ESPHome or else leave it in HA and just read the humidity value from the ESP32:

- platform: trend
  sensors:
    ensuite_shower_occupancy:
      entity_id: sensor.ensuite_humidity
      device_class: moisture
      max_samples: 10
      sample_duration: 300
      min_gradient: 0.01667

Alternatively you could use a battery powered Zwave or Zigbee remote where the different buttons (or key presses like short-press, double-press, long-press etc.) signal to HA how long you want the fan to run for.

I use a double switch in my bathroom to controll the light and a fan. Besides that, I use a humidity sensor. Because humidity is relative, I use a hygrostat custom control: https://github.com/avdeevsv91/ha_generic_hygrostat
Works like a charm!

Thanks. I’m warming up to the idea of using humidity :slight_smile: