- Code: Select all
#Call this from a trigger on State "status" "has any change" for each "beacon" that you wish have set the house status.
#Now get the status of all beacons in the valid beacon folder. Assume all are expired to start
AllExpired = "expired"
WhosHere = ""
PiCount = 0
# Add as many of these as you have rPis
RPi0Close = ""
RPi1Close = ""
#
#Find beacons in "Valid piBeacons" Folder (ID 552440476)
for MyDevice in indigo.devices:
if MyDevice.folderId == 552440476:
if (MyDevice.states["status"] == "up"):
AllExpired = MyDevice.states["status"] # State "status" of next Device in myNewDictionary
WhosHere = WhosHere + u" " + MyDevice.name
PiCount = PiCount + 1
#Add as many of these as you have rPis
if (MyDevice.states["closestRPI"] == 0):
RPi0Close = RPi0Close + u" " + MyDevice.name
if (MyDevice.states["closestRPI"] == 1):
RPi1Close = RPi1Close + u" " + MyDevice.name
if (AllExpired == "expired"):
indigo.variable.updateValue(1363252541, value="Gone") # Home Status
indigo.variable.updateValue(729737176, value="true") # another Home Status
else:
indigo.variable.updateValue(1363252541, value="Here") # Home Status
indigo.variable.updateValue(729737176, value="false") # another Home Status
indigo.variable.updateValue(1332290367, value = WhosHere) # List of all valid Beacons at Home
indigo.variable.updateValue(104188384, value = unicode(PiCount)) # Number of beacons at home
indigo.variable.updateValue(614002335, value = unicode(PiCount)) # another Number of beacons at home
#Add as many of these as you have rPis
VarPiID0 =642149151
VarPiID1=1931232172
indigo.variable.updateValue(VarPiID0, value = RPi0Close) # Beacons near Pi0
indigo.variable.updateValue(VarPiID1, value = RPi1Close) # Beacons near Pi1
If you've got a LOT of Pis like Karl, you can replace the individual variables and ifs with vectors called RPiClose and VarPiID and a loop from 0 to however many, and/or break out family from Guests, etc...