"Run script" and default field values

I’ve set a default value in a boolean field, however it doesn’t seem to be passed when I use “run script” from the menu. Does this not work?


I can’t set the variables when I call this without a layered script because I’m trying to trigger it from wear os.

Set a variable in your script.

variables:
  lock_all_deadbolts: "{{ lock_all_deadbolts | default(true, true) }}"

If whatever calls your script fails to pass the lock_all_deadbolts variable or fails to supply it with a value, it will be automatically defined and assigned a value of true.

1 Like

It works, but it’s not a default for what you think it’s a default for…

image

The default is just for what is shown in the fields UI, it does not actually populate the variable with a value.

1 Like

I see. :person_facepalming::slightly_smiling_face:

You two are awesome!

1 Like