Need help with triggering scenes please

I have Yale Real Living door locks on all my doors and Leviton Vizia RF+ light switches throughout. I have successfully setup and scheduled scenes to turn on my exterior lights at night and turn off at dawn. I’m learning little by little, but I am not a programmer by any means! So here’s what I need help with:
I would like to have the interior light located at each doorway to turn on each time that doors lock is unlocked via PIN code, and then turn back off after 5 minutes.
I realize I need to create a scene where that light comes on and goes off after 5 minutes, but how do I setup the trigger?
Any help would be great. Thanks.

This involves no code at all. You make a scene, have the first action be turning whichever light on, then manage delays and create one for five minutes and then set it to turn said light back off. Then under triggers make a new trigger for your particular door with “a pin code is entered” then select which # pin you want to trigger the event. If you want all valid pin codes to trigger the scene put a * in place of a pin number. Save and continue, then sit back and enjoy your automated lights.

Now, I’m assuming you only want this to happen if it’s nighttime. In this case you will need some code. On the LUUP tab of the scene enter

if ( luup.is_night() ) then return true else return false end

Save lua, confirm changes and continue.

But wait, there’s more!
I have a scene which turns my interior lights on to 30% when I enter a pin at night, in case I’m coming in with a sleeping child that I don’t want to disturb. The above code will always dim the lights to 30%, even if they are already on, which is embarrassing when I have company over. People hanging out and the light dimms down while everyone is eating or something like that. In this case you would:

[code]-- Find the status of the light switches
local Light1State= luup.variable_get(“urn:upnp-org:serviceId:Dimming1”, “LoadLevelStatus”, 4)

– Exit the scene if light1 is on or it’s not night
if (Light1State > “0”) or not ( luup.is_night() ) then
return false
end
[/code]

Just replace the 4 with the device ID of you light.

Voila!

Ok, I followed your steps and I get no response when the door is opened. Its not being triggered I guess?

You followed the first set of steps? Are you sure you selected the proper PIN?

I tried for a while with no luck. So instead, I used alarm disarm to trigger and it worked fine?

luup.is_night will only work correctly if you setup your Vera’s Location and TimeZone

All that was correct, the problem was that the lock wasn’t triggering the scene. I tried setting it to trigger with PIN, then tried with unlocked status, and neither would trigger the lights. So I created a scene with the alarm disarmed status as the trigger and it worked fine. Could just be a problem with the lock settings maybe?