Philips Hue Binding not connecting when I press the button on the bridge

Hi! I’m new to openHAB and installed Openhabian version 4.0.2 on a Raspberry Pi 3. This isn’t my first installation as I had used it a while ago just to test it out (Notably, I didn’t run into this problem the first time). I followed the instructions outlined in the Adding Things - Simple page of the Getting started guide to add my Hue Bridge.

After installing the binding, it successfully discovers the Hue Bridge and I can add it as a thing. However, the bridge thing gives the error The application key is not authorized. I tried deleting the application key (It seems to have just filled one in by default, and when I had tried openHAB out the first time, I remember it just being blank) which then gives the error Not authenticated. Press pairing button on the Hue Bridge or set a valid application key in configuration.. Pressing said button, as the tutorial said to do, doesn’t seem to do anything. After a while, a new application key appeared automatically, and the error changed back to The application key is not authorized.

In the logs (I’m viewing them using frontail) I get a warning stating 2023-08-21 05:13:46.946 [WARN ] [.internal.handler.Clip2BridgeHandler] - Cannot update bridge thing 'hue:bridge-api2:001788fffe2c9979' from legacy since handler already initialized. after deleting the application key. When pressing the button on the bridge, nothing changes in the logs. Other than the warning, I’m just getting INFO messages whenever the error message changes.

I’ve also checked, and the IP Address for the bridge does match what it says in the Hue app.

Here’s the code for the Bridge:

UID: hue:bridge-api2:001788fffe2c9979
label: Philips Hue (10.0.0.190)
thingTypeUID: hue:bridge-api2
configuration:
  ipAddress: 10.0.0.190
  applicationKey: (edited to remove, as I should probably keep this hidden?)
  checkMinutes: 60
  useSelfSignedCertificate: true

And here’s the details in the About section of the web panel:

runtimeInfo:
  version: 4.0.2
  buildString: Release Build
locale: en-CA
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 17.0.7
  javaVendor: Raspbian
  osName: Linux
  osVersion: 6.1.21-v7+
  osArchitecture: arm
  availableProcessors: 4
  freeMemory: 79365144
  totalMemory: 195035136
  startLevel: 100
bindings: null
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: true
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: macos
    pixelRatio: 2
    prefersColorScheme: dark
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 8
    language: en-CA
    languages:
      - en-CA
    onLine: true
    platform: MacIntel
  screen:
    width: 1440
    height: 900
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: dark
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15
    (KHTML, like Gecko) Version/17.0 Safari/605.1.15
timestamp: 2023-08-21T03:26:22.232Z

If you had used a ‘legacy’ API v1 Hue Bridge thing in the past, then when you create a new API v2 Bridge thing now, it will copy over the key from the legacy thing. But obviously if the legacy key was bad then it will still be bad.

You contradicted yourself in the same paragraph; “doesn’t seem to do anything” then “After a while, a new application key appeared”.

Hmm. That is unexpected. Can you please try the following command (substitute ‘your-application-key’ and ‘bridge-ip-address’)…

curl --insecure -H "hue-application-key: your-application-key" -X GET "https://bridge-ip-address/clip/v2/resource/light" -v
1 Like

I haven’t ever used the legacy bridge - I was thinking the bridge could still be connected to the old installation on the Hue side of things but I tried factory resetting the hue bridge and reconnecting the bridge thing but I’m still getting the same problem

Ah yeah, that’s my bad.

After running the command, I get

Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 10.0.0.132:8080...
* Connected to openhabian (127.0.0.1) port 8080 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* SSL connection timeout
* Closing connection 0
curl: (28) SSL connection timeout

If you had an"old’ installation then it is a legacy installation. If you create a new API v2 thing with this version of the binding, then it will look for any old/legacy thing and copy the key.

Umm. You must have run it wrong. Can you quote your exact command line? Are you running it from Linux or Windows?

Ah sorry - I run it from the terminal on my Mac (which uses unix like linux does), as running it in openHAB from SSH gave me the error Command not found: curl

The exact quote from the command line is

benmoon@Bens-MBP ~ % curl --insecure -H "hue-application-key: mjVOswWqYbihipoWXr3YG8nmYHX8yjQaeYuGpaTX" -X GET "https://10.0.0.132:8080/clip/v2/resource/light" -v       

and then the result is exactly what I sent before

^
Try single quotes rather than double quotes. Also check the IP address of your Hue bridge – without any port number.

1 Like

Oh I see - I used the openhab IP address instead of the hue one. After running the command this time, I get

Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 10.0.0.190:443...
* Connected to 10.0.0.190 (127.0.0.1) port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: C=NL; O=Philips Hue; CN=001788fffe2c9979
*  start date: Jan  1 00:00:00 2017 GMT
*  expire date: Jan  1 00:00:00 2038 GMT
*  issuer: C=NL; O=Philips Hue; CN=001788fffe2c9979
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* using HTTP/2
* h2 [:method: GET]
* h2 [:scheme: https]
* h2 [:authority: 10.0.0.190]
* h2 [:path: /clip/v2/resource/light]
* h2 [user-agent: curl/8.1.2]
* h2 [accept: */*]
* h2 [hue-application-key: mjVOswWqYbihipoWXr3YG8nmYHX8yjQaeYuGpaTX]
* Using Stream ID: 1 (easy handle 0x12f80ec00)
> GET /clip/v2/resource/light HTTP/2
> Host: 10.0.0.190
> User-Agent: curl/8.1.2
> Accept: */*
> hue-application-key: mjVOswWqYbihipoWXr3YG8nmYHX8yjQaeYuGpaTX
> 
< HTTP/2 200 
< server: nginx
< date: Mon, 21 Aug 2023 16:05:27 GMT
< content-type: application/json
< x-xss-protection: 1; mode=block
< x-frame-options: SAMEORIGIN
< x-content-type-options: nosniff
< content-security-policy: default-src 'self'
< cache-control: no-store
< pragma: no-cache
< referrer-policy: no-referrer
< 
{"errors":[],"data":[{"id":"f144992b-19ac-4475-b64e-1dcb369549e6","id_v1":"/lights/1","owner":{"rid":"dcb0a4d7-798c-4ee2-bb1e-e7af02399c59","rtype":"device"},"metadata":{"name":"Hue color lamp 1","archetype":"ceiling_round"},"identify":{},"on":{"on":true},"dimming":{"brightness":100.0,"min_dim_level":1.0},"dimming_delta":{},"color_temperature":{"mirek":366,"mirek_valid":true,"mirek_schema":{"mirek_minimum":153,"mirek_maximum":500}},"color_temperature_delta":{},"color":{"xy":{"x":0.4574,"y":0.41},"gamut":{"red":{"x":0.6915,"y":0.3083},"green":{"x":0.17,"y":0.7},"blue":{"x":0.1532,"y":0.0475}},"gamut_type":"C"},"dynamics":{"status":"none","status_values":["none","dynamic_palette"],"speed":0.0,"speed_valid":false},"alert":{"action_values":["breathe"]},"signaling":{"signal_values":["no_signal","on_off","on_off_color","alternating"]},"mode":"normal","effects":{"status_values":["no_effect","candle","fire","prism"],"status":"no_effect","effect_values":["no_effect","candle","fire","prism"]},"powerup":{"preset":"safety","configured":true,"on":{"mode":"on","on":{"on":true}},"dimming":{"mode":"dimming","dimming":{"brightness":100.0}},"color":{"mode":"color_temperature","color_temperature":{"mirek":366}}},"type":"light"},{"id":"7b2a087f-8954-437d-ba35-66dd970bfbf5","id_v1":"/lights/2","owner":{"rid":"65c26811-2192-4a30-bf46-09cd0906d732","rtype":"device"},"metadata":{"name":"Hue color lamp 2","archetype":"sultan_bulb"},"identify":{},"on":{"on":false},"dimming":{"brightness":0.39,"min_dim_level":1.0},"dimming_delta":{},"color_temperature":{"mirek":366,"mirek_valid":true,"mirek_schema":{"mirek_minimum":153,"mirek_maximum":500}},"color_temperature_delta":{},"color":{"xy":{"x":0.4573,"y":0.41},"gamut":{"red":{"x":0.6915,"y":0.3083},"green":{"x":0.17,"y":0.7},"blue":{"x":0.1532,"y":0.0475}},"gamut_type":"C"},"dynamics":{"status":"none","status_values":["none","dynamic_palette"],"speed":0.0,"speed_valid":false},"alert":{"action_values":["breathe"]},"signaling":{"signal_values":["no_signal","on_off","on_off_color","alternating"]},"mode":"normal","effects":{"status_values":["no_effect","candle","fire","prism"],"status":"no_effect","effect_values":["no_effect","candle","fire","prism"]},"powerup":{"preset":"safety","configured":true,"on":{"mode":"on","on":{"on":true}},"dimming":{"mode":"dimming","dimming":{"brightness":100.0}},"color":{"mode":"color_temperature","color_temperature":{"mirek":366}}},"type":"light"},{"id":"a34df6aa-08e4-482e-adb6-b6be4afd6898","id_v1":"/lights/3","owner":{"rid":"7b27cd67-1d84-4317-ae5f-3703f543d699","rtype":"device"},"metadata":{"name":"Hue color lamp 3","archetype":"recessed_ceiling"},"identify":{},"on":{"on":true},"dimming":{"brightness":100.0,"min_dim_level":2.0},"dimming_delta":{},"color_temperature":{"mirek":366,"mirek_valid":true,"mirek_schema":{"mirek_minimum":153,"mirek_maximum":500}},"color_temperature_delta":{},"color":{"xy":{"x":0.4575,"y":0.4101},"gamut":{"red":{"x":0.675,"y":0.322},"green":{"x":0.409,"y":0.518},"blue":{"x":0.167,"y":0.04}},"gamut_type":"B"},"dynamics":{"status":"none","status_values":["none","dynamic_palette"],"speed":0.0,"speed_valid":false},"alert":{"action_values":["breathe"]},"signaling":{"signal_values":["no_signal","on_off"]},"mode":"normal","powerup":{"preset":"safety","configured":true,"on":{"mode":"on","on":{"on":true}},"dimming":{"mode":"dimming","dimming":{"brightness":100.0}},"color":{"mode":"color_temperature","color_temperature":{"mirek":366}}},"type":"light"},{"id":"d88c1f92-4478-4ca5-ba2f-a8c9a79f2803","id_v1":"/lights/4","owner":{"rid":"356a437d-bf9d-4291-8c17-edd1aabc206c","rtype":"device"},"metadata":{"name":"Hue color lamp 4","archetype":"table_wash"},"identify":{},"on":{"on":true},"dimming":{"brightness":100.0,"min_dim_level":1.0},"dimming_delta":{},"color_temperature":{"mirek":406,"mirek_valid":true,"mirek_schema":{"mirek_minimum":153,"mirek_maximum":500}},"color_temperature_delta":{},"color":{"xy":{"x":0.4803,"y":0.414},"gamut":{"red":{"x":0.6915,"y":0.3083},"green":{"x":0.17,"y":0.7},"blue":{"x":0.1532,"y":0.0475}},"gamut_type":"C"},"dynamics":{"status":"none","status_values":["none","dynamic_palette"],"speed":0.0,"speed_valid":false},"alert":{"action_values":["breathe"]},"signaling":{"signal_values":["no_signal","on_off"]},"mode":"normal","powerup":{"preset":"safety","configured":true,"on":{"mode":"on","on":{"on":true}},"dimming":{"mode":"dimming","dimming":{"brightness":100.0}},"color":{"mode":"color_temperature","color_temperature":{"mirek":366}}},"type":"light"},{"id":"2465abbd-b008-4439-9221-469084a48f88","id_v1":"/lights/5","owner":{"rid":"7e0cb336-ef70-4586-8841-96503f8d0719","rtype":"device"},"metadata":{"name":"Hue color lamp 5","archetype":"sultan_bulb"},"identify":{},"on":{"on":false},"dimming":{"brightness":0.39,"min_dim_level":1.0},"dimming_delta":{},"color_temperature":{"mirek":366,"mirek_valid":true,"mirek_schema":{"mirek_minimum":153,"mirek_maximum":500}},"color_temperature_delta":{},"color":{"xy":{"x":0.4573,"y":0.41},"gamut":{"red":{"x":0.6915,"y":0.3083},"green":{"x":0.17,"y":0.7},"blue":{"x":0.1532,"y":0.0475}},"gamut_type":"C"},"dynamics":{"status":"none","status_values":["none","dynamic_palette"],"speed":0.0,"speed_valid":false},"alert":{"action_values":["breathe"]},"signaling":{"signal_values":["no_signal","on_off","on_off_color","alternating"]},"mode":"normal","effects":{"status_values":["no_effect","candle","fire","prism"],"status":"no_effect","effect_values":["no_effect","candle","fire","prism"]},"powerup":{"preset":"safety","configured":true,"on":{"mode":"on","on":{"on":true}},"dimming":{"mode":"dimming","dimming":{"brightness":100.0}},"color":{"mode":"color_temperature","color_temperature":{"mirek":366}}},"type":"light"}]}
* Connection #0 to host 10.0.0.190 left intact

hue-application-key in the output does match the application key set in openHAB

The curl response is HTTP 200 OK and the Hue bridge server returned content has "errors":[] … which means your application key is perfectly Ok. So you just need to edit your Hue bridge thing to have the exact same key.

As I’ve said in the last post, the application key does match exactly. I just double checked to make sure (I copied from the output directly to the thing) and I’m still getting the same error.

Edit: Actually nevermind… not sure what did it but I tried clicking save a few times and after a while it appeared as online. Thanks for your help!

1 Like

Is it (wrongly) wrapped it in quote marks? And/or does it have excess whitespace at start or end?

This worked for me. click Save in the GUI.

1 Like