Lock Triggers

jltnol
Posts: 1162
Joined: Tue Oct 15, 2013 11:11 pm

Lock Triggers

Post by jltnol »

So I've got 2 Z-Wave locks and they are both working just fine. I have a small handful of people who have codes and I'd like for them to be able to enter their code in the lock, unlock the door, and then have Indigo recognize their code and perform an action group.

I have the Trigger set to
Lock State Becomes not Equal to Locked
(... basically unlocked), and the conditions set to
Last User is Equal To
, and then the corresponding lock addresses. But what is happening is when one of the codes is entered the first time, nothing happens, since it obviously not the "last user", but in some respects the "current user". The second time one of the codes is used, the trigger fires, but only because the 1st code is now the "last user".

I can see that I can trigger on
unlocked by any user
, but I don't want this to happen when I use my code. Is there a way to make this happen without having to create individual triggers for each of the codes?
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Lock Triggers

Post by FlyingDiver »

Have you tried using the ZWave Lock Manager specific triggers? Not the generic device changed?
Attachments
Screen Shot 2022-04-21 at 4.04.47 PM.png
Screen Shot 2022-04-21 at 4.04.47 PM.png (428.77 KiB) Viewed 3287 times
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
jltnol
Posts: 1162
Joined: Tue Oct 15, 2013 11:11 pm

Re: Lock Triggers

Post by jltnol »

Yes

Unless I'm missing something, I'd have to create a trigger for each user, TWICE. One for the front door and one for the back door.

I think I'm just going to use the "unlock by any user" trigger(one for each door), and set it to trigger with any user. Then have indigo disable it when the alarm is turned off, and re-enable when the alarm is turned on. This method should work just fine!
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Lock Triggers

Post by whmoorejr »

Untested... but this might work.....

New Trigger "Anyone Unlocks"
  1. Trigger: Type "Z-Wave Lock/Code Manager Event". Event "Lock unlocked by code" (Lock1 & Any User)

    Condition: Always

    Action: Insert Device State into Variable (Variable Actions) Device: Lock1, "lastUser" into variable "Door1_Last_User"

    Action: Delay by 0:00:05. Modify Variable "Door1_Last_User" Set to: 0
New Trigger "Anyone Unlocks Part 2"
  1. Trigger: Variable Changed, Variable "Door1_Last_User" becomes not equal to: 0

    Condition: Always

    Action: <Insert Fancy Stuff Here> I would suggest a python script that reads the variable "Door1_Last_User" to then pull from your list of users to then have an action specific to that user.
Here is an example script you can use in an action that will read the variable "Door1_Last_User" and generate the corresponding name from a plugin I wrote. If the door is successfully unlocked with a code that is known, this script will generate a success message and launch a success action. If the door is successfully unlocked with a code that isn't listed in the plugin, the script will generate an error message and launch an error action. Either way it will then populate another variable with the name of the person that corresponds with the user number.

Code: Select all

import logging
login_name = "Unknown User" # if you change this, don't forget to update the if login_name == "Unknown User" below
Door1_Last_User = indigo.variables[777599449].value # "Door1_Last_User"
theMessage = "Unknown User Entered, User: " + login_name

for dev in indigo.devices.iter(filter="com.whmoorejr.my-people"):
   The_User = dev.states["userPinNumber"]
   if The_User == Door1_Last_User:
      login_name = dev.states["friendlyName"]
      theMessage = "PIN Code Accepted, " + login_name + " is here."
#      indigo.server.log(login_name + " can have soup!") # log a success PIN message
#      indigo.actionGroup.execute(12345678) # run a success PIN action

if login_name == "Unknown User":
   indigo.server.log("No Soup For You!", level=logging.WARNING) # log a failure message
#   indigo.actionGroup.execute(87654321) # run a failure PIN action

indigo.variable.updateValue(748482965, value=login_name)  # update variable with name of user with matching user number or "Unknown User"
indigo.server.log(theMessage) # log the result of the script
Bill
My Plugin: My People
howartp
Posts: 4559
Joined: Thu Jan 09, 2014 4:43 pm
Location: West Yorkshire, UK

Re: Lock Triggers

Post by howartp »

Thanks to everyone who has replied.

I should be able to fairly easily add "Any lock" to the triggers, rather than having to pick a specific lock.

Leave it with me.
jltnol
Posts: 1162
Joined: Tue Oct 15, 2013 11:11 pm

Re: Lock Triggers

Post by jltnol »

So I may be missing something but in the Event log, the status for the Z-Wave Lock Manager shows the current user:
Z-Wave received "DL-02 Kitchen Door" status update unlocked (via keypad)
Z-Wave Lock/Code Manager Status: User 11 unlocked door [Node: 15]
In this case User 11 is the user who just opened the door.

But I don't see how that info shows up in the GUI. "last user" as denoted in the plugin, is actually the user before the most current one like in the attached pic. I've got a work-around that will suffice, but obviously it would be nice if the GUI could gather and use the "current user" info.
Attachments
Screen Shot 2022-04-21 at 8.02.04 PM.png
Screen Shot 2022-04-21 at 8.02.04 PM.png (7.55 KiB) Viewed 3249 times
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Lock Triggers

Post by whmoorejr »

jltnol wrote: But I don't see how that info shows up in the GUI. "last user" as denoted in the plugin, is actually the user before the most current one like in the attached pic. I've got a work-around that will suffice, but obviously it would be nice if the GUI could gather and use the "current user" info.
What is that a screen shot of? Is that a variable you created? If so, how are you populating the variable?

When you select the lock in devices and scroll down on the bottom middle, you will see all the custom states for the device. One of the device states is “lastUser”. That device state should be accurate.
Bill
My Plugin: My People
jltnol
Posts: 1162
Joined: Tue Oct 15, 2013 11:11 pm

Re: Lock Triggers

Post by jltnol »

that device state should be accurate.
It's not.
So the LAST USER in the custom states IS right. But if you have the GUI put the last user into a variable, it will put in the previous user, not the most current user.
howartp
Posts: 4559
Joined: Thu Jan 09, 2014 4:43 pm
Location: West Yorkshire, UK

Re: Lock Triggers

Post by howartp »

As Bill says, how are you populating that variable?

I (don’t think) my plugin populates variables so you must be using a custom action or script.

If you have a trigger on the Zwave lock state (per your earlier post), rather than my plugin, that is probably firing before my plugin and therefore it’s correctly putting the lastUser at that point (fractions of seconds before my plugin updates lastUser) into the variable.


Sent from my iPhone using Tapatalk Pro
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Lock Triggers

Post by whmoorejr »

howartp wrote:... that is probably firing before my plugin and therefore it’s correctly putting the lastUser at that point (fractions of seconds before my plugin updates lastUser) into the variable.
Right.... so whatever method you are using.... add a 1 second delay to that action to give the plugin the millisecond it needs to catch up. I know I've had to do that for other things as well (add a delay before capturing a device state or whatever to give everything else time to line up.)

I don't know, but the milisecond difference might also gum things up if used as a condition.
Example if Tony's code was the last used. Tony's user ID is the "lastUser"
If Ziva enter's her code and the "Unlock" state is changed a millisecond before the "lastUser" state, then the Ziva trigger won't fire because the condition needs a millisecond longer to update with Ziva's user ID.

FYI, the reason I add "Action: Delay by 0:00:05. Modify Variable "Door1_Last_User" Set to: 0" is so the next trigger can fire from a change in the variable. If Ziva is the only one using the door, then the variable will stay the same. This sets the variable to 0 after use
Bill
My Plugin: My People
jltnol
Posts: 1162
Joined: Tue Oct 15, 2013 11:11 pm

Re: Lock Triggers

Post by jltnol »

Again, not sure how else to populate the variable via the GUI, but these are the settings I'm using. It only populates the previous user, not the current user. I can easily create a single trigger for a single user, but I've got 12 codes and 2 doors so that means 24 triggers to accomplish what I'm trying to do. I've given the time delay issue consideration, but do find it odd that the custom state is right, but the GUI isn't.
Attachments
Screen Shot 2022-04-22 at 8.14.34 AM.png
Screen Shot 2022-04-22 at 8.14.34 AM.png (320.04 KiB) Viewed 3175 times
howartp
Posts: 4559
Joined: Thu Jan 09, 2014 4:43 pm
Location: West Yorkshire, UK

Re: Lock Triggers

Post by howartp »

Apologies to you both.

I’ve just realised I’m firing your trigger before I’ve updated the state, so it’s my fault you’re getting wrong state value in variable.

I’ll sort asap.


Sent from my iPhone using Tapatalk Pro
jltnol
Posts: 1162
Joined: Tue Oct 15, 2013 11:11 pm

Re: Lock Triggers

Post by jltnol »

Thanks

Originally I had the Trigger setup with a list of conditions being"any" 'last user', leaving my personal code off the list. But it would sometimes fail given a certain sequence of unlock codes. I didn't notice the custom device state was right until yesterday... so just assumed it was some kind of a timing issue.
jltnol
Posts: 1162
Joined: Tue Oct 15, 2013 11:11 pm

Re: Lock Triggers

Post by jltnol »

So I just downloaded the updated version of the plugin and I know you don't need me to tell you that it works perfectly!

Thanks for making this better and easier!
Post Reply

Return to “ZWave Lock Manager”