I now add the variables part at the same level as the trigger rather than inside each trigger (I did this at the time of the original post) so it is only required in the automation once (more efficient) and applies for all triggers in the automation if that makes sense.
Edit:
I put the variables in “var_3”, script wide level variable (it will appear at the bottom of the automation script after saving it and then going back to edit it in yaml mode):