OpenHAB & Alexa & Milight - invert command action

Dear Community,
I would like to be able to control LED lighting using Alexa.

These components I am using for this purpose:

*) OpenHAB 2.5.1 (stable)
-> OpenHAB Cloud Service
-> Milight Binding
) MiLight Wifi Bridge Box Controller iBox2
) MiLight Controller YL5 (RGBWW)
*) RGBWW Led Stripe
*) Amazon Echo (Alexa)

myopenhab.org service registered, Alexa Skill installed and connected.

I added the Wifi Bridge as a THING as follows:

mi-light.things:

Bridge milight:bridgeV6:98D86370BBAC [ host=“192.168.10.155”, bridgeid=“98D86370BBAC”, passwordByte1=0, passwordByte2=0, repeat=2, delayTime=75 ] {Thing rgbwwLed 1 [ zone=“1” ] }

It was discovered correctly and set ONLINE:

14:36:21.038 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - ‘milight:bridgeV6:98D86370BBAC’ changed from OFFLINE (CONFIGURATION_PENDING): Waiting for session to ONLINE
14:36:21.052 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - ‘milight:rgbwwLed:98D86370BBAC:1’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE

Now I wanted to try out changing the temperature color:
For this purpose I created the following ITEM and let the Alexa successfully search for this device:

alexa.items:

Dimmer Buero_Colortemp_Test “Büro Farbe” {channel=“milight:rgbwwLed:98D86370BBAC:1:ledtemperature”, alexa=“ColorTemperatureController.colorTemperatureInKelvin” [range=“2700:6500”,increment=“2500”]}

Now, when I say “Alexa, switch “Büro Farbe” to coldwhite” Alexa switches to warmwhite and vice versa.
So, in the Paper UI the dimmer at 0% is “warmwhite” and at 100% maximun of “coldwhite” but it should be the other way round.

Has anyone had this situation and can help me here?
Is there a way to invert the commands?

I am grateful for every answer!

Based on the Philips Hue and LIFX bindings, the standard way to model a color temperature channel is via a Dimmer item with values ranging from cold (0%) to warm (100%). Are you saying that the MiLight binding implemented the opposite?

Unfortunately, the Alexa skill uses the same standard and doesn’t have an option to invert that value directly on the channel item. You would need to use a proxy item that would update the color temperature item accordingly through an OH rule.

As a side note, the increment parameter value should match the item type. Therefore, you should specify a percentage and not a temperature value.

Hello jeshab,
thank you for your quick response.

Based on the Philips Hue and LIFX bindings, the standard way to model a color temperature channel is via a Dimmer item with values ranging from cold (0%) to warm (100%). Are you saying that the MiLight binding implemented the opposite?

Yes, it seems so that the MiLight Binding works the wrong way in my case.
MiLight Remote and Mobile App controls the light in correct order.

Unfortunately, the Alexa skill uses the same standard and doesn’t have an option to invert that value directly on the channel item. You would need to use a proxy item that would update the color temperature item accordingly through an OH rule.

Thanks for this Hint - do you have a simple sample for me?

As a side note, the increment parameter value should match the item type. Therefore, you should specify a percentage and not a temperature value.

yeah, the increment parameter is a relic from the different valid item type “Number”.

items

Dimmer Buero_Colortemp_Test "Büro Farbe" {channel="milight:rgbwwLed:98D86370BBAC:1:ledtemperature"}
Dimmer Buero_Colortemp_Alexa "Büro Farbe" {alexa="ColorTemperatureController.colorTemperatureInKelvin" [range="2700:6500"]}

rules

rule "Buero_Colortemp_Alexa Commands"
when
  Item Buero_Colortemp_Alexa received command
then
  Buero_Colortemp_Test.sendCommand(100 - receivedCommand as PercentType)
end

rule "Buero_Colortemp_Test Changes"
when
  Item Buero_Colortemp_Test changed
then
  Buero_Colortemp_Alexa.postUpdate(100 - Buero_Colortemp_Test.state as PercentType)
end
1 Like

Hi Jeremy,
with the rules, it works exactly as it should.
Thank you very much for your support and your quick solution

1 Like