Aqara Opple 6 - button, how to hold to dim?

Post your automation. Are you using ZHA, Z2M or a completely different integration? Do those buttons support both long press and long release actions?

Easiest way (that I used myself) would be to simply have an infinite loop that begins dimming when a long press is detected, then break the loop on a long release by having the automation in mode: restart.

Thanks for your reply!

I haven’t set up an automation at the moment as I’ve just reset my blueprints so they are empty. I’m running Z2M, updated to 2.0 and with experimental events exposed. I can turn lights on and off easily. Screen looks like this:

I can add pretty much anything on the HOLD BUTTON action.
The Aqara Exposes both a HOLD BUTTON and RELEASED BUTTON action.

If I set up a brightness increase on HOLD it will run once, but not repeat. Not sure how to set it up to repeat endlessly until the action says RELEASED.

By far easiest way is to use light.turn_on with the brightness_step parameter inside an infinite loop, but that would require the automation or in this case blueprint to be running in mode: restart or the loop would not automatically break when releasing the button. So in your case I’d probably just edit the blueprint to use mode: restart if it doesn’t already.

So, after some searching it seems I only add this top line to the blueprint.yaml file?

mode: restart
blueprint:
  name: Aqara Opple switch 3 bands via zigbee2mqtt
  description: "Control anything you want with Aqara Opple switch 3 bands (WXCJKG13LM)\n
    \   Each band button has single, double, triple, hold & release.\n    Credits:\n
    \    - @bouyssic created with 4-Button  https://community.home-assistant.io/t/z2m-aqara-opple-4-boutons-blueprint-wxcjkg12lm/279950\n

?

Pretty much. Or if there already is a mode line somewhere in the blueprint, replace its current value with restart.

Then just put your dimming action inside an infinite loop and it should be broken when you release the button. Remember to add a transition time to the dimming action or it may dim from zero to full brightness very quickly. May also want to add a short delay between dimming if you want the discrete steps to be visible, or not depending on your tastes… Here’s an example:

- repeat:
    count: 10
    sequence:
      - action: light.turn_on
        target: !input lights
        data:
          brightness_step_pct: 25
          transition: 0.5
      - delay: 0.5

Edit: You must have a delay which at least matched the transition time, otherwise the loop will keep executing as fast as it possibly can as the light.turn_on action itself doesn’t takes no time.

Thanks for great feedback - not getting it fully there yet. Since this is very much a GUI approach I tried this based on your input:

Should this work? “kontor.spotskinne” is my spotlight entity in the office. It’s a light group of spot-bulbs.

No. Your lights cannot possibly have such an entity id, as it must begin with “light.” and the rest of the id can only consist of lowercase letters, numbers and underscores (no additional periods). Also you must put the entity id on a new line prefixed with entity_id, my example was from a blueprint using a target selector.

- action: light.turn_on
  target:
    entity_id: light.kontor_spotskinne
  …

Sorry, that was a typo on my side. I have primarily been working with gui and then it just shows as kontor.spotskinne. You are correct, it’s called light.kontor_spotskinne.

However, it still doesn’t work. It looks like this now:

I look at the config yaml in “Traces” and see the following setup:

id: '1736186965041'
alias: Aqara Opple switch 3 bands via zigbee2mqtt Kontoret Test2
description: ''
use_blueprint:
  path: XenorPLxx/aqara_opple_6_button_remote.yaml
  input:
    aqara_switch: event.aqara_3button_kjeller_action
    button_2_single:
      - action: light.turn_off
        metadata: {}
        data: {}
        target:
          entity_id: light.kontor_spotskinne
    button_1_single:
      - action: light.turn_on
        metadata: {}
        data:
          brightness_pct: 20
        target:
          entity_id: light.kontor_spotskinne
    button_1_hold:
      - repeat:
          count: 10
          sequence:
            - action: light.turn_on
              target:
                entity_id: light.kontor_spotskinne
              data:
                brightness_step_pct: 25
                transition: 0.5


Does it look ok?

Define “doesn’t work”. Nothing happens? Something unexpected happens? Is there an error in trace?

I always forget something though, and this time it is that you must add a delay which at the very least matches your transition time. This because the light.turn_on action itself takes no time, so without a delay the loop would keep repeating the light.turn_on action as quickly as it can. So do add a new line with - delay: 0.5 at the end of the loop (dash aligned with the dash of - action: light.turn_on above).

By “doesn’t work” I mean that nothing happens. There is no action at all. Can’t see any error in Traces either. I did the delay change that you said, but that didn’t do any difference. I feel I’m missing something crucial here…
Both the turn on and turn off from the same blueprint works flawlessly…

Appreciate you taking the time to help me here :slight_smile:

    button_1_hold:
      - repeat:
          count: 10
          sequence:
            - action: light.turn_on
              target:
                entity_id: light.kontor_spotskinne
              data:
                brightness_step_pct: 25
                transition: 0.5
            - delay: 0.5

Well the code looks correct at least. If you put any other action in there does the button do what it is supposed to, or does nothing happen? If you go into Settings > Devices > Z2M and into your device, do you get anything in the rightmost column Logbook when pressing the button in different ways?

This one took me some time to figure out.
It is not very cleanly implemented in Zigbee2MQTT for this particular device as they mix the use of event_type only and event_type in combination with button.

Here is one of my automations in full. This one controls my blinds and that device is a home brew using MQTT but you should be able to see how the conditions are done in the choose action

alias: Blinds Opple
triggers:
  - trigger: state
    entity_id: event.blinds_opple_action
    not_from: unavailable
actions:
  - choose:
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'button_4_double'}}"
        sequence:
          - data:
              topic: blinds/set/left
              payload: "80"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'button_6_double'}}"
        sequence:
          - data:
              topic: blinds/set/right
              payload: "80"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'button_2_double'}}"
        sequence:
          - data:
              topic: blinds/set/left
              payload: "80"
            action: mqtt.publish
          - data:
              topic: blinds/set/right
              payload: "80"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'hold'}}"
          - "{{trigger.to_state.attributes.button == 'button_3'}}"
        sequence:
          - data:
              topic: blinds/set/left
              payload: "0"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'hold'}}"
          - "{{trigger.to_state.attributes.button == 'button_5'}}"
        sequence:
          - data:
              topic: blinds/set/right
              payload: "0"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'hold'}}"
          - "{{trigger.to_state.attributes.button == 'button_1'}}"
        sequence:
          - data:
              topic: blinds/set/left
              payload: "0"
            action: mqtt.publish
          - data:
              topic: blinds/set/right
              payload: "0"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'hold'}}"
          - "{{trigger.to_state.attributes.button == 'button_4'}}"
        sequence:
          - data:
              topic: blinds/set/left
              payload: "50"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'hold'}}"
          - "{{trigger.to_state.attributes.button == 'button_6'}}"
        sequence:
          - data:
              topic: blinds/set/right
              payload: "50"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'hold'}}"
          - "{{trigger.to_state.attributes.button == 'button_2'}}"
        sequence:
          - data:
              topic: blinds/set/left
              payload: "50"
            action: mqtt.publish
          - data:
              topic: blinds/set/right
              payload: "50"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'button_3_double'}}"
        sequence:
          - data:
              topic: blinds/set/left
              payload: "100"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'button_5_double'}}"
        sequence:
          - data:
              topic: blinds/set/right
              payload: "100"
            action: mqtt.publish
      - conditions:
          - "{{trigger.to_state.attributes.event_type == 'button_1_double'}}"
        sequence:
          - data:
              topic: blinds/set/left
              payload: "100"
            action: mqtt.publish
          - data:
              topic: blinds/set/right
              payload: "100"
            action: mqtt.publish
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'button_4_single'}}"
        sequence:
          - data:
              topic: blinds/step/left
              payload: "10"
            action: mqtt.publish
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'button_6_single'}}"
        sequence:
          - data:
              topic: blinds/step/right
              payload: "10"
            action: mqtt.publish
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'button_2_single'}}"
        sequence:
          - data:
              topic: blinds/step/left
              payload: "10"
            action: mqtt.publish
          - data:
              topic: blinds/step/right
              payload: "10"
            action: mqtt.publish
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'button_3_single'}}"
        sequence:
          - data:
              topic: blinds/step/left
              payload: "-10"
            action: mqtt.publish
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'button_5_single'}}"
        sequence:
          - data:
              topic: blinds/step/right
              payload: "-10"
            action: mqtt.publish
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'button_1_single'}}"
        sequence:
          - data:
              topic: blinds/step/left
              payload: "-10"
            action: mqtt.publish
          - data:
              topic: blinds/step/right
              payload: "-10"
            action: mqtt.publish
initial_state: "on"
mode: queued
max_exceeded: silent

There seems to have been something wrong with the blueprint and interaction. I just did the same setup, but with another blueprint:
[Z2M] Aqara Opple 6 boutons blueprint (WXCJKG13LM) [Updated 2025] - Blueprints Exchange - Home Assistant Community

And now it works!

For those looking to do the same, the building blocks are:
Edit the automation / blueprint to have mode: restart instead of mode: parallel (can be found in your config folder under config/blueprints/automation and in the folder for the blueprint you will find the yaml.

Then set up like this:

Repeat - Count - 10 times
Action: Turn on Light (brightness 10% and transition 0.5sec in my case)
Delay for 1 second.
Should look something like this:

Thank you so much for your help @Mayhem_SWE and your input @KennethLavrsen!

@tottow

I don’t understand this part:

If possible I would like to change the blueprint to something that is compatible with your usecase but automation modes only support single, restart, parallel and queued see Automation modes - Home Assistant

Let me know if I can help on that point

sorry @bouyssic - it’s a typo! I was writing this quite quickly, it’s mode: restart not “repeat”… I’ll amend it now

No need to be sorry @tottow.

I’ve amended all blueprints to use restart instead of parallel

1 Like

Thanks to all for the effort

The dimmer is working , but not stopping when I release the button. It is making the full 10 repeats.

How to stop the repeat on release?

As explained earlier in the thread, the automation/blueprint must use mode: restart or else the release button event cannot interrupt the loop that begins on the hold button event.

@pepe2 did you update to the latest version of the blueprint?

If you didn’t, go ahead as I have added the restart option to the blueprint

Sorry my Yaml is very poor, it is like Latin, I don’t understand.
I reloaded the blueprint .
But you are all very helpfull.

Thanks, it is working like before.