ebaauw / homebridge-deconz

Homebridge plugin for deCONZ
Apache License 2.0
135 stars 7 forks source link

[deCONZ] Phoscon-GW: warning: #22

Closed steini72 closed 2 years ago

steini72 commented 2 years ago

05FB9B6CAE: potentially stale api key: {"create date":"2022-02-22T16:22:22","last use date":"2022-02-22T16:53:32","name":"homebridge-deconz#dockerpi"}
is this normal, or a config error

ebaauw commented 2 years ago

There’s another API key with the same name in the deCONZ gateway. This could be valid if you run multiple instances of Homebridge deCONZ on the same host, but most likely, you reset Homebridge or removed the cached accessories, without un-exposing the gateway first.

steini72 commented 2 years ago

Everything is freshly installed, Homebridge is running in Docker (basement), Deconz on an extra Rasperry Pi.

kikher commented 2 years ago

Hello, I have the same problem, I have tried to use the api, but I do not understand how to use it and it always gives me an error. Is there any way you can explain to us how to remove the old api?

kikher commented 2 years ago

hello again, I thought that deleting and reinstalling the problem would solve it and I have found that I have tripled it. I need help with the command for terminal to remove the api that I have left over. I can't figure out how to use the api. I am very inexperienced in this API and I would appreciate a tutorial please. Thank you very much in advance

Captura de pantalla 2022-02-24 a las 23 14 37

.

steini72 commented 2 years ago

the same thing happened to me, [2/24/2022, 10:52:50 PM] [deCONZ] Phoscon-GW: warning: 05FB9B6CAE: potentially stale api key: {"create date":"2022-02-22T16:22:22","last use date":"2022-02-22T16:53:32","name":"homebridge-deconz#dockerpi"} [2/24/2022, 10:52:50 PM] [deCONZ] Phoscon-GW: warning: 573787698A: potentially stale api key: {"create date":"2022-02-22T18:26:09","last use date":"2022-02-24T20:38:21","name":"homebridge-deconz#dockerpi"} [2/24/2022, 10:52:50 PM] [deCONZ] Phoscon-GW: warning: 927A80A6A5: potentially stale api key: {"create date":"2022-02-24T20:41:38","last use date":"2022-02-24T20:52:51","name":"homebridge-deconz#dockerpi"} otherwise the plugin runs great

ebaauw commented 2 years ago

I am very inexperienced in this API and I would appreciate a tutorial please.

Please folks, I am not your personal help desk, nor your teacher. If you want to learn about the REST API provided by deCONZ, please see the documentation over at their GitHub repository.

Phoscon-GW: warning: 05FB9B6CAE: potentially stale api key

Homebridge deCONZ needs an API key to communicate with deCONZ over the API. deCONZ stores the keys it has given out; Homebridge deCONZ stores the key it has obtained in cachedAccessories. If you delete the gateway accessory from there, or if you bluntly re-install Homebridge, Homebridge deCONZ no longer knows the API key, and needs to obtain a new API key. However, deCONZ still has the old key.

To prevent this from happening, make sure to deselect Expose on the Gateway Settings, before deleting (the gateway accessory from) cachedAccessories, so Homebridge deCONZ removes the API key from deCONZ.

deCONZ stores API keys under application name and hostname (that's the name attribute in the warning message), as specified by the (new) client when requesting an API key. Homebridge deCONZ uses homebridge-deconz for application name (duh), and the hostname of the system it's running on as hostname. If you were to run multiple instances of Homebridge deCONZ on the same system, their corresponding API keys would have the same name. Homebridge deCONZ doesn't know whether the other API key with the same name is legit, because it belongs to another Homebridge deCONZ instance, or stale, left behind by deleting the accessory. Therefore Homebridge deCONZ cannot bluntly delete any other API key with the same name. Hence it issues the warning.

If the API key is indeed stale, you could either ignore the warning message, or delete it using the API. The API exposes the API keys under /config/whitelist. I prefer to use the deconz command-line utility bundled with Homebridge deCONZ to interact with the API, but any REST client like Postman or even curl would do.

Using deconz, you simply issue deconz delete /config/whitelist/api-key from the command line. Note that unless deconz is run on the same system as deCONZ, and deCONZ is running on port 80, you need to specify the hostname and port to deconz using -H. Before you can use deconz, it needs to obtain an API key, just like any API client. Issue deconz -h for help.

kikher commented 2 years ago

Thank you very much, it is true that you are not our personal help desk. But given the problem and the lack of understanding of the api, we need to ask you.

Sorry for the consecutive messages but I reiterate that for people with little programming experience the api are complicated and even if I do deconz --help for me that help is little explained

Thanks for your extensive answer, as I understand that someone else will have this problem at some point I have managed to remove the old api. Removing the old api, the other connection problems with accessories were also eliminated

I have used this command line deconz -H localhost:4530 delete /config/whitelist/number of api in the warning

steini72 commented 2 years ago

Thank you very much

ghost commented 2 years ago

Please folks, I am not your personal help desk, nor your teacher. If you want to learn about the REST API provided by deCONZ, please see the documentation over at their GitHub repository.

That's a shameful answer, to be honest! I'm grateful for your work, but you should rise above that kind of comment. I do not know, but I'm probably not the only one who credits your work, financially ... I'm well aware that, your time is not commensurate with what you receive. I'm not stupid, but your transition from HUE to deconz is undocumented and extremely messy. So it's not okay to ask questions? You launch something, and prompt, warn against HUE being deleted as a plugin. I would like to contribute to the development, but not with your premise.

jakanjakan commented 2 years ago

For newer people running in to this wanting to learn; here's deCONZ API documentation: https://dresden-elektronik.github.io/deconz-rest-doc/endpoints/configuration/#delete-api-key

It helped me in this case. Appreciate your work, ebaauw.