question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Represent an RGBW Light in HomeKit

See original GitHub issue

So I have got an RGBW Light and I don’t know how I could perfectly represent this in HomeKit:

I have 3 incoming nodes:

  1. ON switch (it returns an ON/OFF - this is sent to HomeKit as On: true/false')
  2. Color channel - this returns a HSB (3 parameter - Hue, Sat, Bright) like string - now I get these datas by splitting this string and sending to HomeKit as Brightness, Hue, Saturation.
  3. I also have a White channel which returns an int (0-100) representing the brightness of the seperate white LEDs. I don’t know how I could include this, because HomeKit doesn’t seem to have a seperate Brightness (like WhiteBrightness or something like this…)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:61 (60 by maintainers)

github_iconTop GitHub Comments

1reaction
crxportercommented, Mar 21, 2019

You inspired me to finally take a few minutes to adapt my lights to a color bulb in homekit.

in the wiki

1reaction
Shaquucommented, Mar 7, 2019

Regarding rgbw try this code:

let Ri = 254;
let Gi = 0;
let Bi = 80;

if (Ri === 0) {
  Ri = 1;
}

if (Gi === 0) {
  Gi = 1;
}

if (Bi === 0) {
  Bi = 1;
}


let M = Math.max(Ri,Gi,Bi);
let m = Math.min(Ri,Gi,Bi);

let Wo = m / M < 0.5 ? m * M / (M - m) : M;
let Q = 255;
let K = (Wo + M) / m;
let Ro = Math.floor( [ ( K * Ri ) - Wo ] / Q );
let Go = Math.floor( [ ( K * Gi ) - Wo ] / Q );
let Bo = Math.floor( [ ( K * Bi ) - Wo ] / Q );

console.log("Input RGB: [" + Ri + "," + Gi + "," + Bi + "]");
console.log("Output RGBW: [" + Ro + "," + Go + "," + Bo + "," + Wo+ "]");

Output is:

Input RGB: [254,1,80] Output RGBW: [254,0,79,1.0039525691699605]

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESP IDF Homekit RGB LED Control Over iPhone - YouTube
In this video, an RGB LED is controlled over WiFi using iPhone HomeKit app. HSB to RGB conversion model ESP32 WiFi provisioning and...
Read more >
Apple HomeKit USB Smart LED Light Strip - YouTube
Thank you Koogeek for sending me this LED strip!Today I take a look at the Koogeek USB Smart LED Strip! It works with...
Read more >
How to get Started with WLED: Complete Guide With HomeKit
Add the affordable and highly customizable WLED project into Apple HomeKit. And let your next party be a blast with a lot of...
Read more >
How to add Magic Home LED devices into Apple HomeKit
Step by Step guide to get your Magic home in Homekit using Hoobs. This video shows it by using the IP or MAC...
Read more >
What is the Best RGBIC LIGHT STRIP - for Apple ... - YouTube
Today, we take a look at the only 3 addressable light strips that are available for HomeKit and I tell you which one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found