Sorry I had missed your first message. The loop control is dictated by a few things
The script must be configured as mode: restart
The physical switch firmware sends KeyHeldDown event which enters the construct
When the automation is configured with is_loop_for_key_up_held: true, the instructions under the event repeat indefinitely until the script restarts.
Conventionally we anticipate that KeyReleased is that event but I suppose any event the configured switch sends would jump out of this repeat
This is actually the part that matters the most:
- repeat:
sequence: !input 'key_up_held'
until: '{{ not is_loop_for_key_up_held }}'
The instruction repeat is the control flow. If you’re familiar with a programming language this might read out as
do
{
/* do events associated for the key_up_held event (as an example) */
}
while(true)
Also, you might ask why am I referring to this as do{} while(true) when the configuration expresses until: '{{ not is_loop_for_key_up_held }}'? The end-user configured setting cannot change after the script starts, so this construct implicitly anticipates that the script will restart on the next button click. That last sentence might help clear up your understanding on why this works.
This is what my automation config looks like through your blueprint. The part that I can’t understand how it is defined is this part. Where is {{ not is_loop_for_key_up_held }}
defined? Is this something built into HA that I am unaware of, or is it defined somewhere in your blueprint that I am missing?
So the variable is_loop_for_key_up_held is a user-config variable from the blueprint. If you want to use the concept here, then replace it with any boolean condition; so something like until: false might work. You may want to review the Script Syntax - Home Assistant wiki page to consider other options for your use case. I think while: {{ true }} would probably be okay. Remember, be sure to use the script restart, otherwise you might be introducing a never-ending loop.
@moshess OK there seems to be some misunderstanding going on here. I understand the concept of a loop, I understand how the script syntax goes, but I don’t know what you are looking for to tell when the paddle is let go. You cannot use an event as the “until” portion of the repeat, and I don’t know what logic you were using to determine that. I hope this makes sense.
choose:
- conditions:
- condition: trigger
id: KeyHeldDown
sequence:
- repeat:
until:
- condition: I DONT KNOW WHAT TO PUT HERE
sequence:
- service: light.turn_on
target:
entity_id:
- light.kitchen_ceiling_lights
- light.kitchen_sink_light
data:
brightness_step_pct: -10
default: []
On the surface this is a bad idea because is a never ending loop but that matches how the blueprint is configured. What makes it work, is by using the the script configuration mode: restart
@moshess Hey there, could you give an example of how you implement dimming with this blueprint? On/Off is pretty straight forward to me but I don’t understand how to dim. I’m using an older Homeseer HS-WD100 dimmer that is not a scene controller and Hue bulbs. Thanks