I am currently working on a blueprint that will allow remote controls to be configured. I started with Homematic - but the whole thing should be transferable to Deconz etc…
Each click on a Homematic remote control triggers a homematic.keypress event, in which the channel specifies the ID of the pressed button. I now want to make the button configurable for each action. In particular, I would also like to be able to press a button multiple times to perform other actions. For example, you could switch through scenes by pressing a button multiple times.
For this purpose I created the following test automation for buttons 7 and 8 of a remote control:
alias: '! HM Multipress'
description: ''
trigger:
- platform: event
event_type: homematic.keypress
event_data:
name: HM-Remote
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.event.data.channel == 6 }}'
sequence:
- device_id: 5b10e3ca54045eee20e89dba4026ab1c
domain: mobile_app
type: notify
message: ''
title: '6: 1 Press'
- wait_for_trigger:
- platform: event
event_type: homematic.keypress
event_data:
name: HM-Remote
channel: 6
continue_on_timeout: false
timeout: '1'
- device_id: 5b10e3ca54045eee20e89dba4026ab1c
domain: mobile_app
type: notify
message: ''
title: '6: 2 Press'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.channel == 8 }}'
sequence:
- device_id: 5b10e3ca54045eee20e89dba4026ab1c
domain: mobile_app
type: notify
message: ''
title: '8: 1 Press'
- wait_for_trigger:
- platform: event
event_type: homematic.keypress
event_data:
name: HM-Remote
channel: 8
continue_on_timeout: false
timeout: '1'
- device_id: 5b10e3ca54045eee20e89dba4026ab1c
domain: mobile_app
type: notify
message: '2'
title: '8: 2 Press'
default: []
mode: parallel
max: 10
For example, if I press button 6 once, I get the notification “6: 1 Press”.
If I press button 6 twice, I unfortunately receive three notifications:
“6: 1 Press”, “6: 1 Press” and “6: 2 Press”.
This is due to the fact that the automation has a wait_for_trigger on the one hand, but on the other hand is also started a second time in parallel. The executability must also allow parallelism, because I could also press another button before the timeout of the wait_for_trigger, for which it would then be the first click.
Instead of “6: 1 Press”, “6: 1 Press” and “6: 2 Press” I want to get only “6: 1 Press” and “6: 2 Press”, because if I press the button twice, each action should be executed only once.
Does anyone have an idea how to achieve this?