Looking for help with an automation

Hi there.

I have two Zigbee switches in my bathroom. One controls the overhead light, the other controls the fan. I also have a Zigbee temperature/humidity sensor in the bathroom. I’m trying to automate the fan shutting off after the humidity drops after taking a shower.

I’ve set up an automation that turns the fan on when the light comes on, but I would like to have the fan stay on until the humidity level drops to the initial level.

Trouble is, beyond a simple automation like “if this, do that” I’m kind of at a loss on where to start with composing my own automations. Any help would be greatly appreciated.

You should post the existing automation you have now (properly formatted).

it helps others to visualize where you are starting from

What I would do is in your automation, after you have switch the light on, you save the humidity from the Zigbee sensor into a input_number entity…
Then you create another automation with two triggers: the light has just been switched off and the actual humidity is below or equal (I would add a few percentage because just being equal to the same degree of humidity can take a long time, let’s say 5% that you can decide to adjust) to the humidity stored in the input_number entity. The condition is to avoid to have your fan running for ever if the humidity has not increased after you switched on the light… So the fan will stop when you switch off the light if the humidity is OK at that time…

trigger:
   - the ligth is switched off 
   - the actual humidity is below or equal to (the input_number entity + 5)
condition:
   - the actual humidity is below or equal to (the input_number entity + 5)
action:
   - you switch off the fan

But having the name of the entities would definitely help to build the code…