Brightness and Alexa Skill (Yeelight / Xiaomi)

Hi there,

I’m trying to use a yeelight LED bulb with the new Alexa Skill and the Xiaomi Mi IO Binding.openHab 2.4 release build.
I got everything to work except the brightness controll. The brightness channel is a “Number” Channel:

Number brightness "Brightness" (G_light) {channel="miio:generic:xxxxxxxx:brightness" }

Controlling it via PaperUI works as expected. But I just can’t get it working with alexa. Adding the alexa command directy to the item does not work, because BrightnessController.brightness does not support Numbers.

So I wrote myself a Dimmer item as a workaround to connect it to the Number item afterwards.

Dimmer brightness_alexa "Brightness Alexa" (G_light) {alexa="BrightnessController.brightness"}

This also works, but it just does not recognize the difference between lighter and darker (I’m German so for me it’s “dunkler” and “heller”).
So the following rule and even in the Alexa app the value increases, no matter if I say “Lampe dunkler” or “Lampe heller”. The value in brightness_alexa is increased everytime:

rule "Brightness Workaround"
     Item brightness_alexa changed
     logInfo("yeelight.rules", "Alexa Brightness verändert Yeelight" + brightness_alexa.state.toString)

What is wrong with my Alexa Dimmer? Setting it directly to 50 or another value works perfectly, but the keyword “darker” is ignored.
Can anyone help?

Thanks a lot!

You may want to upgrade to OH 2.5 as 2.4 is over a year old. Make sure to create a backup first. :wink:

Info for upgrading:


thanks for the answer. I did upgrade to the latest release 2.5.3 yesterday. Nothing changed in Alexas behaviour.

Brighten /increase (or “heller” in my case) does work.
Dim / Decrease (or “dunkler” in my case) does not work. It increases the value instead…

Is Dim not supported by the current openhab implementation or where is my mistake? :slight_smile:

Found a rule example on the forum to invert a dimmer command to Alexa, maybe this will help. It’s for color but you can adjust for brightness as needed.


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

rule "Buero_Colortemp_Test Changes"
  Item Buero_Colortemp_Test changed
  Buero_Colortemp_Alexa.postUpdate(100 - Buero_Colortemp_Test.state as PercentType)


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"]}

If you update to the latest snapshot version this should be resolved without need for rules
At least the brightness is a dimmer now

Hi, cool, thanks. It’s resolved now with 2.5.4 (latest I could find in the ppa).

One other strange thing occured however:
When I set the Dimmer to a level larger than 98 it immediately resets itself to the previous value.

2020-04-29 13:34:03.703 [vent.ItemStateChangedEvent] - Yeelight_brightness changed from 98 to 99
2020-04-29 13:34:03.812 [vent.ItemStateChangedEvent] - Yeelight_brightness changed from 99 to 98

The item itself is just

Dimmer Yeelight_brightness "Brightness" (Yeelight) {channel="miio:generic:xxxxxxx:brightness" }

That is really strange and kind of annoying, because setting it to 100 does not have any effect at all, because it simply resets. I did a workaroud by limiting the item to 97 in a rule but…

Is that also known and solved in 2.5.5?

Thanks a lot for your help!

Yes, in 2.5.5-snapshot this has been resolved.
It sends all values until 100%.

Some lights don’t like 0% and 100% and I made a change that avoided sending those. That was included in 2.5.4.

It had some non intuitive side effects like you saw hence I improved it.

1 Like

Great! Thanks a lot for the reply and the work.
I’ll wait for the 2.5.5 snapshot to be included in the Ubuntu unstable ppa. That still seems to be at 2.5.4.

If you want to stay on 2.5.4 you can do to following.

Download the json dB file for your device from GitHub put into the conf/misc/miio folder.
Remove the line with the condition in the brightness channel from the file. This will make that brightness is always send.