daniel-2k / ioBroker.nanoleaf-lightpanels

ioBroker Adapter for nanoleaf Light Panels / Canvas
MIT License
11 stars 4 forks source link

Unable to get API token if IP and Port are correct #24

Closed WolfspiritM closed 3 years ago

WolfspiritM commented 3 years ago

Hi,

I've reset my Lightpanels and had troubles getting the API Token.

The reason is that if the IP and Port are correct, then the Adapter won't start and just shut down cause of a 401 error. I don't even have a chance to click the Button to get the API token.

nanoleaf-lightpanels.0 | 2021-06-08 00:34:46.777 | info | Terminated (NO_ERROR): Without reason
nanoleaf-lightpanels.0 | 2021-06-08 00:34:46.776 | info | terminating
nanoleaf-lightpanels.0 | 2021-06-08 00:34:46.706 | info | Shutting down Nanoleaf adapter 'nanoleaf-lightpanels.0'...
nanoleaf-lightpanels.0 | 2021-06-08 00:34:46.704 | error | Connection to 'xxx:16021' failed with HTTP status 401 (Unauthorized). Permission denied, please check authorization token! Stopping...
nanoleaf-lightpanels.0 | 2021-06-08 00:34:46.666 | info | Connecting to 'xxx:16021'...
nanoleaf-lightpanels.0 | 2021-06-08 00:34:46.659 | info | Nanoleaf adapter 'nanoleaf-lightpanels.0' started.
nanoleaf-lightpanels.0 | 2021-06-08 00:34:46.631 | info | starting. Version 1.2.0 in /opt/iobroker/node_modules/iobroker.nanoleaf-lightpanels, node: v12.21.0, js-controller: 3.3.11

As a workaround I had to change the IP to an IP that is not valid, restart the adapter, change the IP back and then click on the API token button.

daniel-2k commented 3 years ago

Sorry for the late answer. I understood. That's normal, that the adapter throws a 401 error, because the adapter uses the current set authorization token which is not valid anymore because you've reset the device. To obtain a new token set the device into paring mode and then delete the current authorization token in the adapter. Once this field is emptied in the adapter settings you can click on the button again to get a new token. That's the trick.

daniel-2k commented 3 years ago

Sorry. I just tested and got now the real problem. The adapter stops after receiving the 401 error and then you cannot optain a new token (even if you empty the field) because adapter is stopped. And you cannot empty the token field and click save, because save is only possible when a token was entered. That's a bad bahaviour. I'll change this with a new version (thank you for reporting this issue).

As a workaround you can delete the token manually via object explorer. Go to the object explorer and enable system view and go to system -> adapter -> nanoleaf-lightpanels -> your instance and click the edit button. In the "native" area you will find the settings. Remove the authToken (set to "") and save. Then restart your nanoleaf adapter again and you will get the error, that the authtoken is missing. Go to the adapter settings and then you can obtain a new one.

daniel-2k commented 3 years ago

I just released version 1.2.1. Please try again. Should be fixed now.