Automation: Run script on 2nd button click

Well, there are 2 ways to run a script.

  1. Use the script service directly
    - service: script.my_script
      data:
        parameter_1: "Ho ho ho"
  1. Turn on the script
    - service: script.turn_on
      entity_id: script.my_script

There is a subtle difference between the 2 (other than script.turn_on not allowing you to pass data). The 2nd one runs the script and returns immediately. The 1st one will wait for the entire script to complete before continuing.

If you have some rogue light or something that wont reply, this poor script is just going to wait forever to finish. It might even halt on errors for all I know. Either way, the 2nd one doesn’t care. It just says “good luck” and goes to the next step.

So, change your action to this:

action:
  - service: script.turn_on
    entity_id: script.script_office_work_lights

And it might work better for you.

1 Like