The duration is expressed as deltaTime, generated from a start and a finish Timestamp. using this code, which I was very happy to find here
- Code: Select all
from datetime import datetime
startTimeVariable = indigo.variables[1632591664].value # REPLACE '123' WITH YOUR START TIME VARIABLE ID
endTimeVariable = indigo.variables[765744602].value # REPLACE '456' WITH YOUR END TIME VARIABLE ID
try:
startTime = datetime.strptime(startTimeVariable, "%b %d %H:%M:%S")
except StandardError, e:
indigo.server.log(u"Error Converting Start Time ('%s'). Error='%s'" % (startTimeVariable, e), isError=True)
return
try:
endTime = datetime.strptime(endTimeVariable, "%b %d %H:%M:%S")
except StandardError, e:
indigo.server.log(u"Error Converting End Time ('%s'). Error='%s'" % (endTimeVariable, e), isError=True)
return
if endTime > startTime:
deltaTime = endTime - startTime
indigo.variable.updateValue(5022321, str(deltaTime)) # REPLACE '789' WITH YOUR DELTA TIME VARIABLE ID
else:
indigo.variable.updateValue(5022321, value="Start Time not before End Time") # REPLACE '789' WITH YOUR DELTA TIME VARIABLE ID
This bit of python is working beautifully.. It delivers duration in H:MM:SS.
What I haven't figured out is how to trigger off of this data (greater than, less than, etc). Conditions in triggers are not responsive, no matter how I formulate the entry. After many hours trying, I've been unable to manipulate this datetime value into a more digestible, trigger-ready format.
Would anyone have a suggestion?