Ma7amed
(Ma7amed)
December 3, 2021, 9:32pm
1
I’m creating a blueprint that have a repeated part with a delay between each repetition. I want the part that repeat to be as input while the delay and the repeat remain but i don’t know how to do that.
The part i want to be input is the below part
- type: toggle
device_id: 3b2d553bf505829d38d28de5331dc72b
entity_id: switch.ceilingfan_switch
domain: switch
Here is the full action part of the blue print
action:
- choose:
- conditions:
- condition: trigger
id: single_press
sequence:
- type: toggle
device_id: 7debea22572eb215ecf7e73252dcafbe
entity_id: switch.walllamp
domain: switch
- conditions:
- condition: trigger
id: double_press
sequence:
- type: toggle
device_id: 767fac01b8049f4ebe134a948a9500bf
entity_id: switch.ceilinglamp
domain: switch
- conditions:
- condition: trigger
id: long_press
sequence:
- repeat:
count: '10'
sequence:
- type: toggle
device_id: 3b2d553bf505829d38d28de5331dc72b
entity_id: switch.ceilingfan_switch
domain: switch
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
default: []
mode: restart
r-j-taylor
(R. J. Taylor)
December 3, 2021, 10:37pm
2
Have you read through the blueprint documentation? Here is the relevant portion on inputs:
Ma7amed
(Ma7amed)
December 3, 2021, 10:49pm
3
I already checked this tutorial but it didn’t help
r-j-taylor
(R. J. Taylor)
December 3, 2021, 10:53pm
4
How did it not help? Based on your original post, it doesn’t appear that you even attempted to set it up yourself. If you have, please post your attempts so we can tell you where you went wrong.
Ma7amed
(Ma7amed)
December 5, 2021, 7:33am
5
I already checked the url you posted before, it is actually the first page i learned blueprint from.
anyway, I had many failed trial before making this post and here some of them.
action:
- choose:
- conditions:
- condition: trigger
id: single_press
sequence: !input 'single_press'
- conditions:
- condition: trigger
id: double_press
sequence: !input 'double_press'
- conditions:
- condition: trigger
id: long_press
sequence:
- repeat:
count: '10'
sequence:
!input 'long_press'
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
default: []
mode: restart
action:
- choose:
- conditions:
- condition: trigger
id: single_press
sequence: !input 'single_press'
- conditions:
- condition: trigger
id: double_press
sequence: !input 'double_press'
- conditions:
- condition: trigger
id: long_press
sequence:
- repeat:
count: '10'
sequence:
- !input 'long_press'
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
default: []
mode: restart
but i finally managed to achieve what i want by adding a useless repeat loop that have sequence on it to be able to add the input with the delay:
Full Blueprint here
blueprint:
name: Ikea shortcut Switch
description: Actions based on Ikea shortcut Switch
domain: automation
input:
remote:
name: Remote
description: Ikea shortcut Button to use
selector:
device:
integration: zha
manufacturer: 'IKEA of Sweden'
model: 'TRADFRI SHORTCUT Button'
single_press:
name: Button pressed
description: Action to run on single press
default: []
selector:
action: {}
double_press:
name: Button double pressed
description: Action to run on double press
default: []
selector:
action: {}
long_press:
name: Button continuously pressed
description: Action to run on continuosly press
default: []
selector:
action: {}
repeat_long_press_action:
name: Repeat long press action
description: Repeat long press action
default: true
selector:
boolean:
long_press_action_delay:
name: Long press action repeat delay
description: Time to wait between each iteration of long press action (if repeat enabled) until button released
default: 500
selector:
number:
min: 0
max: 10000
mode: box
variables:
repeat_long_press_action: !input 'repeat_long_press_action'
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
command: 'on'
id: single_press
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
command: 'off'
id: double_press
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
command: move_with_on_off
id: long_press
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
command: stop
id: long_press_release
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: single_press
sequence: !input 'single_press'
- conditions:
- condition: trigger
id: double_press
sequence: !input 'double_press'
- conditions:
- condition: trigger
id: long_press
sequence:
- repeat:
count: "{% if repeat_long_press_action -%} 10 {%- else -%} 1 {%- endif %}"
sequence:
- repeat:
count: '1'
sequence: !input 'long_press'
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: !input 'long_press_action_delay'
default: []
mode: restart