Running two services at once

Is it somehow possible to run two scripts/services at the same time in one automation? See example below. I realize that service is looking for a single service to run but I am thinking it should be possible to accomplish this somehow, or am I wrong?

toggle_home_lights:
    alias: "Toggle Home lights"
    sequence:
      service: >
        {% if states ('sensor.template_total_lights_on') | int > 0 %}
          script.turn_off_home_lights,
          script.outside_night_mode
        {% else %}
          script.turn_on_home_lights
        {% endif %}

Is it enough, if they are parallel rather than at once?

Yes, absolutely! I have read the documentation but I’m just not sure how to create multiple services under the conditional statements.

Put conditional statement in the “trigger” for automation and then use following:

toggle_home_lights:
    alias: "Toggle Home lights"
    sequence:
      - parallel:
          - service: script.turn_off_home_lights
          - service: script.outside_night_mode
1 Like

But I don’t want to trigger the automation on the sensor, I want to call it when I press a button. How would I accomplish this?

Use event i.e. button press as trigger in the automation.

In the condition (within automation) use template to check if lights are on.

In the action (for automation) use the two scripts in parallel.

I’m sorry for not following, please bare with me. :slight_smile:

I want to press a button or element that calls “toggle_home_lights”.

If more than 0 lights (or any other number I specify) are lit, I want all home lights and some of the outside lights to go off.

If 0 lights are lit I want to turn on all home lights (but not any of the outside lights.

I want to be able to call this from several places in my UI, hence why I don’t want to configure a button as a trigger. This is a script that I want to be able to run from anywhere, and I want this script in turn to execute either two scripts (if lights are on) or one other script (if lights are off).

Does my specification make sense?