What is the best way (or any way) to run(trigger) multiple automations?

You should concentrate on getting the script working without fields before you try it with them. Your screenshot shows you are on the services tab but in YAML mode, and fields have no effect unless you are in UI mode.

I would suggest staying in YAML mode on the services tab, and simply copying the code from my previous reply (either the second to last block or the last block), and seeing if it works. Change the name of the cover entity as needed.

Edit: I’ll try to say this again but more clearly: the way to pass information into a script at runtime is with variables. Fields simply give you a pretty UI to add those variables. You can pass in variables without a pretty UI. So stop worrying about a nice user interface when you don’t have the guts functioning behind it.

It’s probably worth taking a step back and look at what I think your end goal should be:

  1. A script that accepts variables and can open or close whichever cover entity is passed in as a variable
  2. Either 1 automation that calls the script 8 times, each with a different cover entity; OR: 8 automations that each call the script once
  3. 8 different buttons that you can place on your dashboard that each call the script and pass along a different cover entity

You should already have item #1, although we didn’t yet add in the repeat….while loop. This script is called script.set_cover_position

The next easiest thing to figure out is item #3. Because once you are able to figure out how to call script #1 from the services tab in developer tools, you just take that exact code and have a button in your dashboard call the same service with that same code.

Then you can create automations that call the script #1, and again they are going to use that exact same code for the service call.

Finally, if you really want to call script #1 from the UI for some reason, you can add fields and get that working. Though I don’t really understand why you’d want to do that.

1 Like

@mekaneck I have taken a long time to reply here but it is not because of a lack of interest.

Recent releases have caused my automations to become unreliable. Of the eight shutters, typically one, sometimes two, do not open (am) or close (pm). There seems to be no pattern to the failures as to which shutter fails. The automations ran perfectly before. I know it is not a hardware or signal strength issue as they work perfect with Tuya App. It is just in HA Just keeping what I have running has keep me from making any progress with other things I want to do in my home.

My end goal is to get my shutters to work reliably under HA control. With respect to your numbered items.

  1. Yes, with modification. The script must accept the position. The devices are not binary and I don’t use them in that way. Due to position in the home and mounting positions. Some are open at 86% and some 14% Some are closed at 0% and some are closed at 100%.
  2. One automation that calls the script 8 times each time on a different entity with a different position to be set.
  3. Two buttons. One button that will set all to specific positions unique to each shutter. This positions can be “hard coded”. This is represent “all close” and another button with other positions that will represent 'all open" Quotes because open means 100% in HA and that is not meaningful in this use case. Like wise closed means 0% which again is not meaningful in this use case.
  4. An automation that does what the above buttons do in the AM and PM respectively.

I am setting aside the while loop for now. For testing purposes I will just keep running (a reasonable amount of times) the script until it works as this is what happens when just set position from developer tools, eventually if works after one or more attempts.

With all that out of the way, where I am in this process is a have a script which has templates for the entity and the position. However I don’t know how to test this script, more specifically how to get values into it for the specific cover and position.

This is were I got lost in your replies, you seemed to go in a couple of different directions. So my question here is how do I run, i.e. pass values into this script and test it. Thank you.

alias: Set Cover Position
sequence:
  - target:
      entity_id: "{{ target_cover_entity }}"
    data:
      position: "{{ desired_position }}"
    action: script.turn_on
mode: parallel
icon: mdi:curtains
fields:
  target_cover_entity:
    selector:
      entity: {}
    description: The actual cover entity
    name: target_cover_entity
  desired_position:
    selector:
      number:
        min: 1
        max: 100
        step: 1
    name: desired_position
    description: The position to set the shutter to
    required: true

@mekaneck I made a small change to the script and now I am prompted to enter the values when I run the script from the script editor. So that question is answered. Unforuntely the script did not run and there was an error message as shown below. Also the modified script is listed below also.
What does the error message mean?
Thank you.

alias: Set Cover Position
sequence:
  - target:
      entity_id: "{{ target_cover_entity }}"
    data:
      position: "{{ desired_position }}"
    action: script.turn_on
mode: parallel
icon: mdi:curtains
fields:
  target_cover_entity:
    selector:
      entity: {}
    description: The actual cover entity
    name: target_cover_entity
    required: true
  desired_position:
    selector:
      number:
        min: 1
        max: 100
        step: 1
    name: desired_position
    description: The position to set the shutter to
    required: true

I got rid of this error but when I run the script it does not change the position of the shutter.

When you use the script.turn_on action, you have to list the variables under a variables: key. This is different from how you’d list variables if you instead called the script directly using the script.my_script_name action.

See the very last example in this section, immediately prior to the blue “note”.

The error simply means there are only certain keys that can be specified under the data: key (that is part of action: script.turn_on). “Position” is not a valid key. (But variables: is :wink: )

1 Like