Milight switches not working with RGBW

Hi All,

I’ve just setup openhab on Ubuntu following the apt-get install guide.
I’ve added the milight pairing and read the wiki entry on how to setup milight. The bridge is configured as “bridge1”.

My items looks like (I’ve omitted the groups):
Switch Light_Livingroom_All (Lights, Lounge) {milight=“bridge1;6”} #Switch to turn all RGBW Bulbs on/off
Switch Light_Livingroom_TV (Lights, Lounge) {milight=“bridge1;7”} #Switch for RGBW channel 1
Switch Light_Livingroom_Sofa (Lights, Lounge) {milight=“bridge1;9”} #Switch for RGBW channel 3

Which from what I can tell is correct.

The “all” switch works but the others do not. I click them an no action takes place.
I’ve turned on debugging level logging in the logback.xml and all I can see the following error;
Received command ‘TOGGLE’ for item ‘Light_Livingroom_TV’, but the item does not exist in the registry

My sitemap currently looks like;

sitemap default label=“Home”
{
Frame {
Group item=Lounge label=“Lounge” icon=“groundfloor”
Switch item=Light_Livingroom_All label=“All Lounge Lights”
Switch item=Light_Livingroom_TV label=“TV Lamp”
Switch item=Light_Livingroom_Sofa label=“Sofa Lamp”

    }

}

Am I missing something here in my setup that is causing this not to work?
Additionally the only item that actually shows in the group is the “All” switch.

Thanks!

1 Like

I have seen TOGGLE not work for items that don’t yet have a state (e.g. they are neither ON nor OFF at startup.) How are you toggling them if they don’t appear in the UI?

Also, if you are simply toggling them, what color do you expect when they turn on? Whatever they were set to when last turned off?

I have mine set like so (using mostly whiteMode):

Sitemap:

Switch item=Light_Living_White
Selection item=Light_Living_Scene mappings=[0=“White”, 1=“Red”, 2=“Yellow”, 3=“Green”, 4=“Dark Green”, 5=“Cyan”, 6=“Blue”, 7=“Magenta”, 8=“Orange”]

Items:

Number Light_Living_Scene “Scenes”
Color Light_Living_Scene_ColorSelect “Scene Selector” { milight=“bridge1;7;rgb” }

Switch Light_Living {milight=“bridge1;10”}
Switch Light_Living_White (gLightsAll_White) {milight=“bridge1;10;whiteMode”}

Rules:

rule “Light Scenes”
when
Item Light_Living_Scene received command
then
logInfo(“Light Scenes”, “Received command {}.”, receivedCommand)
if (receivedCommand==0) {
sendCommand(Light_Upstairs_White, “ON”)
}
if (receivedCommand==1) {
sendCommand(Light_Living_Scene_ColorSelect, new HSBType(new DecimalType(0),new PercentType(100),new PercentType(100)))
}
if (receivedCommand==2) {
sendCommand(Light_Living_Scene_ColorSelect, new HSBType(new DecimalType(60),new PercentType(100),new PercentType(100)))
}
if (receivedCommand==3) {
sendCommand(Light_Living_Scene_ColorSelect, new HSBType(new DecimalType(120),new PercentType(100),new PercentType(100)))
}
if (receivedCommand==4) {
sendCommand(Light_Living_Scene_ColorSelect, new HSBType(new DecimalType(120),new PercentType(100),new PercentType(50)))
}
if (receivedCommand==5) {
sendCommand(Light_Living_Scene_ColorSelect, new HSBType(new DecimalType(180),new PercentType(100),new PercentType(100)))
}
if (receivedCommand==6) {
sendCommand(Light_Living_Scene_ColorSelect, new HSBType(new DecimalType(240),new PercentType(100),new PercentType(100)))
}
if (receivedCommand==7) {
sendCommand(Light_Living_Scene_ColorSelect, new HSBType(new DecimalType(300),new PercentType(100),new PercentType(100)))
}
if (receivedCommand==8) {
sendCommand(Light_Living_Scene_ColorSelect, new HSBType(new DecimalType(24),new PercentType(84),new PercentType(89)))
}
end

This all works fine (changing color is sometimes flaky, but I haven’t had a chance to see why yet.)

Hope this helps.

Mark

One more thing: if you mean that the switches are showing up, just not in the group, try wrapping them in curly braces. I haven’t tested this, but it seems logical.

Group…{
Switch…
Switch…
}

Hey Mark,

Oddly my solution ended up being a lot simpler than expected. For some reason copy/paste using Nano over Putty (highlight > right click) was causing weird return characters to be entered into the items resulting in them not showing.
Removing my return characters then putting them in again seems to have resolved it now!

Thanks for sharing your code. It looks like you’ve done some bits that I aim to do next in that lot so I’ll use it as an example for scenes! :smile:

Andy-

I just stumbled back into this, and I wanted to update you with how I am now using colors, as I completely changed it (and it’s much simpler now.)

I have three items per milight zone (on/off switch, white switch, and colorwheel):

  • Switch Light_BackPorch “Back Porch” (gLightsOutside) {milight=“bridge1;7”}
  • Switch Light_BackPorch_White “Back Porch White” (gLightsAll_White) {milight=“bridge1;7;whiteMode”}
  • Color Light_BackPorch_Color “Back Porch Color” (gLights) {milight=“bridge1;7;rgb”}

And in my sitemap, I show the three items. Because the milight binding takes in a RSBType value, and the Colorpicker selects one (that is, the value created by a Colorpicker is a RSBType already) you can just wire it up like this:

  • Switch item=Light_Living
  • Switch item=Light_Living_White
  • Colorpicker item=Light_Living_Color

That’s all it takes.

Now, for some more fun ones that I set up (unrelated, but useful):

In my milight rules file:

  • // set the main switch to ON when the color changes (so it can be turned OFF later)

      rule Light_BackPorch_ColorChanged
      when 
      	Item Light_BackPorch_Color changed
      then	
      	Light_BackPorch.postUpdate(ON)
      end
    
  • // make sure I don’t forget to turn off the outside lights overnight (check more than once in case I’m up late)

      rule TurnOffLightsCron
      when 
      		Time cron "0 0 0 ? * *" or
      		Time cron "0 0 1 ? * *" or
      		Time cron "0 0 2 ? * *" or
      		Time cron "0 0 3 ? * *" or
      		Time cron "0 0 4 ? * *"
      then
      	logInfo("TurnOffLightsCron", "Turning off outside lights.")
      	sendCommand(gLightsOutside, OFF)
      end
    
  • // turn on back porch light when I get home, automatically (this depends on some kind of trigger sending a VoiceCommand - I am using Life360 to detect location and IFTTT to trigger the command when I enter the geofence around my house)

      rule "Auto Porch Light"
      when
      	Item VoiceCommand received command
      then
      	var String logName = "Auto Porch Light"
    
      	logInfo(logName, "Received command {}.", receivedCommand)
      	
      	var String command = VoiceCommand.state.toString.toLowerCase
      	logInfo(logName,"VoiceCommand received [{}]", command)    
      	
      	 if (command.contains("arrived") && command.contains("home"))
      	 {
      		 logInfo(logName, "Checking time [{}] relative to sunrise [{}] / sunset [{}].",now,Sunrise_Time.state, Sunset_Time.state)
      		if (now.isAfter((Sunset_Time.state as DateTimeType).calendar.timeInMillis)
      			   || now.isBefore((Sunrise_Time.state as DateTimeType).calendar.timeInMillis))
      		{
      			var String message = "Turning on outside lights."
      			logInfo(logName, message)
      			 sendCommand(Light_BackPorch_White, "ON")
      			 AndroidPush.apply(message)
      		 }
      		 else
      		 {
      			 logInfo(logName, "Daytime; not changing lights.")
      		 }
      	 }
      end
    
  • // turn on and off the living room light for the morning and evening

      rule "Auto living room light on"
      when
      	Time cron "0 0 7 ? * *" or
      	Item Sunset_Event changed from OFF to ON
      then
      	sendCommand(Light_Living_White, ON)
      end
    
      rule "Auto living room light off"
      when
      	Time cron "0 0 10 ? * *"
      then
      	sendCommand(Light_Living_White, OFF)
      end
    

Hope these help!

1 Like

Hi! I’m creating rules for milight, and for some reason the rule to change brightness or color doesnt work.
The set “item.color” to “180,100,14” or set “item.brightness” to 50 (syntax is just en example, I do it in openhab graphical designer) doesn’t affect milight, however it do change values in sitemap, and from sitemap manualy it work fine, only the rules doesn’t work. What command shuld i use to affect milight or where can be the problem? Log also says “item”.**** changed to the correct value but no affect on milight.

Roman-

What exact command are you using to set the value? I ask because there is one way that will update what OH sees the value as (postUpdate) and another (sendCommand) to both set it in OH and tell the light to change. The latter is what you will want.

Hope this helps!

Mark

Hi Mark! Thanks for your reply! I was doing everything in graphic rule designer(im not so experienced yet with programming, however can do simple stuff), so it tool like that:


I deleted the rule, stoped openhab and cleaned cache, created again the simple rule to test it out, and now it works, code look like this now:
38

Indeed there was "postUpdate " command and now it’s “sendCommand” instead.

why that could happen? some graphic designer bug or my mistake?

Also, do you know what is the right syntax to send RGB Value to the MiLight?

Wow, sorry, I’m way behind on checking up on posts here.

I’m not sure, as I’ve never used the graphic designer before. Anyway, I’m glad you figured it out before I went dark :grinning: