Plugin: DelayLight

I thought I read a comment somewhere that you might implement a scheduling feature so a timer could be made active only during a fixed time period (perhaps in addition to a day/night switch?). Can’t seem to find that discussion now, but I have several use cases where scheduling would be a very useful addition.

I’ve just started using DelayLight and already have 13 timers configured. Thank you for a great utility!

One additional question. Your GitHub description explains that an Automatic Off Delay of zero means no automatic timing. Is this also true for Manual Off Delay? This would be useful for me in a couple cases.

Just tried to make a donation (“tip”) on makersupport.com but it won’t seem to take funding right now. Happy to contribute if you have another means.

Same here. I’d also be happy to contribute if you have another way.

Not currently, but I’ll add it. I’m planning on pushing a maintenance release up this weekend.

Just tried to make a donation ("tip") on makersupport.com but it won't seem to take funding right now. Happy to contribute if you have another means.

Yeah, not sure what’s up there. I’ve contacted makersupport.com. Let’s see if they come back with something quickly.

Hi,

I am enjoying you plugin :slight_smile: I have 2 basic jobs and i cannot work out the best way to solve, just wondering if you can help or point me in the right direction.

door opened - turn on light
door closed - turn off light after 2 min unless door is reopened.

I have 2 doors that trigger a flood light in the garden, so if night and ether door is opened turn on the flood light, turn off the flood light when both doors are closed and 2 min has passed, if ether door is reopened leave the light on.

I know they are very basic things, I have been sat here for a few days scratching my head.

Paul

[quote=“pukka, post:26, topic:198651”]1.
door opened - turn on light
door closed - turn off light after 2 min unless door is reopened.[/quote]

Set the door sensor as the trigger device, and the light on both the on- and off-lists. Set an Auto-off delay time of 120 (seconds). Set Hold-Over to “Wait until all triggered sensors have reset”.

2. I have 2 doors that trigger a flood light in the garden, so if night and ether door is opened turn on the flood light, turn off the flood light when both doors are closed and 2 min has passed, if ether door is reopened leave the light on.

Since DelayLight currently only supports a single trigger device and you have two doors you want to use as triggers, you will need to set up a scene to trigger DelayLight.

  1. Click “Add a scene” in the scene list of the Vera dashboard;
  2. In “Step 1. Select a Trigger”, choose “Device” and set up your first door to trigger on open;
  3. When that’s done, click “Add another trigger” and set up your second door the same way;
  4. Then click “Next Step” to choose the controlled devices, and choose (only) the DelayLight timer;
  5. For the scene device settings, make sure the “Auto” button is highlighted green and the “Reset” button is NOT (you may need to click the buttons more than once);
  6. Click “Next Step” and then click the “No Luup Code defined” line/arrow
  7. Enter the following scene Lua exactly as shown and save the code:
return luup.is_night()
  1. Click on “Advanced editor” and make sure there is only a single line showing urn:toggledbits-com:serviceId:DelayLight1 Trigger. If there is a line for SetEnabled, or any other condition, use the “Delete” button to remove them. Then hit “Done”.
  2. Give your scene a name and room, and click the “Finish” button.

The Vera will reload when you finish the scene, so take a break for a minute or two.

Then, configure that DelayLight timer itself: Auto-off delay 120 seconds, no trigger (the scene will do the triggering externally), put your light in both the on- and off-lists, and switch Hold-Over to “Wait until all triggers have reset”.

The only thing that won’t work exactly as you describe is the off timing–the hold-over doesn’t stop timing, it just stops the off cycle, so if the door (in either case) is open for five minutes (which is more than the two minute timing cycle), for example, the light will go off immediately when the door is closed. I will add an additional option to the Hold-Over function to extend the timing.

Hi Patrick

Thank you so much for a detailed how to. :smiley:

I have one more strange request.

Sunset only
door1 opened light 1 and 2 come on
door 2 opened light 1 and 2 come on light 3 on (between sunset and 9pm)

once both doors are closed lights 123 off after 120 seconds

I did sort of make this work with PLEG but never understood how it work, just kept trying until it worked. (broke when the clocks changed in the UK)

Do i just need to create your scene and then an extra scene for light 3 and then on the DelayLight just add light 3 to the off

Paul


Just incase anyone else see’s this, I just created another scene, trigger door2, turn on light 3, with Luup

local pStart = 0 – Start of time period, minutes offset from sunset
local pEnd = “21:00” – End of time period
local allow = true – true runs scene during period, false blocks it
local mStart = math.floor( (luup.sunset() % 86400) / 60 ) + pStart
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end

[quote=“pukka, post:28, topic:198651”]Sunset only
door1 opened light 1 and 2 come on
door 2 opened light 1 and 2 come on light 3 on (between sunset and 9pm)[/quote]

This is probably into PLEG’s territory.

I have had it running in pleg, but dont really understand pleg…

Will have a think and a test.

[quote=“pukka, post:30, topic:198651”]I have had it running in pleg, but dont really understand pleg…

Will have a think and a test.[/quote]

You might consider vosmont’s Rules Engine plugin. It requires you to use ALTUI, but that’s a good idea anyway.

You might also find the workflows of AltUI useful [url=http://forum.micasaverde.com/index.php?topic=37746.0]http://forum.micasaverde.com/index.php?topic=37746.0[/url]. They are another visual way to create your automation routines. I suggest you look first at the examples, then go back and read the initial documentation. It’s a nice way to see the flow of your automation.

Hi rigpapa

The plugin has been working great and much more simple than others i have tried, I have just installed the update to include “Do not start off-delay timer until registered sensors reset” will let you know how it goes.

Just pondering another idea and wonder how to implement it.

If a door is open and the plugin is set to “Do not start off-delay timer until registered sensors reset” or “Do not turn off until timer expires and all trigged sensors have reset” is they anyway to turn the light off automatically after 30 minutes?

Paul

Just one more usage questions.

kitchen light and a PIR.

What I would like to acheive,
PIR or switch to turn ON the light at night and OFF after 10min or reset timer if they is movement.
If the switch is turned on during the day, turn ON the light and OFF after 10min or reset timer if they is movement.

I can work out how to achieve them separately but not as one.

Paul

A couple of things to know:

  1. If an “auto” delay is set (non-zero), the loads in the “on” list will be turned on automatically when a trigger sensor trips, and the timer will run for the auto delay duration, at least;

  2. If a controlled load is turned on manually, and the manual delay is non-zero, the timer will run for the manual delay duration;

  3. Whichever delay starts first determines the mode (auto or manual);

  4. If a trigger sensor trips during the auto period, the timer restarts the auto delay period;

  5. If a trigger sensor trips during manual timing, the timer is extended to the auto delay period if the remaining manual time is less than the auto delay time.

So, everything you want to do it will do out of the box, except the night-sensitivity. I’m planning on adding “inhibitors” for auto triggering, but it’s not there yet.

[quote=“rigpapa, post:35, topic:198651”]A couple of things to know:

  1. If an “auto” delay is set (non-zero), the loads in the “on” list will be turned on automatically when a trigger sensor trips, and the timer will run for the auto delay duration, at least;

  2. If a controlled load is turned on manually, and the manual delay is non-zero, the timer will run for the manual delay duration;

  3. Whichever delay starts first determines the mode (auto or manual);

  4. If a trigger sensor trips during the auto period, the timer restarts the auto delay period;

  5. If a trigger sensor trips during manual timing, the timer is extended to the auto delay period if the remaining manual time is less than the auto delay time.

So, everything you want to do it will do out of the box, except the night-sensitivity. I’m planning on adding “inhibitors” for auto triggering, but it’s not there yet.[/quote]
Thanks for this—it confirms my observations. After living with it for a couple of weeks, and despite my stated aversion to creeping featurism, I would like to have trigger inhibitors, mainly schedule-based, although light-level would also be useful.

That’s helpful. So time schedules and sensors. It already does house mode. Anything else?

Nothing right now. The trigger inhibit should do the job without overcomplicating it.

The stable branch on Github now contains a version of DelayLight that implements inhibits and active/inactive time periods. It also adds compatibility checks for version of openLuup, as certain versions have a problem with child startup (@akbooer has already fixed this, but it’s still in his testing branch).

There is no UI yet for the Inhibits or schedules, so you need to edit state variables. The service for these variables is [tt]urn:toggledbits-com:serviceId:DelayLightTimer[/tt]

To use the inhibits, put the device numbers, as a comma-separate list, of the devices that should be used to prevent triggering when tripped/on into the state variable called [tt]InhibitDevices[/tt]. These can be any device that implements SecuritySensor1 (motion sensors, door sensors, etc.), or any device that implements SwitchPower1 (switches, dimmers, and many others). If you need to invert the sense of the test, make the device number negative (e.g. 4 will inhibit when device 4 is tripped, but -4 will inhibit when device 4 is not tripped).

To use the active periods, put the start and end 24-hour time ranges into the [tt]ActivePeriods[/tt] state variable (format HHMM-HHMM). If you have multiple active periods, you can make it a comma-separate list of multiple ranges. For example, [tt]0500-0900,1800-2200[/tt] would be active between 5am and 9am, and 6pm and 10pm, daily. Outside these periods, auto-triggering is inhibited.

The stable branch now has a UI for active periods and inhibitors. Users of ALTUI on either Vera or openLuup can install or update to this latest code via the AltAppStore.

As long as testing completes without issue, I plan on releasing this version in the Vera Plugin Marketplace over the weekend for availability on Monday June 25 2018.