I’m having a hard time figuring out how to combine multiple triggers and actions into one automation.
I’m using Hue wall switches to activate my lights. They’re all added to Deconz. The Hue wall switches have 4 buttons, but each button generates multiple “event codes” based on short press, long press etc.
At this moment I’m having 4 automations for one Hue wall switch. One to turn on the lights, one to turn off the lights, one to dim the lights and one to brighten the lights. If I want to utilize the long press functions I need 8 automations per wall switch. That’s a lot, considering I’m having like 10 switches in my house.
I believe it’s possible to pass the event_data code from the deconz_event to an if-else action. I can use different if-else actions to decide which service to call. Can you help me figuring this out?
What I want to do is make a variable within the trigger from the event.event_data.event object, and use that to decide which action to activate. This way I can reduce my automations to one automation per switch instead of multiple.
Hue switch button codes:
1000 - On short press
1003 - On long press
2000 - Dim + short press
2003 - Dim + long press
3000 - Dim - short press
3003 - Dim - long press
4000 - Off short press
4003 - Off long press
I’d go for a choose in the automation even thou you can do it with if of course
The choose syntax is close to the if you did but is more readable in your case, where there is plenty values to check for:
You guys are all great, thanks for the suggestions! I’m going to experiment with the choose instead of if/else to see if I can get it working. The blueprint looks promising too!
So, I tried to use this method to switch the lights, but it didn’t work. The trigger works as I’m seeing the green “triggered” message appear when I press a button. The condition template doesn’t seem to work though.
When I take a look at the YAML of the blueprint that @Olivier1974 mentioned, they are using the following template:
That is the reason why I did not use the conditions: + condition: template form.
As Taras said, you should have a look at the trace of your automation, see what is wrong.
Try this to short the amount of triggers
I don’t know if it will work because I didn’t test it.
It’s just an idea
Variable “type” should contain: short or long and “command” should contain: on, dim+, dim-, off
The screenshot confirms that the received data failed to match and of the conditions. It may indeed be received as an integer value instead of a string. Therefore change the template to:
"{{ trigger.event.data.event == 1000 }}"
If that fails to work then we need to see more information from the trace. The screenshot you posted only provides the most basic information about what happened. You can download the trace as a text file and then post it here where we can examine it for you.