Yeelight moonlight mode doesn't work

Hello community,
I’m trying to setup an automation who set the moonlight mode for my Yeelight Ceiling Light (Jiaoyue 650).

Here is how the Yeelight ceiling light is declared on yeelight.yaml :

  192.168.2.26:
    name: Luce Tavolo
    model: ceiling4
    nightlight_switch_type: light

Here is the automation action (note that light.toggle, commented for testing, works perfect)

  action:
#  - service: light.toggle
#    entity_id: light.luce_tavolo
  - service: light.yeelight_set_mode
    data:
       mode: moonlight
       entity_id: light.luce_tavolo

But I got:

ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.toggle_luce_tavolo_deconz. Service not found for call_service at pos 1: Unable to find service light/yeelight_set_mode

Sure I’m missing something, could someone drive me to configure it properly? Thank you.

The service is called YEELIGHT.SET_MODE

Thank you very much I had read a wrong/old documentation.

Do you know how can I set moonlight brightness in template below?

  - service: yeelight.set_mode
    data_template:
      entity_id: light.luce_tavolo
      mode: >
        {%- if now().strftime('%H')| int >= 23 %}
          moonlight
        {%- elif now().strftime('%H')| int <= 7 %}
          moonlight
        {%- elif now().strftime('%H')| int > 7 %}
          normal
        {%- endif %}

No one? I don’t understand at all how to setup brightness in moonlight mode since the service doesn’t support that key :thinking:

Invalid data for call_service at pos 1: extra keys not allowed @ data['brightness']

EDIT: GOT IT!
From documentation:

nightlight_switch_type
(string)(Optional)
Adds another entity, to control nightlight mode (for models that supports it). Currently, only light is supported. It will create 2 light entities, one for normal light mode and second for nightlight mode. They are mutually exclusive.

So I have to change brightness to related entity:

entity_id: light.luce_tavolo_nightlight

Hey Lucas
Did you make this work?
When I add the “nightlight_switch_type: light”
I get an error in my config:

Error loading /home/homeassistant/.homeassistant/configuration.yaml: mapping values are not allowed here in “/home/homeassistant/.homeassistant/yeelights.yaml”, line 48, column 29

11:31 PM components/homeassistant/init.py (ERROR)
my config:

  192.168.1.241:
    name: light.ceiling.Kitchen
    #use_music_mode: true
    #save_on_change: true
    model: ceiling3
    nightlight_switch_type: light

without the “nightlight_switch_type: light” I get an binary which I can turn the night light on and off, but when I change the brightness it turns off and goes back to “normal” mode.
I like to use the nightlight for a sunrise routine/rule.

I’m having the same problem :confused: If anybody has it working, please share.

Hi guys,

Here is working code for me - bluetooth remotre (on / off) with cailc lamp and yeelight integration.

 - conditions:
            - condition: state
              entity_id: sensor.ble_remote
              state: long press sun
          sequence:
            - choose:
                - conditions:
                    - condition: state
                      entity_id: light.yeelight_ceilc
                      state: 'off'
                  sequence:
                    - service: YEELIGHT.SET_MODE
                      data:
                        entity_id: light.yeelight_ceilc
                        mode: moonlight
                - conditions: []
                  sequence:
                    - service: light.toggle
                      data: {}
                      target:
                        entity_id: light.yeelight_ceilc

You can set brightness with someting like that:

        - conditions:
            - condition: state
              entity_id: sensor.ble_remote_f82441ed5fe5
              state: long press -
          sequence:
            - service: light.turn_on
              data: 
                entity_id: light.yeelight_ceilc
                brightness_step_pct: -10

just adapt it to moonlight