Automation integrated into another automation?

Hello!
Can one automation be integrated into another automation?

I have created an automation that switches off all media players in our house. I would like to integrate this into the automation that runs when the last person has left the house.

And how can this automation be delayed by a certain amount of time? I want to prevent it from running if the mobile phone loses contact with the Wi-Fi for a short time.

Many thanks.

The proper thing is to add all the actions in a script instead, then in your two automations you run the script.
But you can force run an automation also using automation.trigger

2 Likes

Ok understood.
How can I delay the start of the automation itself?

That depends on how the automation is set up.
It’s hard to help when we don’t see the automation.

I want to delay this automation:

alias: Presence simulation on/off
description: ""
triggers:
  - trigger: state
    entity_id:
      - zone.home
    to:
      - "0"
    id: Last person leaves
  - trigger: numeric_state
    entity_id:
      - zone.home
    above: 0
    id: First person arrives
    enabled: true
conditions: []
actions:
  - if:
      - condition: trigger
        id:
          - Last person leaves
    then:
      - action: light.turn_off
        metadata: {}
        data:
          transition: 180
        target:
          entity_id: light.lichter_haus_schaltbar
      - type: turn_off
        device_id: 8b5c511e9f4033d6d4d807586c2f288f
        entity_id: c70f02965490868815de7c2d47918ebb
        domain: switch
      - action: automation.trigger
        metadata: {}
        data:
          skip_condition: true
        target:
          entity_id: automation.mediaplayer_aus
      - action: switch.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: switch.presence_simulation
    else:
      - action: switch.turn_off
        metadata: {}
        data: {}
        target:
          entity_id: switch.presence_simulation
mode: single
triggers:
  - trigger: state
    entity_id:
      - zone.home
    to:
      - "0"
    for:
      minutes: 5   <-----------------------
    id: Last person leaves
  - trigger: numeric_state
    entity_id:
      - zone.home
    above: 0
    id: First person arrives
    enabled: true
1 Like

but keep in mind the home zone probably relies on GPS and not wifi as you said in your first post.
You probably need to enlarge the home zone or lengthen the time enough that it will not cause unwanted triggers.

You can automate an automation…

action: automation.trigger
target:
  entity_id: automation.lights_off
data:
  skip_condition: true

He already use that in his code.

Yeah, noticed that too late :stuck_out_tongue: