Miio binding: Color channel of yeelight bulb does not change when command is sent to brightness channel


Sorry if this has been asked before but I could not find exactly this problem. Let me describe you step by step what needs to be done to replicate this. You may use other brightness values, this is just an example:

  1. Switch on bulb and change to color mode
  2. Set color to whatever value with a brightness of 100%
  3. Change to white mode
  4. Set brightness via brightness channel to 50%
  5. Switch to color mode -> Observe that the actual brightness of the lamp has been reduced to 50%
  6. Check color channel: Brightness is still 100%

=> The device runs out of sync with OH

Is this the expected behaviour or could this be a bug or does my bulb (modelId: yeelink.light.color5) behave differently than others?

I use the following code in a rule when a proxy brightness item receives a new value to fix this:

// Set the actual new brightness value

... do other stuff here ...

if (command > 0) {
  events.sendCommand('bedroom_lamp_wardrobe_brightness', command);
  // The brightness in the color mode is changed as well but we receive no update on the channel
  var color = ir.getItem('bedroom_lamp_wardrobe_color_virt').state;
  var updatedColor = new HSBType(new DecimalType(Math.round(color.hue, 0)), new PercentType(color.saturation), new PercentType(command));
  events.postUpdate('bedroom_lamp_wardrobe_color_virt', updatedColor);

I think it is not a thing specific to your yeelight, but rather the binding does not update the color channel with the brightness.

The binding (miio:basic) currently does not have the possibility to update a oh channel with a combination of 2 properties.
It is on my feature wishlist

I don’t know if it is possible to update the brightness of a color item with only the brightness, without providing the color at the same time. If that is possible it will be an easy fix