dotsam / homebridge-milight

MiLight/LimitlessLED/Easybulb Plugin for Homebridge
MIT License
63 stars 12 forks source link

Color change not working correctly #19

Closed mobster1940 closed 7 years ago

mobster1940 commented 7 years ago

I have recently bought 4 9W RGBWW milight bulbs off ebay, and I got an iBox2 bridge, which is a v6 model I guess and installed homebridge-milight to my rpi. Although my bulbs should work with the rgbw setup in config.json they only work when in fullColor setup. Strange as it may be, my problem is that even though brightness and on/off commands work ok, the colours change correctly only when the last color is white (or as Siri calls it "direct sunlight"). If you try to change 2 colours one after another the second time you are either going to end up with a different hue of the color you wanted or another color altogether.

dotsam commented 7 years ago

@mobster1940 Sorry, I thought I had fixed this in 0.1.7, but it looks like those commits never actually made it. Can you install again to grab 0.1.8 and confirm that it's fixed there? Thanks.

mobster1940 commented 7 years ago

@dotsam Will try when I get home, thanks for the quick response!

mobster1940 commented 7 years ago

@dotsam I tried with the new 0.1.8 version, but the problem remains. It seems that it does change the colour, but it also sets the saturation to 100 making it look "washed" from what I can tell. It also sets the saturation to 0 when I choose white as a colour, which instantly turns the bulb to the right colour before it turns to white.

samsonrosen commented 7 years ago

Hi @dotsam, if you want to access to my homebridge setup for testing with camera you're welcome to VNC into my setup?

andyrooo82 commented 7 years ago

I've installed 0.1.8 and I am also seeing issues changing colour. I'm using RGBW bulbs and LED strips. I'm also using one of the older bridges. I've tried different combimations of delays and repeats but this didn't work and then saw this issue. I'm sure we've had this issue before and it was fixed in an earlier version @dotsam possibly 0.1.5 and I think 0.1.3 I can't remember.

i'm also seeing the same as @samsonrosen where the bulb is changed to the correct colour then back to white (which is why I thought it might be a something weird going on with repeat)

basically, if i want to change the colour of a bulb I have to do it twice. First time the bulb will incorrectly set to white, then set again and it changes colour.

The issue seems to be worse with scene macros where there is just too much going on.

Thanks for all your hard work @dotsam

andyrooo82 commented 7 years ago

Update I've downgraded to 0.1.5 and changed my config back to the old setup and now the bulbs are behaving

dotsam commented 7 years ago

Hi All, I'm going to try and look in to this today and figure out why this regressed with versions > 0.1.5

andyrooo82 commented 7 years ago

Another thing I have noticed having reverted back to 0.1.5 is that the brightness is sometimes unchanged. So if I'm going from Orange 50% and want to go to Blue 25% by way of setting a scene then the colour changes OK but the brightness will not budge from 50%.

mobster1940 commented 7 years ago

Hi, all, I have also tried reverting back to 0.1.5 but there is no change in behaviour, one thing I also noticed is that brightness drops to 50% when I set the colour to purple, maybe @dotsam can figure out why, waiting for fixes, fingers crossed!

dotsam commented 7 years ago

Okay, I was able to replicate the issue and fix it in 0.1.9 that was just published. Please let me know if everything is working correctly now.

andyrooo82 commented 7 years ago

Thanks @dotsam I'll give this a go over the weekend and let you know

mobster1940 commented 7 years ago

@dotsam I installed version 0.1.9 but the problem still remains, color changing is now faster, but saturation goes to 100 after the color change. I am not sure why this happens, and as I have mentioned in my first post I have rgbw bulbs but my config only works when I set it to fullColor. Maybe the problem lies there, if anybody else has this problem maybe we can compare notes?

Update: I also tried version 0.1.10 but no change. My homebridge log when I set color to blue is this: [2/11/2017, 2:11:58 PM] [MiLight] [Office Lamp] Setting power state to on [2/11/2017, 2:11:58 PM] [MiLight] [Office Lamp] Setting hue to 240 [2/11/2017, 2:11:58 PM] [MiLight] [Office Lamp] Setting power state to on [2/11/2017, 2:11:58 PM] [MiLight] [Office Lamp] Setting power state to on [2/11/2017, 2:11:58 PM] [MiLight] [Office Lamp] Setting saturation to 100

dotsam commented 7 years ago

@mobster1940 The bulb labelled RGBWW (as seen here with the original manufacturer http://www.futlight.com/productdetails.aspx?id=184&typeid=101) correspond to the fullColor set of commands in this plugin. The rgbw commands correspond to this older style of RGBW bulbs: http://www.futlight.com/productdetails.aspx?id=158&typeid=101

When asking Siri to set a light to a certain colour, Siri sets a value for hue, saturation, and brightness. For example, when asking for "blue", Siri sets the light to a hue of 240, a brightness of 100, and a saturation of 100. So it looks like everything is working correctly for you when setting colours with Siri. Try changing colour with the colour wheel in the Home app, and you'll see that positions closer to the middle of the wheel have lower saturation values, while the outside edge is a saturation of 100.

mobster1940 commented 7 years ago

@dotsam Thanks for your quick response, I have the 2nd type of bulb that you mention which is rgbw, but homebridge only works when my config is set in fullColor. Maybe it has to do with the bridge (I have a v6 bridge, it actually says iBox2 on it). I noticed what you said about the color wheel and it is working as you explained, but it is easier for me setting the colours from Siri. About that, I can understand the hue and brightness setting when Siri changes the colour, but why is the saturation set to 100? This is the problem for me, setting saturation to 100 makes the color look washed, and even when I ask Siri to set the color to e.g. "dark blue", it sets the brightness to a lower level but keeps the saturation to 100. I hope you can help me figure this out.

andyrooo82 commented 7 years ago

Updated to 0.1.10 and works great. Thanks for sorting it out so quickly @dotsam

dotsam commented 7 years ago

Homekit uses the "HSV" colour model for setting the colours of bulbs. If you look at the formula that converts from RGB to HSV, you'll see that the saturation for any combination of only two of R,G, or B is always 100%.

If you try a Homekit app that lets you set the values independently (Hesperus, for example), where is the saturation value where things look less "washed out"? I suspect that the white LED's in these bulbs simply over-power the colour LEDs, and we might need to compress the saturation scale so it doesn't go to full brightness.

mobster1940 commented 7 years ago

I just downloaded Hesperus and saw the same behaviour, colors appear washed out when saturation is at 100% and normal when saturation is at 0%. After reading your previous comment on what Siri does when you ask for a color I edited your code for the setSaturation function and added var newValue = value - 100; and set that as the command property and the lights behave perfectly! So, it probably has to do with my combination of bulbs and bridge, as far as I can tell

Update: They don't behave as perfectly as planned but, the only problem is with the white color now the first time I tell Siri to turn the lights white the bulb turns red, then the second time the bulb finally turns white, and when I try to change into an other color it stays white until I give the command a second time. I also saw this: #24 and I think that this guy has the same problem as me.

DasPflanze commented 7 years ago

Jep, it's the same problem. Sorry for making another issue.

zuroph commented 7 years ago

seeing the same issue with colour wheel with 4 new gu10 RGBW+CCT bulbs added to my set up. the outer rim of the colour wheel sets the white light to full, which drowns out the colour, then inner rim of the wheel (the whiter part) sett eh colour but turns the white light down. its like the inside and outside of the wheel are inverted.

as an aside, you'll see I've also tried to add the bridge bulb but receiving " Invalid light type specified." when launching. any tips here would be appreciated

      "platforms": [
    {
      "platform":"MiLight",
      "name":"MiLight",
      "bridges": [
        {
          "ip_address": "192.168.0.101",
          "version": "v6",
          "lights": {"bridge": ["ibox"],
            "fullColor": [null,"Bedroom",null,null],
                    "rgbw": ["Kitchen","Sittingroom","Corner lamp","Office"]},
          "repeat": 1,
          "delay": 30
        }]
mobster1940 commented 7 years ago

From what I understand, when rgbw lights are connected to iBox 2 bridge the saturation is inverted, same thing happens to the Milight app too, so maybe @dotsam/anyone can change the commands sent to invert saturation?

@zuroph I think you have an error in your config file, "bridge": ["ibox"], shouldn't exist

zuroph commented 7 years ago

Thanks Mobster, that was me trying to get the v6 bridge bulb to function as a light. I'm likely entering it incorrectly, but if someone can advise me on how to set it as a bulb/single zone I'd appreciate it. I gave up and removed that line for now.

faltim commented 7 years ago

Since yesterday I use this plugin to control my bulbs. I really like it. I have these problems with the saturation too. It would be nice if there is a fix in the future.

In addition I have a question. I have three basic e27 rgbw 6w bulbs. If I set my lights in the .config too "white" they doesn't work. Is that right? I thought that these variable could be used too control up to 8 bulbs with only one bridge. 4 bulbs in rgbw and 4 only in white. Or is this variable a indicator for the different versions of bulbs?

Thanks for your work and help 👍

mobster1940 commented 7 years ago

@bonze4 These variables are only for the bulb versions and zones

dotsam commented 7 years ago

Hi All,

I've just pushed a beta of 1.0 to the dev branch, which, among other things, inverts the saturation value. If someone can give it a go and let me know how it works, that would be great.

DasPflanze commented 7 years ago

Because I anyway reinstalled my raspi I'm going to try the Beta. I hope it works! So how do I install the beta?

DasPflanze commented 7 years ago

So if I done everything right (forked it and changed the version so I could install it with "npm install git://github.com/DasPflanze/homebridge-milight.git") I get this error:

Unhandled rejection Error: no response timeout at Timeout._onTimeout (/usr/lib/node_modules/homebridge-milight/node_modules/node-milight-promise/src/milight-v6-mixin.js:123:26) at ontimeout (timers.js:380:14) at tryOnTimeout (timers.js:244:5) at Timer.listOnTimeout (timers.js:214:5)

DasPflanze commented 7 years ago

Then I get this error:

RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror ssh://git@github.com/DasPflanze/homebridge-milight.git /root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14: Cloning into bare repository '/root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14'...
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror ssh://git@github.com/DasPflanze/homebridge-milight.git /root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14: Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror ssh://git@github.com/DasPflanze/homebridge-milight.git /root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14: Permission denied (publickey).
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror ssh://git@github.com/DasPflanze/homebridge-milight.git /root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14: fatal: Could not read from remote repository.
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror ssh://git@github.com/DasPflanze/homebridge-milight.git /root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14:
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror ssh://git@github.com/DasPflanze/homebridge-milight.git /root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14: Please make sure you have the correct access rights
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror ssh://git@github.com/DasPflanze/homebridge-milight.git /root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14: and the repository exists.
npm ERR! Linux 4.9.13-v7+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "http://github.com/DasPflanze/homebridge-milight.git"
npm ERR! node v7.7.1
npm ERR! npm  v4.1.2
npm ERR! code 128

npm ERR! Command failed: git clone --template=/root/.npm/_git-remotes/_templates --mirror ssh://git@github.com/DasPflanze/homebridge-milight.git /root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14
npm ERR! Cloning into bare repository '/root/.npm/_git-remotes/git-ssh-git-github-com-DasPflanze-homebridge-milight-git-e4429f14'...
npm ERR! Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/npm-debug.log

I never used npm with git together, so I will wait for @dotsam to explain it.

dotsam commented 7 years ago

You don't need to fork the repo, you can install directly from the dev branch with npm install -g git://github.com/dotsam/homebridge-milight.git#dev

DasPflanze commented 7 years ago

I did exactly this before, but I got 0.1.xxx installed. I thought it was because of the "old" package.json, so I forked and changed the file.

dotsam commented 7 years ago

I didn't update the package.json file, so you'll still see the old version, but you should see the git commit ID (7ca0266f8054e5aace355fecf72c238c3eab7154) that indicates you've installed the most recent version from that branch

DasPflanze commented 7 years ago

Ok, I'll try it tomorrow!

DasPflanze commented 7 years ago

Still getting this:

Unhandled rejection Error: no response timeout
    at Timeout._onTimeout (/usr/lib/node_modules/homebridge-milight/node_modules/node-milight-promise/src/milight-v6-mixin.js:123:26)
    at ontimeout (timers.js:380:14)
    at tryOnTimeout (timers.js:244:5)
    at Timer.listOnTimeout (timers.js:214:5)

And I can't find the Homebridge in the Home App...

DasPflanze commented 7 years ago

Ok, after reinstalling the PI homebridge now is working fine. But milight isn't...the logs are fine, no problems there, but no matter what I do, the LEDs won't change the color or brigthness. Just on/off is working. @dotsam could you look at this again?

mobster1940 commented 7 years ago

@dotsam I can confirm this too, it seems that the change you made to the if clauses and replaced them with indexof are to blame, also check the line in setHue function where you check the saturation value, shouldn't it be -100 instead of 0 now that you inverted the saturation value?

dotsam commented 7 years ago

Hi @DasPflanze and @mobster1940, I've tracked down the bug and pushed the change. Can you install from the git URL again and re-test?

DasPflanze commented 7 years ago

Ok now the saturation is as expected but setting the colour to white (nearest to the middle) I get a wonderful ugly pink...

dotsam commented 7 years ago

@DasPflanze Okay, that should be fixed up now too, fullColor bulbs should go in to white mode as well when saturation = 0

DasPflanze commented 7 years ago

@dotsam yes, it's fixed. I guess the blue cast is due to the missing white LEDs.

dotsam commented 7 years ago

@DasPflanze This is actually because I haven't implemented colour-temperature changing on the fullColor bulbs yet. I'm going to close this issue now, and track that problem under #26