ebaauw / homebridge-hue

Homebridge plugin for Philips Hue
Apache License 2.0
894 stars 91 forks source link

Unauthorised User (Deconz/Hue) #1146

Closed Jafalex closed 1 year ago

Jafalex commented 1 year ago

Hi, I've recently restored a one year old Raspbian backup to a new SD card after literally breaking mine. I run homebridge on Docker and after updating all containers and all 15+ plugins, everything is working fine. The only issue I have is with homebridge-hue or homebridge-deconz, showing repeated unauthorised users warnings in the logs every 10 seconds or so.

Log Messages

[3/2/2023, 10:06:05 AM] [deCONZ] Conbee Gateway: request 37: GET /
[3/2/2023, 10:06:05 AM] [deCONZ] Conbee Gateway: warning: request 37: /: api error 1: unauthorized user

After pressing "Authenticate app" in Phoscon UI I went through the steps below and although deconz getApiKey returned the expected result, I'm still getting the warning...

bash-5.1# deconz discover
{
  "172.18.0.6:8082": {
    "apiversion": "1.16.0",
    "bridgeid": "ABCDEF",
    "datastoreversion": "93",
    "devicename": "ConBee II",
    "factorynew": false,
    "mac": "xx:xx...xx",
    "modelid": "deCONZ",
    "name": "Conbee Gateway",
    "replacesbridgeid": null,
    "starterkitid": "",
    "swversion": "2.20.1"
  }
}
bash-5.1# export DECONZ_HOST=192.168.10.14:82
bash-5.1#  deconz config
{
  "apiversion": "1.16.0",
  "bridgeid": "ABCDEF",
  "datastoreversion": "93",
  "devicename": "ConBee II",
  "factorynew": false,
  "mac": "xx:xx...xx",
  "modelid": "deCONZ",
  "name": "Conbee Gateway",
  "replacesbridgeid": null,
  "starterkitid": "",
  "swversion": "2.20.1"
}
bash-5.1# deconz getApiKey
"ABCDEFGHI"

I'm still getting the api error 1: unauthorized user in the HB logs...

Thanks a lot for your help!

Note: The ip "172.18.0.6:8082" returned by deconz discover is just the docker container IP, but 192.168.10.14:8082 is the true location of Deconz

ebaauw commented 1 year ago

For Homebridge Hue, you need to edit config.json manually, and update the API key. Homebridge deCONZ should request a new API key when it detects the old one is no longer working, and store that in cachedAccessories.

Jafalex commented 1 year ago

Thanks Erik! As you posted your answer, I was going through removing cached accessories from HB UI, will report back if I got rid of the warning this way. Thanks

ebaauw commented 1 year ago

I don’t recommend messing with cachedAccessories. You can un-expose the gateway through dynamic settings and re-expose it to lose any setting, incl. the API key. Note that doing that will cause HomeKit to see the newly exposed gateway and it’s devices as new accessories, losing any associations to HomeKit rooms, groups, scenes, and automations.

Jafalex commented 1 year ago

Hmm yeah nothing came out of fiddling with cachedAccessories. I'm quite puzzled as to what's going on, I guess the good news is that HomeKit behaves as expected, and all the accessories added in Phoscon seem to be surfaced in HomeKit as expected (although I can see in Eve that they all are duplicated). I still get the Unauthorised User warning through the HB logs...

You can un-expose the gateway through dynamic settings and re-expose it to lose any setting, incl. the API key.

You mean doing this to the Deconz bridge? image

ebaauw commented 1 year ago

You mean doing this to the Deconz bridge?

No, https://github.com/ebaauw/homebridge-deconz/wiki/Dynamic-Configuration

Hmm yeah nothing came out of fiddling with cachedAccessories.

Note that Homebridge Hue predates the introduction of cachedAccessories and doesn’t use it. That why the API key needs to be included manually in config.json.

Jafalex commented 1 year ago

Thanks will read through that. I just realised that when I thought all accessories were surfaced in the Home App via homebridge-deconz, it is also via homebridge-hue. hence the duplication of accessories. Something that wasn't happening prior to restoring the backup.

Note that Homebridge Hue predates the introduction of cachedAccessories and doesn’t use it. That why the API key needs to be included manually in config.json.

I had no idea, thanks.

I'll keep researching the culprit and update the ticket accordingly... Cheers

Jafalex commented 1 year ago

I ended up turning off all resources in the homebridge-hue plugin, nuked homebridge-deconz and lost 20+ accessories. Started fresh with hb-deconz and all is good now. In a way it was long time coming since hb-hue is on its way out anyway.

Will hb-deconz have the capability to expose Philips hue lights in the future, so I can get rid of the Phillips Hue bridge? Or will I always need hb-hue(2) for this?

Thanks for your rapid support as always!

ebaauw commented 1 year ago

If you pair the Hue lights to deCONZ, Homebridge deCONZ exposes these to HomeKit.