Page 1 of 1

Date conversion error

PostPosted: Thu Jun 15, 2017 10:36 am
by siclark
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?

Re: Date conversion error

PostPosted: Thu Jun 15, 2017 10:37 am
by siclark
With the right attachment

Re: Date conversion error

PostPosted: Thu Jun 15, 2017 5:45 pm
by kw123
simple question: any extra spaces before or after date string in variable? If so do a value.strip() to get rid of them