Interval Control during Certain Hours

I’ve tried searching the wiki and the forums, but if the answer is out there, I can’t seem to put my finger on search terms that would help solve my problem.

Setting - small science museum using a Vera 3 running 1.5.346 for controlling most exhibit components.

I have a fan that already has a z-wave module on it for turning on and off. I would like it to cycle on for 15 minutes, and off for 15 minutes, but only during certain hours each day. I have a scheduled on-scene that runs each day of the week to turn on the other exhibit items that should turn on when we open, and separate off-scene that runs at the end of the day to shut things down at closing. The fan is used to help evaporate water from an exhibit involving fog.

I tried setting up a scene just for this fan, which turns it on immediately, and then turn it off after 15 minutes. I then have this scene scheduled to run as “interval based” every 30 minutes. This works - but then is running 24/7, including afterhours/overnight when I don’t need it to run. I’ve also tried adding a Virtual Switch as a trigger for this scene, and have the virtual switch turned on and off in my regular daily on-scene (opening) and off-scene at closing time. However - while turning that Virtual Switch on at opening did seem to trigger the fan interval scene to run - turning the virtual switch off doesn’t seem to stop the interval scene from running, as such, the fan continues to cycle in 15 minute increments all day/night.

I think my question is how do I get the scene to stop running - either as code that I enter that will be run by the virtual switch when it is turned off, OR entered on the interval scene that checks whether or not the virtual switch is enabled or not. Or, is there a way to have a trigger stop a running interval scene?

Or - is there something completely obvious that I’m missing that lets you set intervals within a specific time frame (for example, run scene every 30 minutes between 8am and 5pm)?


You are correct using a virtual switch, but don’t base any triggers on it.

Assuming you turn the switch on when you open, and off when you close up, change your LUUP code to return true if the switch is on, and false is the switch is off.

Something like this:[code]
local runFan

– get status switch (virtual)
runFan = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,99)

– if tempCheck switch is off, stop
if (tonumber(runFan) == 0) then
luup.log(“FAN: canceled - switch off”)
return false

return true

Change “99” to be the device ID of your virtual switch.

Developer evangelism ahead…

You could use the Countdown Timer plugin to do this without any Luup code. Create two 15-minute timer devices and link the completion of one with triggering the starting of the other. Attach fan on/off commands as needed. Then, create a schedule that mutes the counting-while-fan-off timer at closing time, so that the fan doesn’t start until tomorrow’s opening-time scene kicks it all off again.

You can just limit the scene to run in a certain period.
Add this to You LUUP in the scenario - it will limit the scene to run from 00.00 to 06.00:

local t ='*t') if (t.hour>=0) and (t.hour<=5) then return true else return false end