Entry Code Scheduling, Daily (Yale Deadbolt)

How can this be done? There’s currently values in the settings for scheduling a range of time when a code is active. But I cannot figure out how to schedule a code periodically.

Examples:
Weekdays: From 10am-4pm enable code 3.
Wednesday: From 11am-3pm enable code 4.

You might try this:

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

The above scenario should be “locked” to 0.00 - 06.00

I’ve found an effective way to do this.

With per-established codes, you can set their schedule without any writing any lua/luup.

By using the method “SetPinValidityWeekly” I can easily schedule that a code is enabled throughout the day at a certain time. (See Example)

I can then block access by giving an impossible range. Like Sunday only from 9am till 9am… (replace sample numbers with DayOfWeek=0,StopHour=9).

I’ve wired this to two scenes. One for enabling, and one for disabling.

For most cases, this works great…
The only warning is that scripting these actions along with others can cause problems. If two commands are sent at the same time, one can get lost. What I do is add a luup.sleep(10000) to the scenes in order to be sure that if something else triggers the scene, then it should give 10 seconds before attempting to command the lock.

Finally, I’ve added a virtual switch that triggers these scenes (ON=enable,OFF=disable). I also set the state of the virtual switch to be sure that the scenes remain synced with the switch (in case I simply triggered the scene and not the switch). This requires some more code to be sure you don’t repeat actions or a possible infinite loop. But now everything works great and I can turn on/off these ‘door-codes’ anytime I want with ease.

[quote=“electricessence, post:3, topic:172136”]I’ve found an effective way to do this.

With per-established codes, you can set their schedule without any writing any lua/luup.

By using the method “SetPinValidityWeekly” I can easily schedule that a code is enabled throughout the day at a certain time. (See Example)

I can then block access by giving an impossible range. Like Sunday only from 9am till 9am… (replace sample numbers with DayOfWeek=0,StopHour=9).

I’ve wired this to two scenes. One for enabling, and one for disabling.

For most cases, this works great…
The only warning is that scripting these actions along with others can cause problems. If two commands are sent at the same time, one can get lost. What I do is add a luup.sleep(10000) to the scenes in order to be sure that if something else triggers the scene, then it should give 10 seconds before attempting to command the lock.

Finally, I’ve added a virtual switch that triggers these scenes (ON=enable,OFF=disable). I also set the state of the virtual switch to be sure that the scenes remain synced with the switch (in case I simply triggered the scene and not the switch). This requires some more code to be sure you don’t repeat actions or a possible infinite loop. But now everything works great and I can turn on/off these ‘door-codes’ anytime I want with ease.[/quote]

Hi electricessence

What lock model does this relate to. I looked at my Kwikset locks and the “SetPinValidityWeekly” field is not there?

 Don