set value of variable to value of variable in Python.

Posted on
Mon May 27, 2019 9:28 am
whmoorejr offline
User avatar
Posts: 762
Joined: Jan 15, 2013
Location: Houston, TX

set value of variable to value of variable in Python.

This is a code I would use to update an "Alert Text" log of the last 10 "Alert Events". (doors, motion detection activity, etc.). An example use is knowing why something just happened.... so if my control page rotates to the backyard camera, the alert text will be at the bottom of the screen with either (Back door opened, Motion Zone 17 or Video Motion Detected). So... the event will (among other actions, update two variables, AlertText and enter a formatted date time in AlertTextDTG. Since the contents of AlertText could repeat (like repeated motion sensor in living room)... There is a separate trigger that fires when AlertTextDTG changes value. That fires the below code to keep a running list of the last 10 alerts

AppleScript
Code: Select all
tell application "IndigoServer"
   set value of variable "AlertTextLog10" to value of variable "AlertTextLog9"
   set value of variable "AlertTextLog9" to value of variable "AlertTextLog8"
   set value of variable "AlertTextLog8" to value of variable "AlertTextLog7"
   set value of variable "AlertTextLog7" to value of variable "AlertTextLog6"
   set value of variable "AlertTextLog6" to value of variable "AlertTextLog5"
   set value of variable "AlertTextLog5" to value of variable "AlertTextLog4"
   set value of variable "AlertTextLog4" to value of variable "AlertTextLog3"
   set value of variable "AlertTextLog3" to value of variable "AlertTextLog2"
   set value of variable "AlertTextLog2" to value of variable "AlertTextLog1"
   set value of variable "AlertTextLog1" to value of variable "AlertText"
   set value of variable "AlertTextDTGLog10" to value of variable "AlertTextDTGLog9"
   set value of variable "AlertTextDTGLog9" to value of variable "AlertTextDTGLog8"
   set value of variable "AlertTextDTGLog8" to value of variable "AlertTextDTGLog7"
   set value of variable "AlertTextDTGLog7" to value of variable "AlertTextDTGLog6"
   set value of variable "AlertTextDTGLog6" to value of variable "AlertTextDTGLog5"
   set value of variable "AlertTextDTGLog5" to value of variable "AlertTextDTGLog4"
   set value of variable "AlertTextDTGLog4" to value of variable "AlertTextDTGLog3"
   set value of variable "AlertTextDTGLog3" to value of variable "AlertTextDTGLog2"
   set value of variable "AlertTextDTGLog2" to value of variable "AlertTextDTGLog1"
   set value of variable "AlertTextDTGLog1" to value of variable "AlertTextDTG"
end tell


Python
Code: Select all
#Update alert text
indigo.variable.updateValue(95980368, indigo.variables[979829027].value) # Alert Text 9->10
indigo.variable.updateValue(979829027, indigo.variables[55086791].value) # Alert Text 8->9
indigo.variable.updateValue(55086791, indigo.variables[963955667].value) # Alert Text 7->8
indigo.variable.updateValue(963955667, indigo.variables[1493219924].value) # Alert Text 6->7
indigo.variable.updateValue(1493219924, indigo.variables[1882512563].value) # Alert Text 5->6
indigo.variable.updateValue(1882512563, indigo.variables[1080666339].value) # Alert Text 4->5
indigo.variable.updateValue(1080666339, indigo.variables[412098774].value) # Alert Text 3->4
indigo.variable.updateValue(412098774, indigo.variables[582295042].value) # Alert Text 2->3
indigo.variable.updateValue(582295042, indigo.variables[1361194053].value) # Alert Text 1->2

#update alert DTG
indigo.variable.updateValue(1049491667, indigo.variables[1065501880].value) # Alert DTG 9->10
indigo.variable.updateValue(1065501880, indigo.variables[780856803].value) # Alert DTG 8->9
indigo.variable.updateValue(780856803, indigo.variables[403426304].value) # Alert DTG 7->8
indigo.variable.updateValue(403426304, indigo.variables[30912675].value) # Alert DTG 6->7
indigo.variable.updateValue(30912675, indigo.variables[124946257].value) # Alert DTG 5->6
indigo.variable.updateValue(124946257, indigo.variables[1521762498].value) # Alert DTG 4->5
indigo.variable.updateValue(1521762498, indigo.variables[1808668941].value) # Alert DTG 3->4
indigo.variable.updateValue(1808668941, indigo.variables[1278414883].value) # Alert DTG 2->3
indigo.variable.updateValue(1278414883, indigo.variables[306983668].value) # Alert DTG 1->2


Hope someone finds this helpful

Bill
My Plugin: My People

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests