Widget for yeelight pendant lamps


This is a rather specific widget for yeelight lamps with an additional ambient light on the top. Since these lamps offer a huge variety of controls it was pretty challenging to combine all those into one tiny widget.

Important notes

  • My Yeelight model is a yeelink.light.ceiling10. Despite the miio binding documentation claims that the ambient color mode maps like this: “1”=“CT mode”,“2”=“RGB mode” it seems that actually RGB mode is mapped to 1 and CT mode is mapped to 2. The widget currently implements these “inverted” mode mappings. If you have a different model you may need to apply some changes to match the logic of your model.
  • It seems that the ambient color mode right now cannot be used to acutally toggle the color mode. The light does not change and the widget will toggle back to the previous color mode unless you quickly use the temperature or color wheel controls. To fix this I added some simple rules that reapply the current color or temperature setting whenever the color mode is changed. In addition to that you need to change the profile of the color mode link to “follow”.

These however are binding issues and don’t seem to be related to the widget itself.


  1. Download via marketplace or paste widet code in dev tools (see Ressources section below). Please note that the Footer text is hard coded (“Licht an” → On, “Licht aus” → Off) so please adapt to your localization. I might add some localization properties in future versions to make updates easier for you.
  2. Create a string item that will represent the ambient color as RGB value (required to show the ambient color light in the widget)
  3. Create a rule that is triggered when the ambient color item is changed and create an ECMA Code action and paste the code from section Code for the RGB Rule below. Make sure to change the name of the item in the code to match the name of the item created in step 2.
  4. Add widget to a page and configure the items. I think this is pretty straight forward when you have all the relevant channels mapped to items (Ambient Color RGB should point to the item created in step 2.). Please note that the shutdown timer is not supported by the lamp itself and thus needs to be created manually via a rule. You may use the rule posted below in section Shutdown Timer Rule, trigger this rule on every change of the timer item (dining_lamp_timer in the example code). It is not super sophisticated, please adapt to your needs.
  5. Note that by default for the yellight pendant lamps the ambient light will be switched on and off together with the main toggle. This behaviour can be changed in the official yeelight app. I recommend to disable this behaviour and use openHAB rules if you want to couple the lights together. I use a rule to toggle the ambient ON together with the main lamp but I don’t want it to be toggled OFF.

Code for the RGB Rule

var color = new HSBType(new DecimalType(Math.round(newState.hue)), new PercentType(100), new PercentType(100))
var rgbString = Math.round(color.red * 2,55) + "," + Math.round(color.green * 2,55) + "," + Math.round(color.blue * 2,55);
events.postUpdate("dining_lamp_ambient_color_rgb", rgbString);

Shutdown Timer Rule

var ScriptExecution = (this.ScriptExecution === undefined) ? Java.type("org.openhab.core.model.script.actions.ScriptExecution") : this.ScriptExecution;
var ZonedDateTime = (this.ZonedDateTime === undefined) ? Java.type("java.time.ZonedDateTime") : this.ZonedDateTime;

if (this.decreaseOneMinute != undefined) {
  this.decreaseOneMinute = undefined;

if (newState == 0) {
  events.sendCommand('dining_lamp_ambient', OFF);
  events.sendCommand('dining_lamp_main', OFF);
} else if (newState > 0) {
  var currentTime = ZonedDateTime.now();
  var targetTime = currentTime.plusMinutes(1);
  this.decreaseOneMinute = ScriptExecution.createTimerWithArgument(targetTime, newState, function(minutes) {
    events.postUpdate('dining_lamp_timer', minutes - 1);


Version 0.7

  • fixed: when ambient light is in CCT mode the widget shows white light on top of the lamp

Version 0.6

  • initial release




Hi @marcel_verpaalen

could you please have a look at the known issues section above? I just checked the sources and I see the following in the yeelink.light.ceiling4.json file:

							"value": "2",
							"label": "CT mode"
							"value": "1",
							"label": "RGB mode"

To be honest I don’t know the binding code well enough to know exactly what this file does but shouldn’t CT mode be set to 1 and RGB to 2? This is the way other lamps behave and what the binding documentation says as well.

Also Ambient Color Mode is configured like this:

				"property": "bg_lmode",
				"friendlyName": "Ambient Color Mode",
				"channel": "ambientColorMode",
				"channelType": "ambientColorMode",
				"type": "Number",
				"refresh": true,
				"actions": []

Shouldn’t there be any actions? In fact the color mode channel of the downlight has some actions but it does not support color light at all. Only the ambient lighting supports CT and RGB modes.

Again I don’t know exactly how the binding works but this seems to match my observations as described in the “Known Issues”. Thanks for your help!

I’ll double check.
I vaguely remember similar issue on other yeelights. Could also be the discrepancy/strangeness between the yeelight spec and the reality.

but also

1 Like

Oh I see there’s room for interpretation in the specs :sweat_smile:

Please let me know if I can assist you in any way! Thanks!

I updated the first post with my latest widget code. I do consider the widget being “stable” now. There are a couple of issues remaining concerning the binding that I could however circumvent with additional rules.