Zigbee2mqtt - Aqara Opple switch 3 bands

You can use this blueprint to control 3 lights or groups with an 3 bands Aqara Opple switch (WXCJKG13LM).

It works very well with LED strips and Gledopto controllers (GL-C-008-1ID).

It is inspired by the blueprint of @starbuck93 (Zigbee2Mqtt - IKEA five button remote).

There are 24 actions possible with this switch and 18 of them are preconfigured in the blueprint:

  • left short press (buttons 1, 3, 5): turn off
  • right short press (buttons 2, 4, 6): turn on
  • left long press (buttons 1, 3, 5): decrese the brightness smoothly until released
  • right short press (buttons 2, 4, 6): increse the brightness smoothly until released
  • right double press (buttons 1, 3, 5): turn on with the warmest light (500 mired)
  • right double press (buttons 2, 4, 6): turn on with the coldest light (153 mired)

The rest of 6 actions (the triple clicks) are customizable to answer to everyone’s needs.

You can import the blueprint by using the current forum topic URL.

blueprint:
  name: Z2M - Aqara Opple switch 3 bands
  description: 'Control 3 lights with an Aqara Opple switch 3 bands (WXCJKG13LM).
  
  Inspired by the blueprint of @starbuck93 (https://community.home-assistant.io/t/zigbee2mqtt-ikea-five-button-remote/255308)
  
  It works very well with LED strips and Gledopto controllers (GL-C-008-1ID).
    
    Each band controls one light/group.
    
    - left short press (buttons 1, 3, 5): turn off
    
    - right short press (buttons 2, 4, 6): turn on
    
    - left long press (buttons 1, 3, 5): decrese the brightness smoothly until released
    
    - right short press (buttons 2, 4, 6): increse the brightness smoothly until released
    
    - right double press (buttons 1, 3, 5): set the warmest light (500 mired)
    
    - right double press (buttons 2, 4, 6): set the coldest light (153 mired)
    
    - triple clicks: customizable
    
      '
  domain: automation
  input:
    switch:
      name: Aqara switch
      description: Aqara switch to use
      selector:
        entity:
          domain: sensor
    light_1:
      name: Light(s)
      description: The light(s) to control
      selector:
        target:
          entity:
            domain: light
    light_2:
      name: Light(s)
      description: The light(s) to control
      selector:
        target:
          entity:
            domain: light
    light_3:
      name: Light(s)
      description: The light(s) to control
      selector:
        target:
          entity:
            domain: light
    button_1_triple:
      name: Button 1 - triple click
      description: Action to run on triple click of button 1
      default: []
      selector:
        action: {}
    button_2_triple:
      name: Button 2 - triple click
      description: Action to run on triple click of button 2
      default: []
      selector:
        action: {}
    button_3_triple:
      name: Button 3 - triple click
      description: Action to run on triple click of button 3
      default: []
      selector:
        action: {}
    button_4_triple:
      name: Button 4 - triple click
      description: Action to run on triple click of button 4
      default: []
      selector:
        action: {}
    button_5_triple:
      name: Button 5 - triple click
      description: Action to run on triple click of button 5
      default: []
      selector:
        action: {}
    button_6_triple:
      name: Button 6 - triple click
      description: Action to run on triple click of button 6
      default: []
      selector:
        action: {}
mode: restart
max_exceeded: silent
trigger:
- platform: state
  entity_id: !input 'switch'
  attribute: action
action:
- variables:
    command: '{{ trigger.to_state.state }}'
- choose:
  - conditions:
    - '{{ command == ''button_1_single'' }}'
    sequence:
    - service: light.turn_off
      target: !input 'light_1'
      data: {}
  - conditions:
    - '{{ command == ''button_2_single'' }}'
    sequence:
    - service: light.turn_on
      data: {}
      target: !input 'light_1'
  - conditions:
    - '{{ command == ''button_3_single'' }}'
    sequence:
    - service: light.turn_off
      data: {}
      target: !input 'light_2'
  - conditions:
    - '{{ command == ''button_4_single'' }}'
    sequence:
    - service: light.turn_on
      data: {}
      target: !input 'light_2'
  - conditions:
    - '{{ command == ''button_5_single'' }}'
    sequence:
    - service: light.turn_off
      data: {}
      target: !input 'light_3'
  - conditions:
    - '{{ command == ''button_6_single'' }}'
    sequence:
    - service: light.turn_on
      data: {}
      target: !input 'light_3'
  - conditions:
    - '{{ command == ''button_1_double'' }}'
    sequence:
    - service: light.turn_on
      target: !input 'light_1'
      data:
        color_temp: '500'
  - conditions:
    - '{{ command == ''button_2_double'' }}'
    sequence:
    - service: light.turn_on
      target: !input 'light_1'
      data:
        color_temp: '153'
  - conditions:
    - '{{ command == ''button_3_double'' }}'
    sequence:
    - service: light.turn_on
      target: !input 'light_2'
      data:
        color_temp: '500'
  - conditions:
    - '{{ command == ''button_4_double'' }}'
    sequence:
    - service: light.turn_on
      target: !input 'light_2'
      data:
        color_temp: '153'
  - conditions:
    - '{{ command == ''button_5_double'' }}'
    sequence:
    - service: light.turn_on
      target: !input 'light_3'
      data:
        color_temp: '500'
  - conditions:
    - '{{ command == ''button_6_double'' }}'
    sequence:
    - service: light.turn_on
      target: !input 'light_3'
      data:
        color_temp: '153'
  - conditions:
    - '{{ command == ''button_1_hold'' }}'
    sequence:
    - repeat:
        until:
        - condition: state
          entity_id: !input 'switch'
          state: button_1_release
          attribute: action
        sequence:
        - service: light.turn_on
          data:
            brightness_step_pct: -10
            transition: 0.5
          target: !input 'light_1'
        - delay: '0.2'
  - conditions:
    - '{{ command == ''button_2_hold'' }}'
    sequence:
    - repeat:
        until:
        - condition: state
          entity_id: !input 'switch'
          state: button_2_release
          attribute: action
        sequence:
        - service: light.turn_on
          data:
            brightness_step_pct: 10
            transition: 1
          target: !input 'light_1'
        - delay: '1'
  - conditions:
    - '{{ command == ''button_3_hold'' }}'
    sequence:
    - repeat:
        until:
        - condition: state
          entity_id: !input 'switch'
          state: button_3_release
          attribute: action
        sequence:
        - service: light.turn_on
          data:
            brightness_step_pct: -10
          target: !input 'light_2'
        - delay: '1'
  - conditions:
    - '{{ command == ''button_4_hold'' }}'
    sequence:
    - repeat:
        until:
        - condition: state
          entity_id: !input 'switch'
          state: button_4_release
          attribute: action
        sequence:
        - service: light.turn_on
          data:
            brightness_step_pct: 10
          target: !input 'light_2'
        - delay: '1'
  - conditions:
    - '{{ command == ''button_5_hold'' }}'
    sequence:
    - repeat:
        until:
        - condition: state
          entity_id: !input 'switch'
          state: button_5_release
          attribute: action
        sequence:
        - service: light.turn_on
          data:
            brightness_step_pct: -10
          target: !input 'light_3'
        - delay: '1'
  - conditions:
    - '{{ command == ''button_6_hold'' }}'
    sequence:
    - repeat:
        until:
        - condition: state
          entity_id: !input 'switch'
          state: button_6_release
          attribute: action
        sequence:
        - service: light.turn_on
          data:
            brightness_step_pct: 10
          target: !input 'light_3'
        - delay: '1'
  - conditions:
    - '{{ command == ''button_1_triple'' }}'
    sequence: !input 'button_1_triple'
  - conditions:
    - '{{ command == ''button_2_triple'' }}'
    sequence: !input 'button_2_triple'
  - conditions:
    - '{{ command == ''button_3_triple'' }}'
    sequence: !input 'button_3_triple'
  - conditions:
    - '{{ command == ''button_4_triple'' }}'
    sequence: !input 'button_4_triple'
  - conditions:
    - '{{ command == ''button_5_triple'' }}'
    sequence: !input 'button_5_triple'
  - conditions:
    - '{{ command == ''button_6_triple'' }}'
    sequence: !input 'button_6_triple'
7 Likes

@razvanmdobre Your blueprint looks great but I’m unable to use it because I don’t have a sensor (input) for the Xiaomi device. Can you explain a little bit more about the (MQTT?) sensor? Did you create a sensor based on a MQTT topic?

At the moment I’m using automations based on MQTT device triggers. I don’t like them because they can only be created using the UI and I’m using yaml for my automations. Another thing is that they contain a device_id / discovery_id that can only be retrieved by creating the automation using the UI and view the generated yaml code.

So please let me know how I can use your blueprint.

Hi,

I am using zigbee2mqtt add-on. It creates it automatically.

Thanks. Also works on the 2 bands one!

Hey. Thanks for it, I somehow cannot make it work :frowning: .
This is what I have generated in automations.yaml when using the blueprint (and for simplicity) setting the light:

- id: '1618747060078'
  alias: Z2M - Aqara Opple switch 3 bands
  description: ''
  use_blueprint:
    path: razvanmdobre/zigbee2mqtt-aqara-opple-switch-3-bands.yaml
    input:
      switch: sensor.tripleswitch_action
      light_1:
        entity_id: light.testzarovka1
      light_2:
        entity_id: light.testzarovka1
      light_3:
        entity_id: light.testzarovka1

When I trigger the automation via the button or “Run action”, it does nothing. I only once noticed (when subscribing to mqtt topic) that it tried to send “switch off” command to the bulb, but that was all. Then nothing. I cannot see anything interesting in the trace log, just “Still running” after the button click was registered and then it hangs. Annoyingly, it also somehow makes the automation “buggy” as it cannot be switched off for some reason (the slider is toggled to “off”, but goes back to “on” on a page refresh).

Any help please?

Hello. After updating to version core-2021.4.5, automation stopped working. When any key is pressed, nothing happens. When rolled back to core-2021.4.4, it starts working well. What needs to be fixed to work on the latest version of XA? Any help would be grateful to you.
P.S.
Corrected " Fix race when restarting script" with the new version, everything works.

I am happy to see that the issue have been solved. Please keep sharing this the of post.

Thanks,

MyCCPay Login

i see the same behavior as well, newer HA, broke automations based on blueprints, any hints?

Hey. Is there a version that would work with the new non-legacy homeassistant triggers (homeassistant_legacy_triggers: false setting in the z2m config)? Or is it independent (I cannot make it work somehow :frowning: )?

Great blueprint. Anyone else having issues with the hold functions? I’m running 2022.10.5 on 9.2 OS and the repeat functions only run once.

Same here. The hold function does not loop. you have to long press, releaase, long press release. Did you find a solution to this?

1 Like

I have the same problem with long press.

Did anyone find a solution for the long press?

still broken. will there be a fix or is there a workaround?

1 Like

find a fixed version, this one is working as expected :heart_eyes: