Jump to content

Bathroom Fan Timer with Shower Light Trigger


geogecko

Recommended Posts

Posted

I purchased a Togglelinc relay to control our master bathroom fan a little while back, to add to the other two lights in our bathroom that are controlled by Togglelinc dimmers. I had kind of a clunky way of doing a bathroom fan timer, which was triggered by the one Togglelinc dimmer, assigned to the shower lights...once variables came along in programming, I was able to make it more intuitive, and also more precise in what I wanted it to do.

 

These were my requirements:

* Activate the fan automatically, when the shower light is turned on

* Deactivate the fan automatically, 15 minutes after the shower light is turned off

* If the shower light is turned back on, before the fan goes off, cancel the delay, and do not turn off the fan

 

That last requirement was a little tricky, and the reason for it, is that my wife and I tend to take showers right after each other, on a regular basis, so one of us would get out, turn the light off, and then the other would turn the light back on, get in the shower, and a few minutes into the shower, the fan would turn off. The reason for using the fan in the bathroom is for removing moisture, so obviously this was not ideal. Here are the programs I came up with to accomplish this task. I thought some might find it helpful, if you were trying to do a similar thing.

 

So every minute, the program checks to see if the light has been turned back on, so within a minute of turning off the fan, this should work. If anyone has any corrections, advice, or simplifications, I'm open to suggestions as well.

 

Master Bath Fan Cmd On (Enabled)

If
       Control 'Master Shower Lights' is switched On

Then
       Set Scene 'Master Bath Fan' On
       $MasterBathFanCount_Int Init To 0
       $MasterBathFanCount_Int  = 0

Else
  - No Actions - (To add one, press 'Action')

 

Master Bath Fan Cmd Off (Enabled)

If
       Control 'Master Shower Lights' is switched Off

Then
       Wait  1 minute 
       $MasterBathFanCount_Int += 1
       Run Program 'Master Bath Shower Light Status' (If)

Else
  - No Actions - (To add one, press 'Action')

This program, in combination with [Master Bath Fan Off] (disabled), will delay turning off the fan for
15 minutes, but if the light is turned back on during that time, the program will exit, because of the
[Master Bath Shower Light Status] (disabled) program, and wait for another "off" command.

 

Master Bath Shower Light Status (Disabled)

If
       Status  'Master Shower Lights' is On

Then
       $MasterBathFanCount_Int  = 0

Else
       Run Program 'Master Bath Fan Off' (If)

 

Master Bath Fan Off (Disabled)

If
       $MasterBathFanCount_Int >= 15

Then
       Set Scene 'Master Bath Fan' Off
       $MasterBathFanCount_Int  = 0

Else
       Run Program 'Master Bath Fan Cmd Off' (Then Path)

Posted

I think there may be a simpler way to do that. Tell me if this wouldn't work.

 

Fan turns on with light on program.

If
       Control 'Shower Light' is switched On

Then
       Set 'Shower Fan' On
       Stop Program 'shower fan timer' 

Else
  - No Actions - (To add one, press 'Action')


 

shower fan timer


If
       Control 'shower light' is switched Off

Then
       Wait  15 minutes 
       Set 'shower fan' Off

Else
  - No Actions - (To add one, press 'Action')

Posted

That would not meet requirement #3. The problem is, that if you put a wait statement in there for 15 minutes, it's going to wait 15 minutes before doing anything else. You're stuck in that 15 minute wait loop, until it's over, then your fan is going to go off, no matter if the light was switched back on or not.

 

The issue is this situation:

* Person 1 goes in to take a shower, turns on shower light.

* Fan turns on.

* Person 1 gets done, turns off shower light.

* Fan is now waiting 15 minutes before turning off.

* 10 minutes passes.

* Person 2 goes in to take a shower, turns on shower light.

* Fan is still on from previous activation, with only 5 minutes left remaining.

* Person 2 gets out of the shower (5 minutes passes), and the fan turns off.

 

You have to interrupt the wait loop somehow, and this was the only way I was able to do that, was to check every minute. Unless I'm misunderstanding how everything is interacting together...

 

You are saying it will kill the wait, if the on trigger is met, is this true? I thought the other program would keep running, until complete...

Posted

It is not true that the wait can't be interupted. You can interupt the wait loop by either retriggering the program (run the if clause provided something in the if cluase is false) or you can use the "stop program" clause. I actaully just edited the program and changed it to stop program because it is a little more obvious what it is doing that way, though both ways work the same. So when the person hits the "on" button, the wait program gets killed.

Posted

This issue with wait clauses getting killed is actually a huge topic on the forum. In fact, most people would prefer it the way you had assumed it works. It is very easy to have a wait clause killed by something in your if clause forcing a trigger when you don't want it to. This is one of those less common situations where you actually want the wait to be killed.

Posted

Your programming logic will serve you well, however, when you get into the opposite situation where you want to block a program from being accidentally killed. This has always been the situation requireing work-arounds.

Posted

I have not made a lot of changes to my system in the last few months. All is, generally, working well. Therefore, my programming may have lost a step or two. Would the original requirements not be as simple as:

 

if
status 'shower light' is on
then
set shower fan on
else
wait 15 minutes
set shower fan off

Posted

apostolakisl,

 

That is very interesting. I was not aware of that. I think this is one thing that makes programming so difficult with this thing, is that your standard C/VB/(insert programming language here) logic does not work. The programming used here almost reminds me of hardware (firmware) programming, than a software programming. Even though it would make this program easier, I don't think I like the way it behaves, as you have said... Thanks for being gentle with me, in helping me understand. :)

Posted
I have not made a lot of changes to my system in the last few months. All is, generally, working well. Therefore, my programming may have lost a step or two. Would the original requirements not be as simple as:

 

if
status 'shower light' is on
then
set shower fan on
else
wait 15 minutes
set shower fan off

 

At this point, I'm not sure. I'm still getting my mind around what interrupts a wait loop. In this case, I'm not sure if it would work, because you have to retrigger the if clause somehow...

Posted
I'm still getting my mind around what interrupts a wait loop. In this case, I'm not sure if it would work, because you have to retrigger the if clause somehow...

 

Using the "status" condition, rather than "control", I expect the "if" clause to be triggered at any change in status, whether from off-to-on, or on-to-off (I am assuming your light switch is a relay, rather than dimmer....otherwise, one may have to emply a different type of condition). If the condition is triggered and evaluated as "true", I expect any running "else" clause to cease, and the "then" clause to initiate. If the condition is triggered and evaluated as false, I expect the "else" clause to initiate.

 

It is easy enough to try out. Create the program and observe the program status as you toggle the light from off-to-on, and vice versa.

Posted
I'm still getting my mind around what interrupts a wait loop. In this case, I'm not sure if it would work, because you have to retrigger the if clause somehow...

 

Using the "status" condition, rather than "control", I expect the "if" clause to be triggered at any change in status, whether from off-to-on, or on-to-off (I am assuming your light switch is a relay, rather than dimmer....otherwise, one may have to emply a different type of condition). If the condition is triggered and evaluated as "true", I expect any running "else" clause to cease, and the "then" clause to initiate. If the condition is triggered and evaluated as false, I expect the "else" clause to initiate.

 

It is easy enough to try out. Create the program and observe the program status as you toggle the light from off-to-on, and vice versa.

 

I will for sure give that a try, because that would make a much simpler program...

Posted
I have not made a lot of changes to my system in the last few months. All is, generally, working well. Therefore, my programming may have lost a step or two. Would the original requirements not be as simple as:

 

if
status 'shower light' is on
then
set shower fan on
else
wait 15 minutes
set shower fan off

 

This wouldn't quite satisfy the original intention because it will shut the fan off 15 minutes after the light is turned on, not 15 minutes after it is turned off. The idea was to remove the humidity and you need to keep the fan running for a specific amount of time after the shower is finished (which I assume corresponds to the light being on).

Posted

Geogecko,

 

This comes up over and over again. I didn't get it at first, I don't think anyone does.

 

When a program is executed, it will go down the "then" statements, in order, without interuption, until it hits a "wait" or a "repeat".

 

At this point, the program opens up the "if" clause for evaluation. In the situation of a "wait", while the program is waiting, anything that causes the "if" to evaluate (a trigger) will kill the program and cause it to start over.

 

For example. When you have a "control switch on" in the if section, anytime someone pushes the "on" button, that is a trigger. It doesn't matter if the light is already on or not. If you have a "status on", anything that changes the status of that light is a trigger (the status must change). Once a trigger occurs, the program will proceed through and head into a false or true state and run the then or else clause accordingly. Also, if you have another program force a "run if" that will also be a trigger and the program will stop what it is doing and proceed through from scratch.

 

In the event of a repeat, the program will check for an active trigger in the if section just for a split section, then do the repeat, then check again, and so forth. So the program will keep repeating until it completes the number of repeats designated, or until a trigger event happens.

 

This is useful, but less useful than it would be if the program continued uninterupted to completion. Your situation is actually one of those nice times where this is useful. To block a program from being interupted, you need to create two programs, one contains the if and the second contains the then. The if program runs the then section of the second program. The second program contains nothing in the if section, so it can't get triggered by anything accidentally.

Posted

Ah, wow, that explains it well, thanks for that. I think I'll have to print out a copy of that post for use while programming, so I can remember this behavior. The work around is annoying, but also not that complicated, except for the fact that it requires multiple programs to accomplish.

Posted
This wouldn't quite satisfy the original intention because it will shut the fan off 15 minutes after the light is turned on, not 15 minutes after it is turned off.

 

I am sorry, but I must disagree. The program example I offered would turn the fan on when the light came on. So long as the light stayed on, the fan would stay on. The 15 minute timer does not start until the program is evaluated as false (which happens only when light status changes to off), and runs the "else" condition. Perhaps I should have added spaces to make this easier to read:

 

if
status 'shower light' is on

then
set shower fan on

else
wait 15 minutes
set shower fan off

Posted

I just read the original post and noticed that his toggle lincs are dimmers not relays so you will need to alter your program to account for the dimmed status.

 

If
       Status  'shower light' is not Off

Then
       Set 'shower fan' On

Else
       Wait  15 minutes 
       Set 'shower fan' Off

Posted
I just read the original post and noticed that his toggle lincs are dimmers not relays so you will need to alter your program to account for the dimmed status.

 

Good catch. That is exactly the change that I would suggest, as well.

 

Simple, and to the point. I like your code oberkc

 

Simple is all I can understand.

Posted

Tested it out last night, works perfectly. Thanks for simplifying my code! I am a bit surprised with how all this works, but I think I have a better grasp on it now, thanks to you all.

Posted

Hello

Below are the programs I wrote to deal with my Bathroom Fan.

1. The Fan does not come on unless the Bathroom Door has been closed at some point (it does not have to stay closed)

2. The Fan only comes on if you've spent enough time in the bathroom to justify it (if you know what I mean :-)

3. If you've been in there for a long time (ie bathing or showering) the fan stays on an extra amount of time.

4. The Fan will remain on for a variable time, after you've exited, based on the amount of time you spent in there.

 

I use a Motion Sensor to detect initial presence and a TriggerLinc to determine if the Bathroom Door has been closed at some point. The Motion Sensor is also the Controller for a light scene in the Bathroom.

 

Program: Bathroom Fan Triggered

So with this program someone has triggerred the motion sensor and shut the door. If they are in there longer than 2min 45secs the Fan is turned on. Why turn it on if you're in there for a quick pee?

'SF Bath Door Closed Trigger' is a Boolean trigger (TRUE/FALSE) based on the TriggerLinc

Note: If the Door is not shut, ie your wife is putting on makeup, the light comes on but the Fan does not.

 

If

Status '06.SF.Beds.Bath / SF Bathroom Main' > 10%

And Program 'SF Bath Door Closed Trigger' is True

 

Then

Wait 2 minutes and 45 seconds

Set '06.SF.Beds.Bath / SF Bathroom Fan' On

 

Else

- No Actions - (To add one, press 'Action')

 

Program Bathroom Fan On After Exit

So now that the Fan is on, leave it on until the person leaves plus add an additional 6 minutes (or whatever you want) and give it a chance to simmer down in there :-)

 

Note: 'VAR Shower Fan Triggered' is another Boolean Program that is set to TRUE only is you've spent an extra long time in the bathroom (ie a shower) and is used in the 2 last programs below to run the Fan even longer. Longer, for steam etc

 

If

Status '06.SF.Beds.Bath / SF Bathroom Main' is Off

And Status '06.SF.Beds.Bath / SF Bathroom Fan' is On

And Program 'VAR Shower Fan Triggered' is False

 

Then

Wait 6 minutes

Set '06.SF.Beds.Bath / SF Bathroom Fan' Off

 

Else

- No Actions - (To add one, press 'Action')

 

These programs below are pretty much identical as the ones above however they determine if a longer fan on duration is required because of a shower or bath etc

 

Program: Shower Fan Triggerred

This program will be triggrred at the same time as the program 'Bathroom Fan Triggered'. However it doesn't turn on the Fan. It only determines if the Fan should be left on longer based on the amount of time spent in the bathroom.

So, if you've been in the bathroom, with the door closed, for at least 11min trigger the Shower duration.

If

Status '06.SF.Beds.Bath / SF Bathroom Fan' is On

And Program 'SF Bath Door Closed Trigger' is True

 

Then

Wait 11 minutes

Run Program 'VAR Nicks Shower Fan Triggered' (Then Path)

Else

- No Actions - (To add one, press 'Action')

 

 

Program: Shower Fan On After Exit

Ok - the fan is already on and there's been a presence in the bathroom for at least 11min. Run the fan for 13 min instead of 6, but after the person has left.

Again Note: You don't need to be present the entire time for the fan to come on or stay on. All the triggers have to be triggerred.

 

If

Status '06.SF.Beds.Bath / SF Bathroom Main' is Off

And Status '06.SF.Beds.Bath / SF Bathroom Fan' is On

And Program 'VAR Shower Fan Triggered' is True

 

Then

Wait 13 minutes

Set '06.SF.Beds.Bath / SF Bathroom Fan' Off

Run Program 'VAR Nicks Shower Fan Triggered' (Else Path)

 

Else

- No Actions - (To add one, press 'Action')

Posted

Strong work, a bit odd, but strong none the less.

 

Of course, some of us are capable of doing a lot of damage and getting out in less than 2 min 45 seconds (I don't dilly-dally).

 

I once considered a toilet paper dispenser trigger for the fan. But with the ladies, it would need to trigger twice to avoid the false "pee only" activation.

 

Perhaps an aroma detector? Maybe a detector capable of differentiating the various "splash" noises? Maybe a "grunt" detector?

 

Oh, this is too much fun.

Guest
This topic is now closed to further replies.

×
×
  • Create New...