I have come up with the following python script that looks at the last 25 event log messages and matches a string that I know is the message being sent when my door sensor opens.
This script is run from a schedule every 10 seconds when my alarm is armed.
When the string is located in the event log it sets a variable that in turn works with a trigger I have set to send me push notifications and set of my Sirene.
I am looking for any thoughts and opinions, if this is a good way to do what I wanted, or are there better ways to achieve the result I'm after.
It seems to be working fine, but I'm generally looking for advice, do's and dont's of python inside Indigo...
Here is the code :
- Code: Select all
alarmArmedVar = indigo.variables[1705593234]
if alarmArmedVar.value == "true":
indigo.server.log("The alarm is armed, check for door sensor tripped")
eventEntries = indigo.server.getEventLogList(lineCount=25)
eventToLookFor = "requestAlarmSensorStatus: node 008, endpoint None, cmdClass 71, type 6, value 255"
doorTrippedVar = indigo.variables[543692705]
if eventToLookFor in eventEntries:
indigo.server.log("Event found in eventLog: Door is tripped\n")
indigo.variable.updateValue(doorTrippedVar, "true")