Skip to content

Instantly share code, notes, and snippets.

@elpaso666
Last active November 3, 2020 19:41
Show Gist options
  • Save elpaso666/e8ccc3a40cde8e169ed528d9bf51de33 to your computer and use it in GitHub Desktop.
Save elpaso666/e8ccc3a40cde8e169ed528d9bf51de33 to your computer and use it in GitHub Desktop.
Loxone 2 Conbee HUE

This flow connects Loxone Light Controller version 2 using web socket to HUE bulb connected using Conbee v2 USB stick on RPI

You need to install following contrib to be able to connect NodeRed with Loxone miniserver version 1. Miniserver version 2 is not yet supported, because of HTTPS communication by the node-red-contrib-loxone forked from node-lox-ws-api

In Loxone: just configure a LightControllerV2 and set the outputs to RGB format In Node-RED :

  1. configure Loxone Control-IN to connect to LightControllerV2 you set up
  2. configure Deconz-OUT and set input to JSON object msg.payload

thx to @sstroot on https://gist.github.com/sstroot/a2be61a889a6e6712fa0591ab1a69e35 for inspiration! :)

[
{
"id": "7be55345.48bebc",
"type": "subflow",
"name": "Loxone2HUE",
"info": "",
"category": "",
"in": [
{
"x": 327.5,
"y": 307,
"wires": [
{
"id": "525c492b.7ab478"
}
]
}
],
"out": [
{
"x": 1237.5,
"y": 319,
"wires": [
{
"id": "ebbc239d.76c84",
"port": 0
},
{
"id": "467ba87f.00d8e8",
"port": 0
}
]
}
],
"env": [],
"color": "#DDAA99"
},
{
"id": "ebbc239d.76c84",
"type": "function",
"z": "7be55345.48bebc",
"name": "COLOR",
"func": "msg.payload = msg.payload.replace(\"hsv(\", \"\").replace(\")\", \"\").split(\",\");\n\nvar hue = Number(msg.payload[0]) * 65500 / 360;\nvar sat = Number(msg.payload[1]) * 255 /100;\nvar bri = Number(msg.payload[2]) * 255 /100 ;\nvar time = 5; \n\nif (bri == '0') {\n return { payload: { on: false } };\n}\n\nmsg.payload = {\"on\":true,\"bri\":bri,\"hue\":hue,\"sat\":sat,\"transitiontime\":time};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 740,
"y": 220,
"wires": [
[]
]
},
{
"id": "525c492b.7ab478",
"type": "switch",
"z": "7be55345.48bebc",
"name": "White or Color",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "hsv(",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 520,
"y": 300,
"wires": [
[
"ebbc239d.76c84"
],
[
"467ba87f.00d8e8"
]
]
},
{
"id": "467ba87f.00d8e8",
"type": "function",
"z": "7be55345.48bebc",
"name": "WHITE",
"func": "var bri = msg.payload * 255 /100 ;\nvar time = 5;\n\nif (bri == '0') {\n return { payload: { on: false } };\n}\n\nmsg.payload = {\"on\":true,\"bri\":bri,\"transitiontime\":time};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 740,
"y": 340,
"wires": [
[]
]
},
{
"id": "8616366c.b009a8",
"type": "subflow:7be55345.48bebc",
"z": "a3b8df88.2aea9",
"name": "",
"env": [],
"x": 350,
"y": 60,
"wires": [
[
"2e5982c5.68504e"
]
]
}
]
@elpaso666
Copy link
Author

image

@elpaso666
Copy link
Author

13

@guewii
Copy link

guewii commented Feb 12, 2020

Hi,
this subflow looks very nice! :-)

but, are you sure that the "WHITE" way works correctly?

grafik

@guewii
Copy link

guewii commented Mar 18, 2020

image

i have changed the "WHITE" way.

msg.payload = msg.payload.replace("temp(", "").replace(")", "").split(",");

var bri = Number(msg.payload[0]) * 255 /100;
var ct = Number((1-((msg.payload[1]-2700)/3800))*347)+153;
var time = 5;

if (bri == '0') {
return { payload: { on: false } };
}

msg.payload = {"on":true,"bri":bri,"ct":ct,"transitiontime":time};
return [msg ]

@guewii
Copy link

guewii commented Mar 18, 2020

[{"id":"7a566797.06a6d8","type":"tab","label":"Loxone to deCONZ","disabled":false,"info":""},{"id":"ef8004c2.144c58","type":"function","z":"7a566797.06a6d8","name":"COLOR","func":"msg.payload = msg.payload.replace(\"hsv(\", \"\").replace(\")\", \"\").split(\",\");\n\nvar hue = Number(msg.payload[0]) * 65500 / 360;\nvar sat = Number(msg.payload[1]) * 255 /100;\nvar bri = Number(msg.payload[2]) * 255 /100 ;\nvar time = 5; \n\nif (bri == '0') {\n return { payload: { on: false } };\n}\n\nmsg.payload = {\"on\":true,\"bri\":bri,\"hue\":hue,\"sat\":sat,\"transitiontime\":time};\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":100,"wires":[[]]},{"id":"dd709091.70019","type":"switch","z":"7a566797.06a6d8","name":"White or Color","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"hsv(","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":340,"y":120,"wires":[["ef8004c2.144c58"],["ad69473f.862af8"]]},{"id":"ad69473f.862af8","type":"function","z":"7a566797.06a6d8","name":"WHITE (Lichtsteuerung)","func":"msg.payload = msg.payload.replace(\"temp(\", \"\").replace(\")\", \"\").split(\",\");\n\nvar bri = Number(msg.payload[0]) * 255 /100;\nvar ct = Number((1-((msg.payload[1]-2700)/3800))*347)+153;\nvar time = 5; \n\nif (bri == '0') {\n return { payload: { on: false } };\n}\n\nmsg.payload = {\"on\":true,\"bri\":bri,\"ct\":ct,\"transitiontime\":time};\nreturn [msg ]","outputs":1,"noerr":0,"x":550,"y":144,"wires":[[]]}]

@elpaso666
Copy link
Author

Hi,
thx a lot! i am totally busy these days. I appreciate the help. I test and update the source?

Jakub

@tbernaerd
Copy link

Hello guys,

Appreciate the work here. I used the latest edit by Guewii. Seems like the payload is constructed correctly but my light is not working. What do I need to set up here?

image

@tbernaerd
Copy link

Found it. For others stumbling upon this thread:

image

Thanks again for the code snippet guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment