here i am again looking for some help with an automation i am trying to build and although i have seen many similar posts, i was not able to make it work for my set up. I have an Aqara Mini Switch that supports long press hold and long press release and i am trying to use the feature to dim or brighten the light in the WC. So the intention is:
When i hold the button, the brightness increases smoothly. Here is a screenshot of the aqara button functions:
The light i have in the WC supports increase / decrease brightness but some how i need to make it work as if it is increasing or decreasing the brightness for as long as i hold the button. I thought to use the Repeat Until function in automations but some how it is not working for me.
Status update. I figured out how to make it understand if to increase or decrease the brightness using an input_boolean. So, i created an input_boolean and an automation that toggles the state of the boolean on the button long press. Now when i long press the button first time, the boolean changes state to on, and when i press again it changes to off.
So based on that, i created another automation that either increases or decreases the brightness based on the state of the boolean. Here it is:
With the above, it decreases or increases the brighness once. I haven’t figure out how to repeat it until something happens. Perhaps you can help me here.
So repeat while until your remote sends the release command.
When I looked in the GUI I could not do that on my devices from IKEA. I’m limited to the battery in repeat while. Perhaps yours is different.
If not then you will need to read the zha_event for the release command
I tried last night for a couple of hours and this is exactly the problem. I am also limited in the battery state of the button. I have never used so far the zha_event option. Could you please redirect me to an example?
Then press the button and you should see the communication from the remote.
Most likely there will be a “command”: “long_press”, then when you release a “command”: “release”.
Copy paste the data here and we can probably get it to work
huh… In the repeat you can’t make it repeat while events.
I guess I can’t help more now.
I’m sure this can be done with a variable or with a helper that is set with the events.
This is why I never bother with HA automations when doing something more than flipping a switch or similar.
if all these values are constant. if not then just delete the parts that change. I believe as long as you keep device_id and command release it should work.
Thanks for the code.
Since the button supports release state i don’t need to use the zha_event. I can select it from the GUI but only as a trigger. The intention was to select it as a repeat - until section to stop a loop.
I think i am going to quit as i don’t see this possible… Pity, it should be something that could be there by default. I believe that the button manufacturers include the hold/release features for such reasons (increase / decrease brightness).
I have found a post that does it with node-red but i don’t want to go this way. Thank you very much for the help though, really appreciate it!
I have tried this last night however the result is that the automation never stops. It keeps increasing the brightness to 100% and if you turn the light off, it turns it on again and raises the brightness to 100%.
What mode are you running that in?
If that is in mode: repeat (given that is what you posted before) then I could see that happen as all automations are queued.
If you run it in single mode then all automations that occur when the first is running should be blocked from running.
I think what we need to do here is to implement another helper. An Input_Slider. The idea is, that the long press, increases the number of the slider and then with another automation (if possible, the brightness is equal to the slider number).
This can be then further extended with another condition that if the slider is number is >50 then the brightness should increase but if <50 the brightness should decrease.
Status Update… I was able to create an input_slider and link it the light brightness. I was even able to add conditions so if slider is above 50 it should increase while if below 50 it should decrease.
The problem again is the event of stopping the slider from increasing/decreasing. So, the button registers the long press, but there is no way to stop changing the brightness on release because in the repeat - until condition there is no “event” option.
And now i am officially quitting… I am going to do it the old way. Create some scenes with different brightness and shuffle them with the button one after the other.