Hi all - I have a fresh air intake for a single room that isn’t always occupied. I want to make the fresh air intake runs 20 minutes every hour, but only when the room is occupied, and only for up to 4 hours once it is vacated.
Example scenario: Room hasn’t been used in days, no fresh air. Someone goes into the room at 1pm at sits down. Fresh air intake starts and is set to run until 5pm. At 2pm the person gets up and moves around but is still in the room, so since the motion saw him move at 2pm it will now run the fresh air until at least 6pm. Person gets up at 2:30pm and leaves the room. Fresh air will now run until 6:30pm. No one else enters the room so motion is not tripped again. At 6:30pm the fresh air intake is shut off. Process then repeats the next time someone enters the room.
For the hardware side - I will use a motion sensor to detect last time of occupancy. And I will use a dry contact to trigger the motorized damper to open/close. I have the hardware part of the puzzle solved, but not sure if I can accomplish the above using existing smartapps, SmartThings and or IFTTT, or if I need to write something myself?
The logic for how I want things to work would look something like this (pseudo-code):
IF motion is detected THEN
IF motion not detected for 4 hours then
STOP RUN_JOB from running (somehow?)
send alert/log message "Room occupied, turning on fresh air"
time_until_room_is_considered_empty = now + 4 hours
while now < time_until_room_is_considered_empty DO
run_this_cycle_until = now + cycle_time
while now < run_this_cycle_until do
send alert/log message "Time to bring in fresh air for " + cycle_time + " minutes."
send signal to Z-Wave plug to switch on, so it powers 24VAC connected to damper to open damper
look for an override signal (somehow???) that may be sent to say to quit, and exit this loop if so
send alert/log message "Fresh air for " + cycle_time + " minutes completed, closing damper, waiting for next time to run"
I’m not sure if this is the right way to do things within the SmartThings universe, but the pseudo code will give you an idea of the functionality. Also I’m not sure if the job should keep track of its time or it should run forever until and outside job stops it somehow… And as you can see in the pseudo code I need a way to tell it to stop by sending it a z-wave command.
Any advice or pointers is greatly appreciated as to the best way to go about this. Thank you!!