Convert Loxone color string to Hue RGB

This flow converts a Loxone hsv(...) or temp(...) string from a LightControllerV2 directly to a RGB array.

You will need these nodes:

  • node-red-contrib-loxone
  • node-red-contrib-huemagic
  • node-red-contrib-color-convert

In Loxone:

  • Configure a LightControllerV2
  • Set the outputs to RGB

In Node-RED

  • Place a Loxone "control in" node and configure it with the LightControllerV2 and state color
  • Place a "Hue Lamp" or "Hue Group" node
  • Connect both with this flow. Loxone on the input and Hue on the output.

Loxone and Hue are now connected. The color and brightness setting in Loxone is then transferred to Hue.

[{"id":"7fa10a6e.8bda14","type":"subflow","name":"Loxone color string to Hue RGB","info":"","category":"","in":[{"x":327.5,"y":307,"wires":[{"id":"616f6d48.4176b4"}]}],"out":[{"x":1237.5,"y":319,"wires":[{"id":"21e6122.56392ee","port":0},{"id":"527b719d.025c7","port":0}]}]},{"id":"52121dad.3e9224","type":"color-convert","z":"7fa10a6e.8bda14","input":"hsv","output":"rgb","outputType":"array","x":898.5,"y":251,"wires":[["21e6122.56392ee"]]},{"id":"c0a01e2b.be63","type":"function","z":"7fa10a6e.8bda14","name":"split hsv","func":"msg.payload = msg.payload.replace(\"hsv(\", \"\").replace(\")\", \"\").split(\",\");\nflow.set(\"brightness\", msg.payload[2]);\nreturn msg;","outputs":1,"noerr":0,"x":732.5,"y":251,"wires":[["52121dad.3e9224"]]},{"id":"21e6122.56392ee","type":"function","z":"7fa10a6e.8bda14","name":"RGB > msg","func":"var brightness = flow.get(\"brightness\");\nif (brightness == '0') {\n  return { payload: { on: false } };\n}\nreturn { payload: { on: true, rgb: msg.payload, brightness: brightness } };","outputs":1,"noerr":0,"x":1078.5,"y":251,"wires":[[]]},{"id":"616f6d48.4176b4","type":"switch","z":"7fa10a6e.8bda14","name":"hsv or temp","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"hsv(","vt":"str"},{"t":"cont","v":"temp(","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":518.5,"y":310,"wires":[["c0a01e2b.be63"],["fd3e393c.a0cbb8"]]},{"id":"fd3e393c.a0cbb8","type":"function","z":"7fa10a6e.8bda14","name":"spilt temp","func":"msg.payload = msg.payload.replace(\"temp(\", \"\").replace(\")\", \"\").split(\",\");\nreturn msg;","outputs":1,"noerr":0,"x":730.5,"y":368,"wires":[["527b719d.025c7"]]},{"id":"527b719d.025c7","type":"function","z":"7fa10a6e.8bda14","name":"Temp > RGB > msg","func":"var brightness = parseInt(msg.payload[0]);\nif (brightness == '0') {\n  return { payload: { on: false } };\n}\n\nvar kelvin = parseFloat(msg.payload[1]);\nvar temp = kelvin / 100;\nvar red, green, blue;\n\nif (temp <= 66) { \n  red = 255; \n\n  green = temp;\n  green = 99.4708025861 * Math.log(green) - 161.1195681661;\n\n  if (temp <= 19) {\n    blue = 0;\n  } \n  else {\n    blue = temp - 10;\n    blue = 138.5177312231 * Math.log(blue) - 305.0447927307;\n  }\n} \nelse {\n  red = temp - 60;\n  red = 329.698727446 * Math.pow(red, -0.1332047592);\n\n  green = temp - 60;\n  green = 288.1221695283 * Math.pow(green, -0.0755148492 );\n\n  blue = 255;\n\n}\n\nred = Math.round(Math.min(Math.max(red, 0), 255));\ngreen = Math.round(Math.min(Math.max(green, 0), 255));\nblue = Math.round(Math.min(Math.max(blue, 0), 255));\n\nreturn { payload: { on: true, rgb: [ red, green, blue ], brightness: brightness } };","outputs":1,"noerr":0,"x":920.5,"y":368,"wires":[[]]}]

Flow Info

Created 1 year, 6 months ago
Rating: 5 1

Owner

Node Types

Core
  • function (x4)
  • subflow (x1)
  • switch (x1)
Other

Tags

  • Loxone
  • Hue
  • node-red
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option