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.
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:
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.
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.
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:
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…
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
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:
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
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.