Date conversion error

Posted on
Thu Jun 15, 2017 10:36 am
siclark offline
Posts: 895
Joined: Jun 13, 2017
Location: UK

Date conversion error

Hi
I am trying to use this to show me minutes since an alarm sensor was last tripped. I have a trigger that puts the current time into the variable whenever the sensor is tripped. The current value of that is

2017-06-15 17:30:42

If I just do a date conversion I get this error

EPS - Device Extensions Error Exception in dtutil.DateStringFormat line 164: time data 'description : \nfolderId : 1273164603\nglobalProps : MetaProps : (dict)\nid : 257243966\nname : FrontDoorChangeTime\npluginProps : com.eps.indigoplugin.device-extensions : (dict)\nreadOnly : False\nremoteDisplay : True\nvalue : 2017-06-15 17:03:48' does not match format '%Y-%m-%d %H:%M:%S'
CODE: oldDate = datetime.datetime.strptime (value, oldFormat)

and if I do a conversion to elapsed time I get this error

EPS - Device Extensions Error Error in plugin execution ServerReplacedElem:

Traceback (most recent call last):
File "plugin.py", line 114, in deviceUpdated
File "plugin.py", line 171, in updateDevice
File "plugin.py", line 456, in convertDeviceAction
File "plugin.py", line 486, in calcMinutes
TypeError: debugLog() got an unexpected keyword argument 'isError'

This is my setting... it all seems ok, and I have tried various combinations. Where am I going wrong?
Attachments
datetimeconversion.tiff
datetimeconversion.tiff (54.79 KiB) Viewed 662 times

Posted on
Thu Jun 15, 2017 10:37 am
siclark offline
Posts: 895
Joined: Jun 13, 2017
Location: UK

Re: Date conversion error

With the right attachment
Attachments
datetimeconversion2.tiff
datetimeconversion2.tiff (60.52 KiB) Viewed 660 times

Posted on
Thu Jun 15, 2017 5:45 pm
kw123 offline
User avatar
Posts: 6510
Joined: May 12, 2013
Location: Dallas, TX

Re: Date conversion error

simple question: any extra spaces before or after date string in variable? If so do a value.strip() to get rid of them

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest