happyleavesaoc / python-limitlessled

MIT License
33 stars 22 forks source link

Support for LimitlessLED Wifi Bridge v6.0 #7

Closed alexmat closed 7 years ago

alexmat commented 7 years ago

Is it possible to add support for the new wifi bridges? I just bought one and would like to use it with this library. The specs have been published here: http://www.limitlessled.com/dev/

ash-vd commented 7 years ago

There is a fork here, which should have support for v6. I can't get it to work, I can't seem to get a response from the bridge for the WB1 and WB2...

soldag commented 7 years ago

I'm the developer of the fork. It's still work in progress, but retrieving wb1 and wb2 works for me so far.

ash-vd commented 7 years ago

Yes, I got a response now... None of the other commands seem to work though. Is there anything that should work so far, or anything I can help you with?

happyleavesaoc commented 7 years ago

@soldag PR welcome once you get it working properly. I don't have a v6 bridge yet unfortunately.

soldag commented 7 years ago

I only have a RGBWW bulb, for which turning it on and off and changing the color/brightness works yet. For the other led types I only copied the commands from the docs, but could not test it. Which bulb do you have? It would be nice, if anybody could test, if the code works with the other led types than RGBWW.

I hope to find time soon to get it working completely and will create an PR then ;)

ash-vd commented 7 years ago

I have RGBW, RGBWW and White, and a v6 box. I also have v5 box laying around at work which used to work with this repo. Do you have an example? This is what I've got, but it doesn't seem to work:

from limitlessled.bridge import Bridge
from limitlessled.group.rgbw import RGBW, RGBWW, BRIDGE_LED
from limitlessled.group.white import WHITE

bridge = Bridge('192.168.39.11')
group = bridge.add_group(2, 'group', RGBWW)

group.on = True

It receives the WB1 and WB2, but the lamp doesn't go on. Looks like it doesn't send the command from what I'm seeing. Anything I missed? My RGBW bulb also isn't working when I change RGBWW to RGBW.

RiRomain commented 7 years ago

I have a rgbww and cw/ww bulb as well as a v6 bridge at home so I'll be able to test both those bulb (after 5 January)

soldag commented 7 years ago

@ashwinvandijk I think the problem with your code is, that the actual command is not even sent to the bridge. The way the library works is that when changing any property of a group, i.e. setting group.on = True, the respective command is put into an queue. When instantiating a Bridge object, a daemon thread is started, which processes the command queue. In your case the application terminates before the daemon thread is able to send the command, since there is no other operation after turning the led group on. So for testing you could add something like time.sleep(10) at the end of your script so that the application exits only after 10s, which is enough time for the daemon thread to send the command.

@RiRomain That would be nice! 👍

ash-vd commented 7 years ago

Yep, that was it. Furthermore, the RGBWW and RGBW commands seem to be switched in the example from Limitlessled, and they are switched here too. Turning on and off and setting the brightness works for me. Colors do not work for me yet:

limitlessled/group/commands/v6.py", line 67, in convert_color
    return math.floor(hue * self.MAX_COLOR)
TypeError: must be real number, not tuple

I think we should only get the first value of the tupel, right? In that way it works a bit better, although Color(255, 0, 0) isn't red but pink... I experienced this with another module before, so maybe it has something to do with limitless itself.

Nevertheless, good work so far! 👍

soldag commented 7 years ago

Since I am really new to this whole thing: Whats the difference between RGBW and RGBWW bulbs? I only copied the commands from the LimitlessLED examples and assumed they are right.

Yeah, you're right with getting only the first value of the hsv tuple. I forgot to commit this :unamused: I also fixed the color conversion so Color(255, 0, 0) is now red and not pink.

ash-vd commented 7 years ago

Yep, Limitless switched these, so you did too. Makes sense :). This repo also has them switched.

The RGBW lights are the "old" ones, they are supported in the older bridges. Then can be warm white OR cold white, and the white led's can't be on at the same time as the RGB-leds.

The RGBWW are quite new. They are supported from bridge v6, and are warm AND cold white. Also, the white leds can be on together with the RGB-leds. In this way you can change the saturation of the colors, just like you can with Philips HUE.

Your fixes work great by the way, for both RGB and RGBWW. However, the fix for the color doesn't seem to work for the RGBWW lights.

I implemented a basic setting for the saturation, for which I created a pull-request. This works for the RGBWW bulbs, but to my opinion it should be inverted. 0.1 should be just a little bit of color (more white), and 1 should be fully saturated, so no white. Right now this is the other way around. However, this is the way that Limitless itself implements it...

RiRomain commented 7 years ago

I've just tested the bridge and a RGBW bulb (old generation) basic function (on/off/color set) and it worked fine 👍 I'll continue testing

I just have bulb from the older generation, warm+cold white, rgb+warm white. So I cannot test RGB+CW+WW bulb.

RiRomain commented 7 years ago

Does WB1 and WB2 always stays the same or does the session expire? I feel like my session expire after a while and I need to recreate a bridge object to keep the communication working.

ash-vd commented 7 years ago

WB1 and WB2 change. Everytime I connect I get different values. I do not know how long the session is valid, we could try to find out how long the session is valid, and fetch a new one when it's expired... I can't find anything about it on the Limitlessled website.

soldag commented 7 years ago

Thanks for the explanation. I ordered also some RGBWW bulbs, which I can use for testing. I will have a look at your PR later. ;)

There are keep alive messages, which have to be sent every 5s. They are described in the limitlessled docs, but I did not implemented them yet. I could imagine as long as you send these, wb1 and wb2 stay the same.

soldag commented 7 years ago

Keep alive messages are now supported and work as I assumed ;)

RiRomain commented 7 years ago

Awesome :-) I'll try that tomorrow.

On home-assistant forum someone made the following comment: "For the person who is working on the library, don't forget to reset the Sequence Number to 0 when it passed 255. Otherwise you are only able to send 255 commands." I didn't have time to check by myself yet.

RiRomain commented 7 years ago

Keep alive message are working as expected and the sequence number reset with a modulo is very clever 👍

soldag commented 7 years ago

My RGBWW bulbs arrived today so I could play around with them a little bit. I also encountered the color problem you mentioned @ashwinvandijk. The color wheel seems to be shifted. I tried to add different values to the hue of the color and ended up with an value, which might not be 100% correct, but seems to work properly for the colors I tested. Also when setting the color of an RGBWW bulb the hue and saturation will be changed.

ash-vd commented 7 years ago

Thanks, the color is much better this way! I updated the module in my Home Assistant, and it already works. It seems to stop working after a while, but I will look into that later.

soldag commented 7 years ago

Yay, another Home Assistant user :) I also encountered this problem and just pushed a commit, which implements a reconnection mechanism. I only tested it manually by disconnecting the bridge for a while and it worked. I will now install it on my Raspberry Pi running Home Assistant and will check if it solves the problem. Maybe you could also give it a try?

dnousome commented 7 years ago

I've been following you all for a while with the new Bridge and will try implementing this in my Home assistant.

I have been having issues through the bridge where it seems to lose connection with the app every so often. @soldag are you implementing some sort of keep alive to ensure the bridge stays online?

RiRomain commented 7 years ago

I think he answered your question just before you asked ^^

dickwolff commented 7 years ago

What is the current state of the V6 implementation? On what time frame is it ready for a Home Assistant release?

soldag commented 7 years ago

There are still some issues with the transition. I hope to find some time this week to fix them ;)

MMaximuss commented 7 years ago

What a great work! I'm very excited for the HA-release. Are there, in addition to the transition issue, other issues?

Does anybody know why the lights will dim before they go off in home assistant? Is it possible that hey go off without dimming?

happyleavesaoc commented 7 years ago

@MMaximuss the reason is that if you ask a light to turn on to a given brightness, it will first turn on, then transition to that brightness. If the previous brightness was 100%, and you only want 50%, it will get very bright before going to 50%.

RiRomain commented 7 years ago

I think MMaximuss meant that when turning off the light they'll dim first. They dim goes to something like 10%, stay there for a short time, and then goes off. Is it possible to skip the transition and pass directly from set brightness to 0?

MMaximuss commented 7 years ago

Indeed, RiRomain. That's what I mean. @happyleavesaoc I understand the reason why the transition is added.

I use home assistant and the standard light wall-switch to control the lights. If I first use home assistant to turn my lights off and then use the wall switch to turn them on, the lights are dimmed. So that's why I ask if it's possible to skip the transition. Maybe it's possible to add a setting in de config-file to turn the transition on or off?

Like:

light:
  platform: limitlessled
  bridges:
    - host: xxx.xxx.xxx.xxx
      groups:
      - number: 1
        name: Bedroom1
        type: rgbw
        transition: off
JohanLeirnes commented 7 years ago

Any updates? Ive ordered 20 lamps and 4 boxes to use around the house. Also any work being done to try and implement the disco mode etc.?

RiRomain commented 7 years ago

I didn't try to implement disco mode etc... as I don't have any use for it and I didn't see that someone plan to implement it... but you're free to send your code

JohanLeirnes commented 7 years ago

It looks like it is some kind of colorloop implemented atleast:

COLORLOOP = Pipeline() \ .on() \ .transition(10, color=Color(255, 0, 0)) \ .transition(10, color=Color(0, 255, 0)) \ .transition(10, color=Color(0, 0, 255)) \ .repeat(stages=3)

is this for home assistant's "colorloop" mode? If yes is there maby a way to make it smoother? 2.5%% increase each step can be a bit to big maby?

ash-vd commented 7 years ago

I think this should be in another ticket, as it's not directly linked to this issue.

This module by itself is working great, no more time-outs or weird errors. The thing that is missing now is a slider for saturation/color temperature in home-assistant itself. Has anybody taken a look at this? I will try to look into it if I find the time.

RiRomain commented 7 years ago

I think this should be in another ticket, as it's not directly linked to this issue. Agree with that.

The thing that is missing now is a slider for saturation/color temperature Slider for color temperature should already be supported by home-assistant, attribute color_temp.

In SUPPORT_LIMITLESSLED_XXX you need to have the element: SUPPORT_COLOR_TEMP

I'm not sure that saturation is already supported by home-assistant, those features are supported: SUPPORT_BRIGHTNESS = 1 SUPPORT_COLOR_TEMP = 2 SUPPORT_EFFECT = 4 SUPPORT_FLASH = 8 SUPPORT_RGB_COLOR = 16 SUPPORT_TRANSITION = 32 SUPPORT_XY_COLOR = 64 SUPPORT_WHITE_VALUE = 128

Maybe WHITE_VALUE WHITE_VALUE could be use for saturation...

But again, this maybe also doesn't have it's place here, it's not really about the library and more about home-assistant. So it's maybe better here or here

dickwolff commented 7 years ago

Does this mean the module can be released to the official HA channel very soon? I have multiple V6 bulbs (and a V6 bridge) and can't wait to get started with it..

RiRomain commented 7 years ago

There are still some issues with the transition. I hope to find some time this week to fix them ;)

Soldag seems to still have found issues with the transition, so it's not sure yet when this fork will be stable and therefore released.

JohanLeirnes commented 7 years ago

The latest commit says that transitions is fixed. https://github.com/soldag/python-limitlessled/commit/cf9f7a05a4fa8ca6c45667973f25f5a1810fb0b3

RiRomain commented 7 years ago

Yes I've seen that, but: Soldag wrote the 16.01 at 10am:

There are still some issues with the transition. I hope to find some time this week to fix them ;)

This commit is from the 15.01 at 3am. So I suppose that was just a partial fix.

soldag commented 7 years ago

Sorry for my absence in the last weeks. I didn't had the time to fix the remaining issues 😕
You're right, it was just a partial fix. I discovered some more small issues after this commit. I just fixed some of them, but the biggest issue left refers to the timing. For now, the transitions are much slower than the specified time. The reason is, that for each request I wait for the response of the bridge so that responses of keep alives and ordinary commands do not mix.

Also my bulbs still sometimes seem to stop working after a while, but I am noch quite sure, if its a problem with HA. You don't have these problems, @ashwinvandijk? Could you share the code of your updated limitlessled HA component?

ash-vd commented 7 years ago

No problems here I think. Yesterday I gave my wifi a reset, but HomeAssistant didn't seem to automatically reconnect. I will try it again, maybe it was just coincidence. My code is mostly unchanged, but I added LimitlessLEDRGBWWGroup.

See: http://pastebin.com/bb72Lm0J

durzo commented 7 years ago

Hi, my v6 bridge and rgbww lights arrived yesterday. let me know if i can help test any code etc.

tbrasser commented 7 years ago

I tested with the following hardware: 1x MiLight iBox Bridge v6 with bridge led. 3x GU10 RGBWW 4W, 2x E27 RGBWW 8W and 1 12W RGBWW downlight and a few 6W RGBWW downlights.

Everything seemed to work, however as I'm going to switch the power to these bulbs/downlights with z-wave relays I'd prefer to disable the transition entirely (they are also really slow, but you already mentioned that).

Also there is only RGB + Brightness control, no CCT control yet. But that is understandable since that will probably be worked on after this is done/tested.

My Home-Assistant Docker updates to the latest dev version every night, so it overwrote the changes I've made, so if theres anything new to test tell me so I can repatch it.

RiRomain commented 7 years ago

I've also tested with with some CW/WW bulb and some RGB WW bulb and a v6 bridge (iBox).

Since last modification, I didn't notice any problem, the transition are fine for me, they are not specially long.

splodgemcroo commented 7 years ago

My new v6 stuff arrived yesterday, and I've just managed to get it all working with @soldag fork and home assistant - thanks for all your work on this. I'm using the new v6 bridge (ibox), and 4x 8W RGBWW lights.

After a little fiddling, I've also got CCT control working in addition to the RGB+Brightness controls for the bulbs in Home Assistant - happy to share the modifications I've made if it's useful to anyone (there's probably a better way of doing it - i've not used Python before..)

ash-vd commented 7 years ago

I think it would help us if you share your code here: https://github.com/home-assistant/home-assistant/issues/4941. This is a fix for Home Assistant and not for this library. I'm looking for a nice solution to integrate the saturation and temperature into home-assistant, so maybe this will help me.

splodgemcroo commented 7 years ago

@ashwinvandijk - I've added details to the thread here : https://community.home-assistant.io/t/update-limitlessled-milight-component-v6-bridge-ibox/6248/58 - hope it's useful

durzo commented 7 years ago

can confirm using the @soldag fork with the above home-assistant fix that @splodgemcroo posted i have my v6 bridge and RGBWW lights working perfectly. When are we likely to see it merged back into this repo?

ash-vd commented 7 years ago

As far as I know there is still a small bug in the transitions that @soldag wants to fix. As long as this library isn't updated, we can't update Home Assistant.

@soldag, anything I can help you with?

RiRomain commented 7 years ago

I don't know if those issue are still present, I've been using the latest version for 3-4 days and it's also working well for me.

tbrasser commented 7 years ago

There are more people on the home-assistant community that report it working without issues. Ready for a merge? :D