FlyingDiver / Indigo-miniUniFi

Minimalistic UniFi plugin for Indigo
MIT License
0 stars 0 forks source link

Version 0.11 offline seconds error #15

Closed jstewart99 closed 3 years ago

jstewart99 commented 3 years ago

Upgraded to 0.11, got this error below. Deleted device and recreated it, error still occurs. Did not yet try deleting ALL old devices though.

miniUniFi Error Error in plugin execution runConcurrentThread:

Traceback (most recent call last): File "plugin.py", line 102, in runConcurrentThread File "plugin.py", line 374, in updateUniFiClient UnboundLocalError: local variable 'offline_seconds' referenced before assignment

miniUniFi Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)

FlyingDiver commented 3 years ago

Interesting. Can you see if there's an "offline_seconds" state in the device? Is this device online or offline at this time?

jstewart99 commented 3 years ago

offline_seconds is the ONLY state shown. Device shows offline, but is connected and should show online

FlyingDiver commented 3 years ago

OK, that error is causing the device update to fail, which is why nothing else is showing properly. Let me see what I need to do to fix that...

FlyingDiver commented 3 years ago

Can you grab the latest commit and see if that fixes the error? I don't want to push a release if it doesn't.

https://github.com/FlyingDiver/Indigo-miniUniFi/archive/50669a7ea08b30c6d04c5db64f48d347941cfe73.zip

jstewart99 commented 3 years ago

Slightly different error:

Error device "iPhone - AS" state key offline_seconds not defined (ignoring update request) miniUniFi Error Error in plugin execution runConcurrentThread:

Traceback (most recent call last): File "plugin.py", line 102, in runConcurrentThread File "plugin.py", line 377, in updateUniFiClient IndexError: tuple index out of range

miniUniFi Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)

jstewart99 commented 3 years ago

THAT referenced device is offline and I did not recreate it from the original (.3 was the last version I'd used, FWIW). I have two other devices that aren't explicitly throwing an error in the log, that are online (also were not recreated). I'd prefer not to have to recreate devices (makes me have to redo my control pages, shame on me for using beta versions in my CP's haha) but I can obviously do so it needed.

FlyingDiver commented 3 years ago

Try that again: https://github.com/FlyingDiver/Indigo-miniUniFi/archive/main.zip

FlyingDiver commented 3 years ago

Why would you need to recreate the device? Just update the plugin and see if the error goes away.

FlyingDiver commented 3 years ago

The 'IndexError: tuple index out of range' error should be fixed. The other error should be benign, but I'd want to see the logs anyway.

jstewart99 commented 3 years ago

Sorry since the version number was the same it wasn't a double-click to install update, so I disabled the plugin, went to /Library/Application Support, replaced the plugin, and then enabled the plugin. Just want to make sure that was the correct procedure...

Log now shows only: Error device "iPhone - AS" state key offline_seconds not defined (ignoring update request)

FlyingDiver commented 3 years ago

It's even easier to just replace the existing files then restart the plugin. But disabling, replacing, enabling also works.

If you edit that device (iPhone - AS) and hit save without actually changing anything, does the error go away?

jstewart99 commented 3 years ago

Yes I think that fixed the problem. Device shows offline and ONLY displays offlineseconds = 0. When I edit/save an online device, the state names got cleaned up a bit ("c" removed) and I now see offline_seconds for those, along with all the other states.

FlyingDiver commented 3 years ago

For some reason that device doesn't have a "last_seen" state, so I can't calculate the offline_seconds. Not sure what value I could put there in that case.

jstewart99 commented 3 years ago

It's probably messed up because it's offline and it couldn't update because of the bug/glitch you just fixed, and then when I edit/saved it there was no previous data to read, (no "last_seen")? So I assume this is just a unique issue caused by updating the plugin that will go away once this device comes back online.

FlyingDiver commented 3 years ago

Probably. Pre-release software - I reserve the right to break things. ;)