Yeah, that would help, huh?
Sorry - here are the supporting scripts running under v10.7.5 of OSX
I placed this code in /Library/Python/2.7/site-packages in a file called "dws.py".
- Code: Select all
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
import indigo
except ImportError:
print "Attachments can only be used from within Indigo"
raise ImportError
import datetime
from datetime import timedelta
import time
def minutesSince(indigoTimestamp, indigoVariable):
indigoTimestamp = indigo.variables[indigoTimestamp]
date_time_obj = datetime.datetime.strptime(indigoTimestamp, '%A, %B %d, %Y %H:%M:%S %p')
timestamp_now = datetime.datetime.now()
delta_minutes = (timestamp_now - date_time_obj).seconds / 60
indigo.server.log("Updating var " + indigoVariable + " with " + str(delta_minutes))
indigo.variable.updateValue(indigoVariable, value=unicode(delta_minutes))
Then I am running this code inside of an Indigo Action. I've verified it's loading the code, because when I change "dws.py" to "xyz_dws.ply" is throws an error saying it can't find the file (as it should). I've also verified I'm running v2.7 of Python.
- Code: Select all
import dws
import sys
indigo.server.log("Running Python: " + sys.version)
minutesSince("motionWholeHouseTimestamp", "minutesSinceMotionWholeHouse")
- Code: Select all
Script Running Python: 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]
Script Error embedded script: global name 'minutesSince' is not defined
Script Error Exception Traceback (most recent call shown last):
embedded script, line 9, at top level
NameError: global name 'minutesSince' is not defined