jfeger wrote:Has anyone else experienced the error I posted above? Im not fluent in python or coding in general, so I am hacking away, but haven't made much progress. Im wondering if there was a change in python versions or Indigo that is causing this timestamp to come back 00:00, which clearly doesn't match the expected format.
I too have the above issue.
The offending calling method is:
- Code: Select all
def runConcurrentThread(self):
try:
while True:
dev = indigo.devices[self.dev]
s = epsdtutils.DateDiff ("hours", indigo.server.getTime(), str(dev.states["lastreset"]) + " 00:00:00")
if s > 24:
self.hlreset()
self.sleep(1)
except self.StopThread:
pass # Optionally catch the StopThread exception and do any needed cleanup.
It is calling the utility method
- Code: Select all
DateDiff
passing the current server time, the concatenation and conversion to string of
- Code: Select all
dev.states["lastreset"]
and
- Code: Select all
" 00:00:00"
You will note the error returned:
time data ' 00:00:00' does not match format '%Y-%m-%d %H:%M:%S'
The server time is returning correctly for me, " 00:00:00" is a literal and mentioned in the error message, so this suggests dev.states["lastreset"] is returning an empty value.
I not sure what dev.states["lastreset"] actually is, but another code snippet (I believe) sets it:
- Code: Select all
def hlreset (self):
d = indigo.server.getTime()
dev = indigo.devices[self.dev]
w = indigo.devices[self.ws]
dev.updateStateOnServer("temperature_F_High", "")
dev.updateStateOnServer("temperature_F_Low", "")
dev.updateStateOnServer("temperature_C_High", "")
dev.updateStateOnServer("temperature_C_Low", "")
dev.updateStateOnServer("lastreset", d.strftime("%Y-%m-%d ") )
indigo.server.log ("High/low temps reset")
self.highlow (w, dev)
I can't find another call to hlreset other than runConcurrentThread.
I do not understand runConcurrentThread. Form the documentation:
If a plugin defines runConcurrentThread() and an uncaught python exception is thrown within that method, then the Indigo Plugin Host will automatically (after several seconds) create a new thread and again call runConcurrentThread().
Which is great, but an exception must occur in this method for it to get automatically run again, so what calls it the first time? It clearly is getting called though, so maybe it gets called always at plugin load?
Either way I suspect the first time str(dev.states["lastreset"] is being accessed for a value it hasn't been set at that point, thus it returns nothing and DateDiff fails.
The second bit of code is resetting the High and Low temps and there is a Force reset of High/Low through the plugin UI. I was hopping this would call hlreset manually and thus put a date value into dev.states["lastreset"].
This gives a new error:
- Code: Select all
Acme Future Home CPanel System Error Error in plugin execution MenuAction:
Traceback (most recent call last):
File "plugin.py", line 179, in hlreset
<type 'exceptions.KeyError'>: required elem or key type was None
I don't know what the above means, but clearly it fails to set dev.states["lastreset"] as the original error repeats every 10 seconds when runConcurrentThread is executed.
I am totally at the limit of my coding ability though!
Sam.