Change datetime.datetime to just datetime
Once it's been imported above, you don't need to type it twice. (It's confusing because the module and the whateveritscalled are the same in this particular instance)
Sent from my iPhone using Tapatalk Pro
import datetime
source_datetime = datetime.datetime.strptime(source_var.value, "%Y-%m-%d %I:%M%p") # use this format specifier to insert timestamp into var
from datetime import datetime
source_datetime = datetime.strptime(source_var.value, "%Y-%m-%d %I:%M%p") # use this format specifier to insert timestamp into var
# Get the source device
my_device = indigo.devices[937130354] # "Bill's Office Light"
# Set the destination variable ID
dest_var_id = 1796103489 # "Motion_last"
# Subtract the device's lastChanged from the current time from the server
delta = indigo.server.getTime() - my_device.lastChanged
# Insert the number of elapsed minutes (seconds / 60)
indigo.variable.updateValue(dest_var_id, str(delta.seconds/60)) # insert elapsed minutes into dest var
import datetime
datetime.datetime # a datetime class
from datetime import datetime
jay (support) wrote:As I explained above, you can't use lastChanged because that represents ANY change to the device
whmoorejr wrote:Or if I see that one of the lights was left on... click to see how long it has been on for.
Colly wrote:whmoorejr wrote:Or if I see that one of the lights was left on... click to see how long it has been on for.
I like the sound of this - my other half has a habit of leaving lights on, doors open etc ...
bkmar1192 wrote:I know I am late...
Users browsing this forum: No registered users and 0 guests