Struggling with wait script

Hi all,

I have defined an input_boolean as follows:

  input_boolean:
    elgato_tvswitch:
      name: "Elgato TV Switch"

I now would like to build a script which does a sequence of tasks in follow scenario:

Either the input_boolean is already “on”, or the script waits until the input_boolean becomes “on”.

Is this possible with HA?

I guess what I would like to achieve is an OR condition where one of the checks is instant (is input_boolean “on”) and the other check is a wait template?

- wait_template: "{{ is_state('input_boolean.elgato_tvswitch', 'on') }}"

Are you saying you want the script to do A if the input_boolean is already on, but if it’s off, then wait for it to go on and then do B? Or is the script going to do the same thing once the input_boolean is on (either immediately or when it eventually goes on)?

Hi Phil,

The script would do the same thing in both cases.

Makes sense?

Thanks Giel, would this not only fire when the input_boolean goes from off to on? I understand it won’t do anything if the input boolean was already on?

Yes. Then the wait_template suggestion @gieljnssns provided is what you want. If the input_boolean is already on then it will complete immediately. Otherwise it will wait forever for it to go on. You may want to specify a timeout, though.

ok, then i probably made a mistake as somehow i couldn’t get it to work.

will try again. cheers both

No problem. If you still have trouble, post your whole script; we might be able to spot what’s wrong.

Works perfectly. not sure what i did wrong. Thanks