WiFi Binding - change RGBW to GRBW

Hi everybody!

I am wondering if it is possible to change the output of my LED controller from RGBW to GRBW.

I ordered an RGBW Stripe and a Magic Home Wifi Controller (protocol LD382A).
I connected everything and i am wondering why the colors are not correct. I see that the cables on the Stripe are not in the RGBW order. They are instead in GRBW.

I would like to use this strip outdoors, so i would prefer not to soldering on the cables to not destroy the ip67 waterproof cert.

Is it possible somehow to change this behaviour in openhab via script or something else? I tried to find a solution online but i did not found anything.


Assuming you purchased an Arilux controller, I believe many of these are counterfeit. I had the same issue with some I purchased from Bangood. After a bit of discussion with them, I was refunded my money. You can resolder them or just swap the wires around outside of the controller (but it looks like you are aware of this!). Probably the best option for you is to create another Item and rule to convert the values.

Of course, an update to the binding could be made to provide a Thing configuration to allow remapping the colors.

I think the controller is working fine, because i see that the colors on the cable wich is soldered to the Strip have this “wrong” order. Here is a picture of the controller and from the cable…

Can you maybe explain how to convert the values so i can correct it via “software”? I have no idea where to start here…

Add a Converted_Color_Item linked to the Channel and remove the link from the Old_Color_Item. Then this should work…

from core.rules import rule
from core.triggers import when

@rule("Correct colors")
@when("Item Test_Color_1 changed")
def correct_colors(event):
    red = int((event.itemState.green.intValue() * 2.55) + 0.5)
    green = int((event.itemState.red.intValue() * 2.55) + 0.5)
    blue = int((event.itemState.blue.intValue() * 2.55) + 0.5)
    events.sendCommand("Test_Color_2", HSBType.fromRGB(red, green, blue).toString())

ok… i think i am missing something here… i am not really fit in this rules stuff.

This is my items file now:

Switch Terrasse_LED_power "Power" (Light) {channel="wifiled:wifiled:2CF432F4F7AC:power"}
Dimmer Terrasse_LED_white "White" (Light) {channel="wifiled:wifiled:2CF432F4F7AC:white"}
Color  Terrasse_LED_color "Color" (Light) 
Color  Terrasse_LED_color_corrected "Color" (Light) {channel="wifiled:wifiled:2CF432F4F7AC:color"}

and the new rules file:

from core.rules import rule
from core.triggers import when

@rule("Correct colors")
@when("Item Terrasse_LED_color changed")
def correct_colors(event):
      events.sendCommand("Terrasse_LED_color_corrected", HSBType().fromRGB(event.itemState.green, event.itemState.red, event.itemState.blue).toString())

rule file could not be read because of an error. I think the rule “Correct colors” is not there… because I can manage the stripe directly from the sliders without any rule in between…

The example I provided was using the new rule engine, Jython and the helper libraries…

To use this in the legacy rules DSL, you’d do something like this…

      Terrasse_LED_color_corrected.sendCommand(HSBType.fromRGB(newState.green.intValue, newState.red.intValue, newState.blue.intValue))

Completely different approach: why don’t just change the wiring? Some male to female jumper cables should do the job and the are very cheap.
I think this is the approach with the less effort needed

Waterproof jumpers?

Attach the jumper cables and the seal it. The cables themselves should be waterproof I guess and you can seel the connectors for example with hot glue

Jumper cables are a good idea! I can put them together with the controller in a sealed box… but I think they are a little bit too thin for a 5m strip?

Apparently you were not aware of this :slightly_smiling_face:! This is what I did, but I did not pot them since they are used indoors.

No they aren’t. I use them in a lot of projects with 5m LED strips. Works perfectly fine

Ok! I will give it a try and keep an eye on it for a while! :wink:

But nevertheless, I am also interested to understand how it would work with this rule… I will try tomorrow to bring it to life… never stop learning! :crazy_face:

Ok… i tried to change the order of the cables with jumpercables, but the connectors are to big to put it in to the strip. Also on the controller side the female jumper cable don´t stuck on the male connector.

So i tried the rule from @5iver:

led_stripe rule:

rule "Terrase Korrektur"

when Item Terrasse_LED_color changed 


    Terrasse_LED_color_corrected.sendCommand(HSBType.fromRGB(newState.green.intValue, newState.red.intValue, newState.blue.intValue))


And this errors are visible in the logfile:

2020-08-19 08:24:10.135 [ome.event.ItemCommandEvent] - Item 'Terrasse_LED_color' received command 159.8026601534175,54.98538121474191,0.5494505494505475

2020-08-19 08:24:10.140 [vent.ItemStateChangedEvent] - Terrasse_LED_color changed from 0.0,0.0,0.0 to 159.8026601534175,54.98538121474191,0.5494505494505475

==> /var/log/openhab2/openhab.log <==

2020-08-19 08:24:10.143 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Terrase Korrektur': 'green' is not a member of 'org.eclipse.smarthome.core.types.State'; line 13, column 62, length 14

==> /var/log/openhab2/events.log <==

2020-08-19 08:24:10.443 [ome.event.ItemCommandEvent] - Item 'Terrasse_LED_color' received command 159.8026601534175,54.98538121474191,33.51648351648352

==> /var/log/openhab2/openhab.log <==

2020-08-19 08:24:10.451 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Terrase Korrektur': 'green' is not a member of 'org.eclipse.smarthome.core.types.State'; line 13, column 62, length 14

==> /var/log/openhab2/events.log <==

2020-08-19 08:24:10.453 [vent.ItemStateChangedEvent] - Terrasse_LED_color changed from 159.8026601534175,54.98538121474191,0.5494505494505475 to 159.8026601534175,54.98538121474191,33.51648351648352

2020-08-19 08:24:10.762 [ome.event.ItemCommandEvent] - Item 'Terrasse_LED_color' received command 159.8026601534175,54.98538121474191,58.60805860805861

2020-08-19 08:24:10.769 [vent.ItemStateChangedEvent] - Terrasse_LED_color changed from 159.8026601534175,54.98538121474191,33.51648351648352 to 159.8026601534175,54.98538121474191,58.60805860805861

==> /var/log/openhab2/openhab.log <==

2020-08-19 08:24:10.770 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Terrase Korrektur': 'green' is not a member of 'org.eclipse.smarthome.core.types.State'; line 13, column 62, length 14

==> /var/log/openhab2/events.log <==

2020-08-19 08:24:11.083 [ome.event.ItemCommandEvent] - Item 'Terrasse_LED_color' received command 159.8026601534175,54.98538121474192,97.25274725274726

==> /var/log/openhab2/openhab.log <==

2020-08-19 08:24:11.090 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Terrase Korrektur': 'green' is not a member of 'org.eclipse.smarthome.core.types.State'; line 13, column 62, length 14

==> /var/log/openhab2/events.log <==

2020-08-19 08:24:11.090 [vent.ItemStateChangedEvent] - Terrasse_LED_color changed from 159.8026601534175,54.98538121474191,58.60805860805861 to 159.8026601534175,54.98538121474192,97.25274725274726

2020-08-19 08:24:11.401 [ome.event.ItemCommandEvent] - Item 'Terrasse_LED_color' received command 159.8026601534175,54.98538121474191,100.0

2020-08-19 08:24:11.408 [vent.ItemStateChangedEvent] - Terrasse_LED_color changed from 159.8026601534175,54.98538121474192,97.25274725274726 to 159.8026601534175,54.98538121474191,100.0

==> /var/log/openhab2/openhab.log <==

2020-08-19 08:24:11.409 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Terrase Korrektur': 'green' is not a member of 'org.eclipse.smarthome.core.types.State'; line 13, column 62, length 14

==> /var/log/openhab2/events.log <==

2020-08-19 08:24:11.712 [ome.event.ItemCommandEvent] - Item 'Terrasse_LED_color' received command 159.8026601534175,54.98538121474191,100.0

2020-08-19 08:24:12.173 [ome.event.ItemCommandEvent] - Item 'Terrasse_LED_color' received command 159.8026601534175,54.98538121474191,100.0

maybe there is an import or some type conversion missing?

Maybe, could be - but to be honest, this is out of the range of my knowledge of rule writing

Same… that’s why I liked the idea with just switching the cables

The rules DSL is terrible for stuff like this! Also, the red/green/blue attributes of HSBType return PercentType, so they need to be converted to byte in order to use them to build an HSBType. This was really easy in Jython and took WAY too much time to work it out for the rules DSL, but this should work for you…

rule "Terrase Korrektur"
    Item Terrasse_LED_color changed 
    val red = Math.round(Terrasse_LED_color.getStateAs(HSBType).green.intValue * 2.55) as int
    val green = Math.round(Terrasse_LED_color.getStateAs(HSBType).red.intValue * 2.55) as int
    val blue = Math.round(Terrasse_LED_color.getStateAs(HSBType).blue.intValue * 2.55) as int

    Terrasse_LED_color_corrected.sendCommand(HSBType.fromRGB(red, green, blue))

Donations gratefully accepted!


This works like a charm! Thank you very much! I really appreciate your effort for helping me out here!

2020-08-19 18.10.50

1 Like

one small question to the end…i noticed that i am not able to set pure red for example… is this because of the multiplication with 2.55 in the rule?`

This is what i see in the logfile:

2020-08-19 21:08:52.600 [ome.event.ItemCommandEvent] - Item 'Terrasse_LED_color' received command 1.837736790387805,99.99999999999997,28.205128205128204

2020-08-19 21:08:52.608 [vent.ItemStateChangedEvent] - Terrasse_LED_color changed from 357.3834649214174,99.5690476651169,28.205128205128204 to 1.837736790387805,99.99999999999997,28.205128205128204

2020-08-19 21:08:52.633 [ome.event.ItemCommandEvent] - Item 'Terrasse_LED_color_corrected' received command 120,100,27

2020-08-19 21:08:52.636 [nt.ItemStatePredictedEvent] - Terrasse_LED_color_corrected predicted to become 120,100,27

2020-08-19 21:08:52.645 [vent.ItemStateChangedEvent] - Terrasse_LED_color_corrected changed from 122,100,27 to 120,100,27