Milight brightness

Hi there

I’m using the MiLight binding to control 2 zones of RGBW bulbs. This works very well for on/off, color and whiteMode operation. However the brightness setting does not seem to function properly. I can dimm the bulbs, but can never get the brightness up to 100% again. It will go up to about 50-60%. I then have to use the native android app to get the brightness all the way up. My config:

Setup:
openHAB 1.6.2 runtime
MiLight binding version 1.7.1
Hardware/OS: Raspberry PI / raspbian
MiLight bridge: Seems to be v3 (visually/physically at least)

openhab.cfg:
milight:bridge1.host=10.0.0.121
milight:bridge1.port=8899

Items:
Switch Light_Kitchen_Light_Switch “Kitchen Lights” (Lights, Kitchen, LightsONOFF) {milight=“bridge1;8”}
Switch Light_Kitchen_Light_WhiteMode “Kitchen Lights White Mode” (Lights, Kitchen) {milight=“bridge1;8;whiteMode”}
Switch Light_Kitchen_Light_NightMode “Kitchen Lights Night Mode” (Lights, Kitchen) {milight=“bridge1;8;nightMode”}
Dimmer Light_Kitchen_Light_Dimmer “Kitchen Lights Dimmer” (Lights, Kitchen) {milight=“bridge1;8;brightness;10”}
Color Light_Kitchen_Light_Colour “Kitchen Lights Colour” (Lights, Kitchen) {milight=“bridge1;8;rgb”}

Testing rule:
rule “Dummy”
when
Item dummy received command
then
sendCommand(Light_Kitchen_Light_Dimmer, 30)
timer_test = createTimer(now.plusSeconds(2)) [|sendCommand(Light_Kitchen_Light_Dimmer, 100)]
end

Debug window (30->90% brightness test case):
12:03:39.610 [DEBUG] [m.r.internal.engine.RuleEngine:285 ] - Executing rule ‘Dummy’
12:03:39.613 [INFO ] [runtime.busevents :22 ] - dummy received command ON
12:03:39.806 [DEBUG] [.o.b.m.internal.MilightBinding:96 ] - milight: item is of type brightness
12:03:39.808 [DEBUG] [.o.b.m.internal.MilightBinding:111 ] - milight: command is of type PercentType
12:03:39.810 [DEBUG] [.o.b.m.internal.MilightBinding:192 ] - milight: sendPercent
12:03:39.811 [DEBUG] [.o.b.m.internal.MilightBinding:608 ] - milight: sendOn
12:03:39.813 [DEBUG] [.o.b.m.internal.MilightBinding:780 ] - milight: messageBytes to transform: ‘47:00:55’
12:03:39.815 [DEBUG] [.o.b.m.internal.MilightBinding:771 ] - Sent packet ‘47:00:55’ to bridge ‘bridge1’ (10.0.0.121:8899)
12:03:39.917 [DEBUG] [.o.b.m.internal.MilightBinding:274 ] - milight: send dimming packet ‘4E:5:55’ to RGBW bulb channel ‘8’
12:03:39.918 [DEBUG] [.o.b.m.internal.MilightBinding:780 ] - milight: messageBytes to transform: ‘4E:5:55’
12:03:39.920 [DEBUG] [.o.b.m.internal.MilightBinding:771 ] - Sent packet ‘4E:5:55’ to bridge ‘bridge1’ (10.0.0.121:8899)
12:03:39.928 [INFO ] [runtime.busevents :22 ] - Light_Kitchen_Light_Dimmer received command 30

…some other stuff…

12:03:42.121 [DEBUG] [.s.i.actions.TimerExecutionJob:42 ] - Executing timer ‘DEFAULT.2015-09-20T12:03:42.116+02:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: org.eclipse.xtext.xbase.impl.XClosureImplCustom@1c124ab (explicitSyntax: true)’
12:03:42.398 [DEBUG] [.o.b.m.internal.MilightBinding:96 ] - milight: item is of type brightness
12:03:42.400 [DEBUG] [.o.b.m.internal.MilightBinding:111 ] - milight: command is of type PercentType
12:03:42.401 [DEBUG] [.o.b.m.internal.MilightBinding:192 ] - milight: sendPercent
12:03:42.403 [DEBUG] [.o.b.m.internal.MilightBinding:608 ] - milight: sendOn
12:03:42.404 [DEBUG] [.o.b.m.internal.MilightBinding:780 ] - milight: messageBytes to transform: ‘47:00:55’
12:03:42.406 [DEBUG] [.o.b.m.internal.MilightBinding:771 ] - Sent packet ‘47:00:55’ to bridge ‘bridge1’ (10.0.0.121:8899)
12:03:42.508 [DEBUG] [.o.b.m.internal.MilightBinding:274 ] - milight: send dimming packet ‘4E:11:55’ to RGBW bulb channel ‘8’
12:03:42.509 [DEBUG] [.o.b.m.internal.MilightBinding:780 ] - milight: messageBytes to transform: ‘4E:11:55’
12:03:42.511 [DEBUG] [.o.b.m.internal.MilightBinding:771 ] - Sent packet ‘4E:11:55’ to bridge ‘bridge1’ (10.0.0.121:8899)
12:03:42.520 [INFO ] [runtime.busevents :22 ] - Light_Kitchen_Light_Dimmer received command 90

Result:
When I initiate the rule the lights will dimm, and 2 seconds later they will increase brightness to about midway of full.

Has anyone else experienced this and can perhaps help out? Thanks!

regards,
Tertius

I just got a light bulb today to play around with… Only a white one…

I have noticed that if I crank the brightness up to full using the phone app and then power the light off using OpenHAB and then switch it back on using openhab then it feels like only 50% brightness…

When it switches off i suspect it’s lowering the brightness first… Because if I switch it back on with the phone app it’s still pretty dim and not back to full brightness…

I did notice this being discussed on the old forums too…

https://groups.google.com/forum/#!searchin/openhab/Milight|sort:relevance/openhab/-OltTNqkEhk/lgI2xgtUcyIJ

Hi,
As said in other discussions, I will have a look at the brightness jssue.
But always keep in mind, that there is no possibility to sync the state if you use the remote, the phone app or openHAB. Milight is a one way communication.

Best
Hans-Jörg

Thanks Hans-Jörg

It’s for this very sync reason that I will refer openhab to do all interactions with the bulbs.

Much appreciated.

Regards,
Tertius

Hi

According to the LimitlessLED dev wiki the following commands are used to change brightness.

45 00 55 wait 100ms then send 4E XX 55 - Set Zone 1 to Brightness XX (XX range is 0x02 to 0x1B) 47 00 55 wait 100ms then send 4E XX 55 - Set Zone 2 to Brightness XX (XX range is 0x02 to 0x1B) 49 00 55 wait 100ms then send 4E XX 55 - Set Zone 3 to Brightness XX (XX range is 0x02 to 0x1B) 4B 00 55 wait 100ms then send 4E XX 55 - Set Zone 4 to Brightness XX (XX range is 0x02 to 0x1B)

From my debug windows’s output on the first post (zone 2 being sent) you can see the 47 00 55 sent first followed by 4E 11 55. The latter sets the brightness which in openhab was at 90%. However as the value sent to the bridge is 11 (middle value), in relation to a maximum of 1B, it equates to about 68% brightness.

This is inline with what I am seeing. If I’m right then the scaling in the binding should be changed…?

Thanks for doing some more debugging.
I will have a closer lok at it. Just did a quick review of the code but did not see any wrong scaling at first sight.
The code should transform 90% to a message byte of 18, not 11 like in your logs.

Best
Hans-Jörg

Hi

So I eventually figured it out! Really my own stupidity at play here, but I did find a small bug… So it seems that my bulbs have 27 steps as per two posts ago. By me overriding the steps to 10 in my items file I caused 10 to be my maximum. When I changed this to 27 and send a 100 brightness command; now the light goes on full and I can see the correct message sent to the bridge. :yum:

The thing is that when I dimm the lights to 1 then nothing happens. This is as a result of the steps (as per API) being defined for the range 0x02 to 0x1B. So when I send a 1 it equates to 1 * 27 / 100 = 0 (int). The lowest value that can currently be sent for a dimm is actually 8, i.e. 8 * 27 / 100 = 2.16 (=2 = 0x02).

So I believe line 271 (and corresponding ones) should change from:

int newCommand = (command.intValue() * rgbwSteps / 100);

to:

int newCommand = (command.intValue() * (rgbwSteps - 2) / 100 + 2);

In doing so the following will happen:

Send value of 1:    newCommand = 1 * (27 - 2) / 100 + 2 = 2.25
Send value of 50:   newCommand = 50 * (27 - 2) / 100 + 2 = 14.5 (full range 25, so 2+25/2 = 14.5, exactly halfway)
Send value of 100:  newCommand = 27

This works for any step value. It will start at 2 and step to the defined max steps at 100 brightness.

regards,
Tertius

1 Like

Hi,
Thanks for digging into it and finding the issue.
I will try to implement this fix over the weekend an create a PR, so it could be used very soon.

Best
Hans-Jörg

1 Like

Hi Hans-Jörg,
I am also affected by this error.
When can you fix it?

Many thanks!
Andy

Hi,
just created PR 3252 to implement this fix.

Best
Hans-Jörg

PR is merged, so the bugfix should be available with next snapshot build.

Best
Hans-Jörg

Thanks! Sounds good!

Can you give me the org.openhab.binding.milight-x.x.x.jar file earlier?
Have no idea of java compiling and my pregnant wife stumbles without light through the apartment.

many thanks

Hi, it’s been a while since I’ve looked into this issue again but after installing OpenHAB on a new server today I realise the milight binding is still having the same issue. When I switch off a light it looks like it dims it first and then off. And then when I switch it back on it’s at the very lowest brightness setting.

Did you ever confirm that you resolved this issue?

This is the content of the OpenHAB log file with debug logging turned on. All I did was switch the light bulb off… I’m not using a dimer…

01:13:49.003 [DEBUG] [.o.b.m.internal.MilightBinding:664 ] - milight: sendOff
01:13:49.004 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.005 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘91’
01:13:49.007 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.009 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:49.111 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.112 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘82’
01:13:49.114 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.117 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:49.219 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.220 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘73’
01:13:49.222 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.225 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:49.327 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.328 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘64’
01:13:49.330 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.332 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:49.434 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.435 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘55’
01:13:49.437 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.440 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:49.542 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.543 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘45’
01:13:49.545 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.547 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:49.649 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.650 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘36’
01:13:49.652 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.655 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:49.757 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.758 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘27’
01:13:49.760 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.763 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:49.865 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.866 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘18’
01:13:49.868 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.870 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:49.972 [DEBUG] [.o.b.m.internal.MilightBinding:350 ] - milight: sendDecrease
01:13:49.973 [DEBUG] [.o.b.m.internal.MilightBinding:383 ] - milight: Bulb ‘1’ getting decreased to ‘9’
01:13:49.975 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘34:00:55’
01:13:49.977 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘34:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)
01:13:50.079 [DEBUG] [.o.b.m.internal.MilightBinding:786 ] - milight: messageBytes to transform: ‘3B:00:55’
01:13:50.081 [DEBUG] [.o.b.m.internal.MilightBinding:778 ] - Sent packet ‘3B:00:55’ to bridge ‘bridge1’ (192.168.1.101:8899)

I will try to find the time to look into this.
BTW, we now have a native openHAB2 binding for the MiLight bulbs …

I’m also getting this kind of flaky behavior on my milight white bulbs. Some don’t come on to 100%, even though I’m sending the ON command to the brightness value. I’m seeing this when I send the ON to a group:switch the bulbs are assigned to.

If I jiggle the slider in Android I can get it back to 100%.

Not sure if there is anything I can do to help troubleshoot. This is on 1.8.3.

I’m also having the same problem. I tried implementing the virtual switch that was suggested in another post, but I’m getting an error

Cannot determine item type of 'officeVirtualLightON’
org.openhab.core.items.ItemNotFoundException: Item ‘officeVirtualLightON’ could not be found in the item registry

So I must not have that set up correctly, although I cannot spot the error.

Please post your item config and the rule you are using.

BTW, a PR is waiting to be merged to solve a dimming issue.
It can be found here for testing.

I have posted my files after a similar closed topic, since I tried that solution