Option 1: Variable Based List
I have this sorta working. The only thing I'm missing is a way to populate a variable with the USER_ID (Variable Name) associated with the correct PIN entered or with the python variable used. Right now, it just updates a variable with either "Fail" or "Success" vs. "Fail" or "Bill"
- Code: Select all
# Users
Bill = indigo.variables[699977664].value # "User01_Bill"
User2 = indigo.variables[669277461].value # "User02"
Vikki = indigo.variables[380866193].value # "User03_Vikki"
Anna = indigo.variables[190982521].value # "User04_Anna"
Ashley = indigo.variables[717167343].value # "User05_Ashley"
OneTime1 = indigo.variables[141646497].value # "User20_OneTime1"
# Add 20 more lines
# Build PW List
PWLIST = (Bill, User2, Vikki, Anna, Ashley, OneTime1)
# Receive and check the input variable
PWInput = indigo.variables[777599449].value # "PWInput"
if PWInput in PWLIST:
indigo.variable.updateValue(748482965, value="Success")
else:
indigo.variable.updateValue(748482965, value="Fail")
Side Note: I added a couple "OneTime" users to my keypad with a code. Good for a one time use. Once the code is used, a trigger fires that deletes the code from the keypad. So I can give it to a repair guy or something that needs access when I'm away, but I don't want them coming back later that night or whatever.
Option 2: CSV Based:
Ideally, I'd like to move the list to an external CSV file for overall user management. Where I'm stuck is how to use the data in one column on one row as input to return the data from a different column on the same row. (i.e., if I use a PIN as a variable, the script can return the User_Name. If I use the User_Name as the input variable, I can return the CellPhone#, etc.
- Code: Select all
User, PIN, Email, CellPhone
Bill, 1234, bill@mail.com, 832-555-1212
Vikki, 5678, vikki@mail.com, 713-555-1212
OneTime1, 9012, n/a, n/a
Every python script I've run gets me to the "Fail" message, so I'm messing it up big time somewhere.
Example of my failures:
- Code: Select all
import os.path
from os import system
import csv
login = False
with open('/Users/williammoore/Desktop/PinList.csv', 'r') as csvfile:
csv_reader = csv.reader(csvfile)
password = indigo.variables[777599449].value # "PWInput"
for column in csv_reader:
print(column[0],column[1])
print(password)
if column[1] == password:
login == True
else:
login == False
if login == True:
indigo.variable.updateValue(748482965, value=column[0])
else:
indigo.variable.updateValue(748482965, value="fail")
- Code: Select all
import csv
import sys
#input number you want to search
password = indigo.variables[777599449].value # "PWInput"
#read csv, and split on "," the line
csv_file = csv.reader(open("/Users/williammoore/Desktop/PinList.csv", "r"), delimiter=",")
#loop through the csv list
for column in csv_file:
if password == column[1]:
indigo.variable.updateValue(748482965, value=column[0])
else:
indigo.variable.updateValue(748482965, value="Fail")