My People Scripting Examples

Just a regular Indigo user that wants to contribute to the Indigoverse any way I can.
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

My People Scripting Examples

Post by whmoorejr »

I will try to post any scripting examples that work with the MyPeople plugin here to help others. Feel free to contribute if you have one that works.
Bill
My Plugin: My People
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: My People Scripting Examples - Update state

Post by whmoorejr »

Use this script to update the state of a MyPeople Person device....

Code: Select all

import logging
myPeopleId = "com.whmoorejr.my-people"
myPeoplePlugin = indigo.server.getPlugin(myPeopleId)
if myPeoplePlugin.isEnabled():
	newPinNumber = "5678"
	myPeoplePlugin.executeAction("setUserPinNumber", deviceId=946349721, props={'userPinNumberField':newPinNumber})
else:
	indigo.server.log("Didn't Work" , level=logging.WARNING) # log a failure message
Hint:
  • Change deviceId # to the deviceId# of your device
    All of the device states are called by "set" from a "field"
    for userPinNumber setUserPinNumber userPinNumberField
    for firstName setFirstName firstNameField
    for phoneNumber1 setPhoneNumber1 phoneNumber1Field
    etc.
Bill
My Plugin: My People
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: My People Scripting Examples - PIN Code use

Post by whmoorejr »

This can be used with a control page keypad on any method where you can get a PIN number saved as a variable... This example is used in a trigger that fires when that variable changes.... In this example:
  • Variable: "PWInput" [777599449] is the variable set from a control page keypad (or whatever method you choose to populate the variable)
    Variable: "Outcome" [748482965] the variable that is updated at the end of the scrip with the name of the person.
    Action Group (12345678) the action that is run with a successful PIN code.
    Action Group (87654321) the action that is run with a failed PIN code.

Code: Select all

import logging
login_name = "PIN fail" # if you change this, don't forget to update the if login_name == "PIN fail" below
password = indigo.variables[777599449].value # "PWInput"
theMessage = "Unsuccessful PIN Entry Attempt with PIN: " + password

for dev in indigo.devices.iter(filter="com.whmoorejr.my-people"):
	MyPin = dev.states["userPinNumber"]
	if MyPin == password:
		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 == "PIN fail":
	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 pin or "PIN Fail"
indigo.server.log(theMessage) # log the result of the script
Bill
My Plugin: My People
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: My People Scripting Examples - Specific Now Showing

Post by whmoorejr »

Use this script to set the "Now Showing" device to a specific device (record/person).

Code: Select all

import logging
myPeopleId = "com.whmoorejr.my-people"
myPeoplePlugin = indigo.server.getPlugin(myPeopleId)
if myPeoplePlugin.isEnabled():
	theRecord = "1"
	myPeoplePlugin.executeAction("nowShowingSpecific", deviceId= 1883703450, props={'nowShowingSpecificField':theRecord})
else:
	indigo.server.log("Didn't Work" , level=logging.WARNING) # log a failure message
Notes:
  • Change theRecord = "n" to the record number you want.
    Change deviceId= 12345 to the deviceId of your "Now Showing" device created by the plugin
    If you request a record greater than the number of records available 0-total, the action will set the requested number to 0 (the first record)
Bill
My Plugin: My People
User avatar
mundmc
Posts: 1068
Joined: Fri Sep 14, 2012 4:34 pm

Re: My People Scripting Examples

Post by mundmc »

Thank you for these!
Post Reply

Return to “Bill's Plugins”