node-red-contrib-huemagic icon indicating copy to clipboard operation
node-red-contrib-huemagic copied to clipboard

Error requesting from the bridge

Open ralfhille opened this issue 2 years ago • 77 comments

After the update I get the following entries in the node-red log:

22 Mar 10:00:29 - [info] [hue-bridge:Hue Wohnung] Error requesting info from the bridge. Reconnect in some secs. undefined
22 Mar 10:00:29 - [info] [hue-bridge:Hue Wohnung] Initializing the bridge (192.168.178.15)…
22 Mar 10:00:30 - [info] [hue-bridge:Hue Wohnung] Connected to bridge
22 Mar 10:00:30 - [info] [hue-bridge:Hue Wohnung] Processing bridge resources…
22 Mar 10:00:30 - [info] [hue-bridge:Hue Wohnung] Initial emit of resource states…
22 Mar 10:00:31 - [info] [hue-bridge:Hue Wohnung] Keeping nodes up-to-date…
22 Mar 10:00:31 - [info] [hue-bridge:Hue Wohnung] Subscribing to bridge events…
22 Mar 10:00:51 - [info] [hue-bridge:Hue Wohnung] Error requesting info from the bridge. Reconnect in some secs. undefined
22 Mar 10:00:51 - [info] [hue-bridge:Hue Wohnung] Initializing the bridge (192.168.178.15)…
22 Mar 10:00:51 - [info] [hue-bridge:Hue Wohnung] Connected to bridge
22 Mar 10:00:51 - [info] [hue-bridge:Hue Wohnung] Processing bridge resources…
22 Mar 10:00:51 - [info] [hue-bridge:Hue Wohnung] Initial emit of resource states…
22 Mar 10:00:52 - [info] [hue-bridge:Hue Wohnung] Keeping nodes up-to-date…
22 Mar 10:00:52 - [info] [hue-bridge:Hue Wohnung] Subscribing to bridge events…
22 Mar 10:01:01 - [info] [hue-bridge:Hue Wohnung] Error requesting info from the bridge. Reconnect in some secs. undefined
HueMagic: Connection to bridge lost. Trying to reconnect again in 30 seconds… Event {
  type: 'error',
  status: 503,
  message: 'Service Temporarily Unavailable'
}

HUE Bridge Version BSB002 / 1.50.1950111030 Node Red Version 2.2.0

All scenes and/or lamps can only be switched sporadically.

Is it now a mistake or did I go about it the wrong way?

The previous version with the workaround worked stable for me. Whereby I use exclusively the switching of scenes and groups.

ralfhille avatar Mar 22 '22 09:03 ralfhille

same here on 4.2.1 but just installed hue-magic 4.2.2 testing now

Luke050 avatar Mar 23 '22 10:03 Luke050

I am seeing same issue with hue-magic 4.2.2

tocDK avatar Mar 24 '22 12:03 tocDK

Hi guys, what versions of node and npm have you installed

ptweety avatar Mar 24 '22 12:03 ptweety

hi i have npm 6.14.16 Node RED v2.2.0

but from yesterday after update to 4.2.2 i cant see any request problem in my logs

Luke050 avatar Mar 24 '22 13:03 Luke050

Node RED: 2.2.2 Hue magic: 4.2.2 And it is installed through: https://github.com/hassio-addons/addon-node-red/tree/v11.1.1

I still see it after 4.2.2

tocDK avatar Mar 24 '22 14:03 tocDK

@tocDK: so, you don't know about your npm or node version?

ptweety avatar Mar 24 '22 14:03 ptweety

@ptweety still new to HomeAssistant. Just trying to figure out where I can see that

tocDK avatar Mar 24 '22 14:03 tocDK

Hm, maybe you are using a docker for Node-Red:

https://github.com/hassio-addons/addon-node-red/blob/278e54c468b64e42804fc232317d72741a2847bf/node-red/Dockerfile#L25-L32

&& apk add --no-cache \
    git=2.34.1-r0 \
    nginx=1.20.2-r0 \
    nodejs=16.14.0-r0 \
    npm=8.1.3-r0 \
    openssh-client=8.8_p1-r1 \
    patch=2.7.6-r7 \
    python3=3.9.7-r4 \

ptweety avatar Mar 24 '22 15:03 ptweety

Same problem here Node-red running on docker, Node-red ver v2.2.2, huemagic ver 4.2.2, node ver 14.18.2, npm ver 6.14.15 Hue Bridge is Version BSB002 / 1.50.1950111030

davidcreager avatar Mar 24 '22 18:03 davidcreager

Hi again,

I've tried to reproduce the behavior on my side, but wasn't able to ...

At least the first line in your logs that reads:

- [info] [hue-bridge:Hue Wohnung] Error requesting info from the bridge. Reconnect in some secs. undefined

showed, that there is no actual response object coming back from the api call to the bridge. This little undefined should actually be the detailed error from the api call.

You can try to apply this patch #349 and see, if you get more information in your logs.

If someone of you is able to spin up a local Node-Red instance with node-red-contrib-huemagic installed and generate some more debug logs that might also be helpful.

ptweety avatar Mar 24 '22 20:03 ptweety

Hi all,

i have the Versions:

  • nodejs 16.14.2
  • npm 8.5.0
  • node red 2.2.0
  • hue node 4.2.2
  • HUE Bridge Version BSB002 / 1.50.1950111030

After the update hue node 4.2.2 (5 hours ago) the log is clear, the group / light node works in universal mode fine.

Also to all again many thanks for the corrections and the associated effort. If there are still problems in the next 24 hours, I will send the debug log.

ralfhille avatar Mar 24 '22 21:03 ralfhille

So Very weird, I applied the pull request to change the catch and now seems to be working much better , No errors thrown

I'll leave it running and see how it goes

davidcreager avatar Mar 24 '22 23:03 davidcreager

I am also having this issue: https://github.com/Foddy/node-red-contrib-huemagic/issues/345

Maybe this is related

tocDK avatar Mar 25 '22 05:03 tocDK

So Very weird, I applied the pull request to change the catch and now seems to be working much better , No errors thrown

I'll leave it running and see how it goes

8 hours later I get the same problem, with no difference in the log (ie the messages are the same, the change to api.js does not appear to have changed this)

`25 Mar 08:10:29 - [warn] [yeelight-config:192.168.1.115:55443] [Yeelight-Config][onError][Error] Error: read ECONNRESET retrying

25 Mar 08:11:46 - [info] [hue-bridge:Philips hue] Error requesting info from the bridge. Reconnect in some secs. undefined

25 Mar 08:11:46 - [info] [hue-bridge:Philips hue] Initializing the bridge (192.168.1.147)… 25 Mar 08:11:46 - [info] [hue-bridge:Philips hue] Connected to bridge 25 Mar 08:11:47 - [info] [hue-bridge:Philips hue] Processing bridge resources… 25 Mar 08:11:47 - [info] [hue-bridge:Philips hue] Initial emit of resource states… 25 Mar 08:11:47 - [info] [hue-bridge:Philips hue] Keeping nodes up-to-date… 25 Mar 08:11:47 - [info] [hue-bridge:Philips hue] Subscribing to bridge events… 25 Mar 08:13:59 - [info] [hue-bridge:Philips hue] Error requesting info from the bridge. Reconnect in some secs. undefined`

davidcreager avatar Mar 25 '22 09:03 davidcreager

Ok I am trying the suggestion in https://github.com/Foddy/node-red-contrib-huemagic/issues/354#issue-1180080990

Will report back

davidcreager avatar Mar 25 '22 10:03 davidcreager

Hi again,

I still have a problem with the hue group node.

Unfortunately, so far I can not see how to reproduce the behavior. In the following scenarios I have the problem with the hue group node:

Hue scenes are switched automatically by sensors or manually a push button via a hue scene node in universal mode.

If the corresponding Hue scene must/should be switched off, this is done via a hue group. Again, the trigger is a sensor or a switch.

The corresponding group ID is passed as a string in msg.topic together with the settings.

The problem is that the group is not always switched off.

Attached is a message object for the hue group node and an excerpt from the log

{"topic":"c6fc75e1-7db4-4beb-ab6b-77c53b506f31","payload":
{"on":false,"hueKey":"Esszimmer"},"_msgid":"36bc12eec7fbd1d4"}
25 Mar 03:03:30 - [error] [hue-group:7e2ecf7fbe2e8059] Keine Gruppen-ID definiert.
25 Mar 05:43:20 - [error] [hue-group:7e2ecf7fbe2e8059] Keine Gruppen-ID definiert.
25 Mar 08:30:58 - [error] [hue-group:7e2ecf7fbe2e8059] Keine Gruppen-ID definiert.

The last log entry should have turned off the group by a sensor. But it did not happen.

ralfhille avatar Mar 25 '22 11:03 ralfhille

Hi again,

one more item.

I know that there is a property in the msg object in the payload that is not meant for the HUE. I just sent the same msg directly to the bridge with a http node.

I get the following payload back:

{
  "topic": "c6fc75e1-7db4-4beb-ab6b-77c53b506f31",
  "payload": [
    {
      **"error": {
        "type": 6,
        "address": "/groups/c6fc75e1-7db4-4beb-ab6b-77c53b506f31/action/hueKey",
        "description": "parameter, hueKey, not available"
      }**
    },
    {
      "success": {
        "/groups/c6fc75e1-7db4-4beb-ab6b-77c53b506f31/action/on": false
      }
    }
  ],
  "_msgid": "72c25566030b5da5",
  "url": "https://192.168.178.15/api/...xyz.../groups/c6fc75e1-7db4-4beb-ab6b-77c53b506f31/action",
  "headers": {
    "server": "nginx",
    "date": "Fri, 25 Mar 2022 11:40:15 GMT",
    "content-type": "application/json",
    "transfer-encoding": "chunked",
    "connection": "close",
    "cache-control": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-store",
    "pragma": "no-cache, no-cache",
    "expires": "Mon, 1 Aug 2011 09:00:00 GMT",
    "access-control-max-age": "3600",
    "access-control-allow-origin": "*",
    "access-control-allow-credentials": "true",
    "access-control-allow-methods": "POST, GET, OPTIONS, PUT, DELETE, HEAD",
    "access-control-allow-headers": "Content-Type",
    "x-xss-protection": "1; mode=block",
    "x-frame-options": "SAMEORIGIN",
    "x-content-type-options": "nosniff",
    "content-security-policy": "default-src 'self'",
    "referrer-policy": "no-referrer"
  },
  "method": "Put",
  "statusCode": 200,
  "certificate": {},
  "certificateExpires": null
}

In the response there are two objects in the payload, one with the error unknown ... and in the second object a success.

The light was also switched off.

Is the unknown property possibly the culprit?

ralfhille avatar Mar 25 '22 11:03 ralfhille

Did not work......sigh

I have a test environment running on docker ....if anyone wants to suggest adding debug statements, I'd be happy to try it.....seems to be fairly intermittent though so will take time to actually get results

davidcreager avatar Mar 25 '22 13:03 davidcreager

Did not work......sigh

I have a test environment running on docker ....if anyone wants to suggest adding debug statements, I'd be happy to try it.....seems to be fairly intermittent though so will take time to actually get results

@davidcreager i have all the same issues and it drives me crazy. I tried to send http requests, but I can't get it running. I used the Rest App in iOS to discover the key, but I didn't got the header in node red running.

Can you share a flow to me that I can use http requests, please? It should be the function node for the header and the http request one, right?

Greetings Andreas

andesse avatar Mar 25 '22 21:03 andesse

Hi again,

after a certain time the bridge does not run stable anymore and log entries with the already known entries occur more and more often.

In my case, this happens after the hue group node has often turned off some groups (in my case only rooms). With under then also the group node seems to hang or it is turned off nothing more.

However, there are no problems with the hue scene node. I have then tried the way via a direct http connection via API v1 and API v2.

I noticed the following points for which I have no explanation:

First I started with an http request for the HUE API V1

REQUEST FOR ROOM ESSZIMMER {"_msgid":"af126533c7d153be","topic":"c6fc75e1-7db4-4beb-ab6b-77c53b506f31","payload":{"on":false},"url":"https://192.168.178.15/api/<username>/groups/c6fc75e1-7db4-4beb-ab6b-77c53b506f31/action","headers":{"Content-Type":"application/json","Accept":"application/json"},"method":"Put"}

RESPONSE OK {"_msgid":"af126533c7d153be","topic":"c6fc75e1-7db4-4beb-ab6b-77c53b506f31","payload":[{"success":{"/groups/c6fc75e1-7db4-4beb-ab6b-77c53b506f31/action/on":false}}],"url":"https://192.168.178.15/api//groups/c6fc75e1-7db4-4beb-ab6b-77c53b506f31/action","headers":{"server":"nginx","date":"Fri, 25 Mar 2022 21:12:07 GMT","content-type":"application/json","transfer-encoding":"chunked","connection":"close","cache-control":"no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-store","pragma":"no-cache, no-cache","expires":"Mon, 1 Aug 2011 09:00:00 GMT","access-control-max-age":"3600","access-control-allow-origin":"*","access-control-allow-credentials":"true","access-control-allow-methods":"POST, GET, OPTIONS, PUT, DELETE, HEAD","access-control-allow-headers":"Content-Type","x-xss-protection":"1; mode=block","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","content-security-policy":"default-src 'self'","referrer-policy":"no-referrer"},"method":"Put","statusCode":200,"certificate":{},"certificateExpires":null}

REQUEST FOR ROOM KUECHE {"_msgid":"a7bedb483108878d","topic":"4747c001-1fbb-46ee-b8a4-461e909401ff","payload":"{"on":false}","url":"https://192.168.178.15/api//groups/4747c001-1fbb-46ee-b8a4-461e909401ff/action","headers":{"Content-Type":"application/json","Accept":"application/json"},"method":"Put"}

RESPONSE ERROR - WHY {"_msgid":"a7bedb483108878d","topic":"4747c001-1fbb-46ee-b8a4-461e909401ff","payload":[{"error":{"type":3,"address":"/groups/4747c001-1fbb-46ee-b8a4-461e909401ff/action","description":"resource, /groups/4747c001-1fbb-46ee-b8a4-461e909401ff/action, not available"}}],"url":"https://192.168.178.15/api/<username>/groups/4747c001-1fbb-46ee-b8a4-461e909401ff/action","headers":{"server":"nginx","date":"Fri, 25 Mar 2022 21:19:53 GMT","content-type":"application/json","transfer-encoding":"chunked","connection":"close","cache-control":"no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-store","pragma":"no-cache, no-cache","expires":"Mon, 1 Aug 2011 09:00:00 GMT","access-control-max-age":"3600","access-control-allow-origin":"*","access-control-allow-credentials":"true","access-control-allow-methods":"POST, GET, OPTIONS, PUT, DELETE, HEAD","access-control-allow-headers":"Content-Type","x-xss-protection":"1; mode=block","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","content-security-policy":"default-src 'self'","referrer-policy":"no-referrer"},"method":"Put","statusCode":200,"certificate":{},"certificateExpires":null}

So far I had used the room id for the request. This did not work for the kitchen room.

So I tried the id_v1.

REQUEST FOR ROOM KUECHE {"_msgid":"c1e8ba3b21dbb18b","topic":"10","payload":"{\"on\":false}","url":"https://192.168.178.15/api/<username>/groups/10/action","headers":{"Content-Type":"application/json","Accept":"application/json"},"method":"Put"}

REPONSE OK.

In fact, I have no idea what value is expected from the Bridge API V1.

I tested this for all other rooms. Except for the kitchen, I was able to use the id and the id_v1 for all other rooms. I started with the id because it is also displayed in the hue group node.

But the error for the kitchen room "resource /groups/4747c001-1fbb-46ee-b8a4-461e909401ff/action, not available" is not clear to me. Which value / ID is used in the HUE group node ?

25 Mar 22:27:30 - [info] [hue-bridge:Hue Wohnung] Subscribing to bridge events…
25 Mar 22:28:31 - [info] [hue-bridge:Hue Wohnung] Error requesting info from the bridge. Reconnect in some secs. undefined
25 Mar 22:28:31 - [info] [hue-bridge:Hue Wohnung] Initializing the bridge (192.168.178.15)…
25 Mar 22:28:31 - [info] [hue-bridge:Hue Wohnung] Connected to bridge
25 Mar 22:28:32 - [info] [hue-bridge:Hue Wohnung] Processing bridge resources…
25 Mar 22:28:32 - [info] [hue-bridge:Hue Wohnung] Initial emit of resource states…
25 Mar 22:28:32 - [info] [hue-bridge:Hue Wohnung] Keeping nodes up-to-date…
25 Mar 22:28:32 - [info] [hue-bridge:Hue Wohnung] Subscribing to bridge events…
25 Mar 22:33:47 - [info] [hue-bridge:Hue Wohnung] Error requesting info from the bridge. Reconnect in some secs. undefined
25 Mar 22:33:47 - [info] [hue-bridge:Hue Wohnung] Initializing the bridge (192.168.178.15)…
25 Mar 22:33:47 - [info] [hue-bridge:Hue Wohnung] Connected to bridge
25 Mar 22:33:48 - [info] [hue-bridge:Hue Wohnung] Processing bridge resources…
25 Mar 22:33:48 - [info] [hue-bridge:Hue Wohnung] Initial emit of resource states…
25 Mar 22:33:49 - [info] [hue-bridge:Hue Wohnung] Keeping nodes up-to-date…
25 Mar 22:33:49 - [info] [hue-bridge:Hue Wohnung] Subscribing to bridge events…
25 Mar 22:35:00 - [info] [hue-bridge:Hue Wohnung] Error requesting info from the bridge. Reconnect in some secs. undefined
25 Mar 22:35:00 - [info] [hue-bridge:Hue Wohnung] Initializing the bridge (192.168.178.15)…
25 Mar 22:35:00 - [info] [hue-bridge:Hue Wohnung] Connected to bridge
25 Mar 22:35:00 - [info] [hue-bridge:Hue Wohnung] Processing bridge resources…
25 Mar 22:35:00 - [info] [hue-bridge:Hue Wohnung] Initial emit of resource states…
25 Mar 22:35:01 - [info] [hue-bridge:Hue Wohnung] Keeping nodes up-to-date…
25 Mar 22:35:01 - [info] [hue-bridge:Hue Wohnung] Subscribing to bridge events…
25 Mar 22:36:12 - [info] [hue-bridge:Hue Wohnung] Error requesting info from the bridge. Reconnect in some secs. undefined

Last but not least I tried the http request with the hue api v2.

Here everything went basically very well, after a restart of the Hue bridge there were no further problems. After that also the strange LOG entries were there again.

REQUEST V2 {"_msgid":"0fc096e6bc785239","endpoint":"grouped_light","topic":"51932247-09b0-47cb-8bf8-ba93666bb30d","payload":{"on":{"on":false}},"verb":"put","url":"https://192.168.178.15/clip/v2/resource/grouped_light/51932247-09b0-47cb-8bf8-ba93666bb30d","headers":{"hue-application-key":"","Content-Type":"application/json","Accept":"application/json","ContentLength":19},"method":"put"}

RESPONSE OK

In another response I had two entries in the payload. This was preceded by a change of different scenes in the same room. In the last scene also not all lamps were used

{
	"data": [
		{
			"rid": "51932247-09b0-47cb-8bf8-ba93666bb30d",
			"rtype": "grouped_light"
		}
	],
	"errors": [
		{
			"description": "device (grouped_light) is \"soft off\", command (.on) may not have effect"
		}
	]
}

Unfortunately, I have no experience with the HUE API. but already the change from v1 to v2 seems very complex to me with HUE.

Furthermore, I have that. Problem only with the hue group node. It feels like the HUE Bridge is not coping properly with the id for the v1.

Dahe would be very interested in what id the hue node uses.

Have a nice evening

ralfhille avatar Mar 25 '22 21:03 ralfhille

Did not work......sigh I have a test environment running on docker ....if anyone wants to suggest adding debug statements, I'd be happy to try it.....seems to be fairly intermittent though so will take time to actually get results

@davidcreager i have all the same issues and it drives me crazy. I tried to send http requests, but I can't get it running. I used the Rest App in iOS to discover the key, but I didn't got the header in node red running.

Can you share a flow to me that I can use http requests, please? It should be the function node for the header and the http request one, right?

Greetings Andreas

Hi,

this is my flow to test some http request to hue api v1 and hie api v2. You must enter a vild user in the function node for the hue bridge. Best is copy the user from the hue config node.

[{"id":"071bd578da1b2818","type":"tab","label":"HUE Test","disabled":false,"info":"","env":[]},{"id":"5680d99b769430de","type":"inject","z":"071bd578da1b2818","name":"Get all lights","props":[{"p":"endpoint","v":"/light","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":300,"wires":[["d87ac955771c69ed"]]},{"id":"eb46e63d124f2815","type":"debug","z":"071bd578da1b2818","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1230,"y":620,"wires":[]},{"id":"57f80eec5c1f85e6","type":"https-node","z":"071bd578da1b2818","name":"HTTPS HUE API","method":"use","ret":"obj","url":"","authorized":false,"agent":true,"x":1020,"y":620,"wires":[["eb46e63d124f2815"]]},{"id":"3017d4ba999a868c","type":"inject","z":"071bd578da1b2818","name":"Get all scenes","props":[{"p":"endpoint","v":"scene","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":360,"wires":[["d87ac955771c69ed"]]},{"id":"b886b3fd8b3a579e","type":"comment","z":"071bd578da1b2818","name":"HUE API V2","info":"","x":170,"y":180,"wires":[]},{"id":"33b85f79fd3b1d8f","type":"debug","z":"071bd578da1b2818","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":1240,"wires":[]},{"id":"e9af9922f8038189","type":"https-node","z":"071bd578da1b2818","name":"HTTPS HUE API","method":"use","ret":"obj","url":"","authorized":false,"agent":true,"x":900,"y":1240,"wires":[["33b85f79fd3b1d8f"]]},{"id":"5a54535cb4395d90","type":"inject","z":"071bd578da1b2818","name":"Esszimer OFF","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"6","payload":"{\"on\":false}","payloadType":"json","x":150,"y":1220,"wires":[["1c90ae17ba382974"]]},{"id":"1c90ae17ba382974","type":"function","z":"071bd578da1b2818","name":"HUE API V1 - PUT Group ","func":"// you can copy the user name from the hue config node\n\nvar user = \"\";\n\nvar url = \"https://192.168.178.15/api/\" + user;\n\nmsg.url = url + \"/groups/\" + msg.topic + \"/action\";\n\nmsg.headers = {};\n\nmsg.headers['Content-Type'] = 'application/json';\nmsg.headers['Accept'] = 'application/json';\n\nmsg.method = \"Put\";\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":1240,"wires":[["e9af9922f8038189","8dd827ad98e8c9f7"]]},{"id":"6966e9d5342a22dd","type":"comment","z":"071bd578da1b2818","name":"HUE API V1 - light state","info":"Es gibt für lights keinen toggle endpoint","x":160,"y":1160,"wires":[]},{"id":"8b4a20060d483cbb","type":"inject","z":"071bd578da1b2818","name":"Get all rooms","props":[{"p":"endpoint","v":"room","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":420,"wires":[["d87ac955771c69ed"]]},{"id":"f9cb3f7876b0b860","type":"inject","z":"071bd578da1b2818","name":"Get all zones","props":[{"p":"endpoint","v":"zone","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":480,"wires":[["d87ac955771c69ed"]]},{"id":"c55eb562378dfeb5","type":"inject","z":"071bd578da1b2818","name":"Schlafzimmer ON","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"70a3cdeb-07f9-49f3-9b28-6abd8a789ca0","payload":"{\"on\":{\"on\":true}}","payloadType":"json","x":160,"y":600,"wires":[["d87ac955771c69ed"]]},{"id":"d87ac955771c69ed","type":"function","z":"071bd578da1b2818","name":"HUE API V2 - HTTP Request","func":"\n// you can copy the user from the hue config node\nvar user = \"\";\n\n\nif(msg.endpoint === undefined)\n msg.url = \"https://192.168.178.15/clip/v2/resource\";\nelse if(msg.topic === undefined)\n msg.url = \"https://192.168.178.15/clip/v2/resource/\" + msg.endpoint;\nelse\n msg.url = \"https://192.168.178.15/clip/v2/resource/\" + msg.endpoint + \"/\" + msg.topic;\n\n\nmsg.headers = {};\n\nmsg.headers['hue-application-key'] = user;\nmsg.headers['Content-Type'] = 'application/json';\nmsg.headers['Accept'] = 'application/json';\n\nif(msg.payload != undefined)\n msg.headers['ContentLength'] = JSON.stringify(msg.payload).length;\n\nif(msg.verb === undefined)\n msg.method = \"get\";\nelse\n msg.method = msg.verb;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":620,"wires":[["57f80eec5c1f85e6","d592b921aa30ca60"]]},{"id":"d208f4af7c83b617","type":"inject","z":"071bd578da1b2818","name":"Get All","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":240,"wires":[["d87ac955771c69ed"]]},{"id":"5f2c8ebecd931d72","type":"inject","z":"071bd578da1b2818","name":"Küche Off","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"10","payload":"{\"on\":false}","payloadType":"str","x":160,"y":1300,"wires":[["1c90ae17ba382974"]]},{"id":"80e0fff54ebfe3c6","type":"inject","z":"071bd578da1b2818","name":"Schlafzimmer OFF","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"70a3cdeb-07f9-49f3-9b28-6abd8a789ca0","payload":"{\"on\":{\"on\":false}}","payloadType":"json","x":150,"y":640,"wires":[["d87ac955771c69ed"]]},{"id":"03a65631c97acf26","type":"inject","z":"071bd578da1b2818","name":"Esszimmer ON","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"24937e74-f2e6-4bac-8ea5-ea90c44aa91a","payload":"{\"on\":{\"on\":true}}","payloadType":"json","x":160,"y":700,"wires":[["d87ac955771c69ed"]]},{"id":"9cb0fcd061f65641","type":"inject","z":"071bd578da1b2818","name":"Esszimmer OFF","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"24937e74-f2e6-4bac-8ea5-ea90c44aa91a","payload":"{\"on\":{\"on\":false}}","payloadType":"json","x":160,"y":740,"wires":[["d87ac955771c69ed"]]},{"id":"b06ab76b8ae0cfb9","type":"inject","z":"071bd578da1b2818","name":"Wohnzimmer ON","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"8a4d68a0-3748-4ecd-8c04-46f976f67aa1","payload":"{\"on\":{\"on\":true}}","payloadType":"json","x":160,"y":800,"wires":[["d87ac955771c69ed"]]},{"id":"47efa1b2629f77a6","type":"inject","z":"071bd578da1b2818","name":"Wohnzimmer OFF","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"8a4d68a0-3748-4ecd-8c04-46f976f67aa1","payload":"{\"on\":{\"on\":false}}","payloadType":"json","x":150,"y":840,"wires":[["d87ac955771c69ed"]]},{"id":"04fd30440f856543","type":"inject","z":"071bd578da1b2818","name":"Küche ON","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"51932247-09b0-47cb-8bf8-ba93666bb30d","payload":"{\"on\":{\"on\":true}}","payloadType":"json","x":180,"y":900,"wires":[["d87ac955771c69ed"]]},{"id":"5925f25fabfe6f3f","type":"inject","z":"071bd578da1b2818","name":"Küche OFF","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"51932247-09b0-47cb-8bf8-ba93666bb30d","payload":"{\"on\":{\"on\":false}}","payloadType":"json","x":170,"y":940,"wires":[["d87ac955771c69ed"]]},{"id":"85cf954e76252659","type":"inject","z":"071bd578da1b2818","name":"Bad ON","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"678918b8-ce79-4c44-bf88-93ae1636d14d","payload":"{\"on\":{\"on\":true}}","payloadType":"json","x":190,"y":1000,"wires":[["d87ac955771c69ed"]]},{"id":"45b69557c470dc69","type":"inject","z":"071bd578da1b2818","name":"Bad OFF","props":[{"p":"endpoint","v":"grouped_light","vt":"str"},{"p":"topic","vt":"str"},{"p":"payload"},{"p":"verb","v":"put","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"678918b8-ce79-4c44-bf88-93ae1636d14d","payload":"{\"on\":{\"on\":true}}","payloadType":"json","x":180,"y":1040,"wires":[["d87ac955771c69ed"]]},{"id":"8dd827ad98e8c9f7","type":"debug","z":"071bd578da1b2818","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":1160,"wires":[]},{"id":"46027bf8ca6a6e1e","type":"inject","z":"071bd578da1b2818","name":"Küche Off","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"4747c001-1fbb-46ee-b8a4-461e909401ff","payload":"{\"on\":false}","payloadType":"str","x":160,"y":1340,"wires":[["1c90ae17ba382974"]]},{"id":"d455a026a5629570","type":"inject","z":"071bd578da1b2818","name":"Esszimer OFF","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"c6fc75e1-7db4-4beb-ab6b-77c53b506f31","payload":"{\"on\":false}","payloadType":"json","x":150,"y":1260,"wires":[["1c90ae17ba382974"]]},{"id":"d592b921aa30ca60","type":"debug","z":"071bd578da1b2818","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":560,"wires":[]}]

ralfhille avatar Mar 25 '22 22:03 ralfhille

@ralfhille Thank you so much for sharing! I think I'll just use this in the future and the philipshue-events for status updates. It's a huge effort to setup instead of using this contrib but I can now finally talk to the bridge without a Hue contrib, using just API V2 requests.

Due I have a account on Hue developers I can solve problems in no-time by myself. That was my plan all the time, I just couldn't create the header.

To create the context for the https node like that is a really cool idea!

andesse avatar Mar 26 '22 09:03 andesse

@ralfhille: I lost track with which direction you are going for. But whatever. One comment regarding your flow: you don't need this extra https-node but can (and should) use the build-in http-request instead. The output can be set to a parsed JSON-object as well.

ptweety avatar Mar 26 '22 09:03 ptweety

@ralfhille: I lost track with which direction you are going for. But whatever. One comment regarding your flow: you don't need this extra https-node but can (and should) use the build-in http-request instead. The output can be set to a parsed JSON-object as well.

@ptweety The built-in Node is always replying with "Error: unable to verify the first certificate" The other https contrib node has an option "enable http agent" the built in doesn't have this option. Is this the problem?

andesse avatar Mar 26 '22 12:03 andesse

@andesse,

you can configure the built-in http-request with a tls-config within which you disable the check against a valid certificate from the server.

[{"id":"1f820636c64450e3","type":"http request","z":"071bd578da1b2818","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"4bc31af9bd03bbdc","persist":false,"proxy":"","authType":"","senderr":false,"credentials":{},"x":1010,"y":620,"wires":[["eb46e63d124f2815"]]},{"id":"4bc31af9bd03bbdc","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false,"alpnprotocol":"","credentials":{}}]

ptweety avatar Mar 26 '22 12:03 ptweety

@ptweety cool thanks for the hint!

andesse avatar Mar 26 '22 12:03 andesse

Same Problem Docker Node-red

corincorvus avatar Mar 27 '22 07:03 corincorvus

@ralfhille: I lost track with which direction you are going for. But whatever. One comment regarding your flow: you don't need this extra https-node but can (and should) use the build-in http-request instead. The output can be set to a parsed JSON-object as well.

Hi @ptweety,

until the update of the HUE Bridge, everything was actually fine. After that there were just some problems with the hue-nodes.

After that, it was actually only to find out where the problem is and why the combination HUE Bridge and node-red HUE nodes no longer ran cleanly.

So if everything is good again, I go the way of the hue-nodes, clear advantage a large community with which I can exchange. By the way, this also applies to all other node-red nodes.

Maybe finally the hint to all who have a problem to update to the node-red version 2.2.1.

I found some duplicate wires in my nodes. This bug has been fixed in version 2.2.1. Maybe this also contributed to the misbehavior, because the msg was sent as often as wires are present.

More information about this BUG https://github.com/node-red/node-red/releases/tag/2.2.1

ralfhille avatar Mar 28 '22 13:03 ralfhille

So if everything is good again, I go the way of the hue-nodes, clear advantage a large community with which I can exchange. By the way, this also applies to all other node-red nodes.

Is your implementation of Huemagic stable? Are you running Node-red on docker?

davidcreager avatar Mar 28 '22 14:03 davidcreager

So if everything is good again, I go the way of the hue-nodes, clear advantage a large community with which I can exchange. By the way, this also applies to all other node-red nodes.

Is your implementation of Huemagic stable? Are you running Node-red on docker?

Until last Friday I still have node-red version 2.2.0 and there were always the disconnections after some time. So now I use only the http node and for the HUE events I have a sse (server side events) connection to the hue bridge.

Today i have updated to node-red 2.2.1, because I also had the problem with the multiple wires between the nodes.

Unfortunately I have now only in 2 weeks time again to switch everything to the hue nodes. But I will definitely try it out, because it is my preferred integration.

ralfhille avatar Mar 28 '22 15:03 ralfhille