Enable Moonlight of Yeelight Ceiling with API


I realy like the Yeelight Ceiling and its Moonlight mode. I dim and adjust color by home-assistant. Now i wonder if it is possible to enable the Moonlight mode with the API as well. Right now i only saw the possibility to enable it with remote or cell phone. In the developer PDF is saw nothing about Moonlight.

Thanks for your help.


here is the API:

{"id":1,"method":"set_scene", "params": ["nightlight", 10]
//10 is brightness value
1 Like

That’s great - is there a way to set that scene with Alexa?

You can create a scene through scene management in Yeelight app and re-run discovery in Alexa. Then you can say “turn on ‘scene_name’”.

1 Like


Hello, is there a way to do a color flow with nightlight ?

start a color flow under nightlight mode

can you please let me know how to switch from the nightlight mode back to the standard mode using the API?
Thank you.


If the client keeps track of the Ceiling’s brightness and color temperature info, it could achieve this by set_ct_abx interface. But I assume this is untrue for your case.

There’s an extra parameter “mode” for set_power interface though, which can be used to switch to specific mode regardless of current power status.

  • Example 1: switch or turn on the light to last mode:
    {“method”:“set_power”,“params”:[“on”, “smooth”, 500, 0]}
  • Example 2: switch or turn on the light to normal mode:
    {“method”:“set_power”,“params”:[“on”, “smooth”, 500, 1]}
  • Example 2: switch or turn on the light to nightlight mode:
    {“method”:“set_power”,“params”:[“on”, “smooth”, 500, 5]}

Note this interface requires/allows no brightness or color information.

Other values for mode (not supported by Yeelight Ceiling):
2: switch to RGB mode
3: switch to HSV mode
4. switch to color flow mode

Hope this helps.

Thank you for your quick answer. It was very helpful.

Hi Peter (@yeelight_ceiling)

As i can read, you use Home assistant, and you added this lamp.

Please, can you tell me how did you added?

I’m using too home assistant, but i would like to know if this lamp is compatible, before buy it.

Also i see that is new version, but also i dunno if it will possible to add in home assistant.


It is supported using this component:


although moonlight is not supported yet. i use moonlight mode with a separate script

best regards

Hi Peter,

I’m also a HA user. Can you share you code that you used to enable moon mode in HA?

Thx in advance!

@liufei But if the light is OFF, then this command turn on and ignore Moon (“5”). If the light is ON, then it works. Why?

@staff Could someone comment?


can you look please?

hi,what’s is the model of your device(yeelink.light.ceilingxxx),or your MI ID please.

Where is this info? Its standard old 320.

you can update the firmware to 2.0.6_0193.
ps:{“id”:1,“method”:“get_prop”,“params”:[“model”]} can get the model info

Upgraded and tested.


With commands same problem: