Ive got two automations but the second one must only trigger if the first one has completed.
Is that possible?
Maybe you could make your action as a script
and then wait for the first script to be done
{{ is_state(‘your_script’, ‘off’) }}
edit…
Or you could in the first automation make a helper and set it to on, and in your second automation make a condition to see if the helper is on.
in the second automation you could set the helper to off again.
It should be. Try triggering second automation like this
platform: state
entity_id:
- automation.first.one
from: "on"
to: "off"
Every automation has an attribute called current: when the automation is running the current attribute is 1 and when not running the current attribute is 0. (it may be a number higher than one if you have the automation mode set to run in queued or parallel mode but that is beside the point) If you set the second automation with a condition to only run when the first automation attribute current: is 0 then it can’t run while the first one is still running. Do you always want the second one to run after the first? Or you just want it to never run while the first is running?
Why not make it a single automation? Are there cases where the second automation triggers by itself without the first executing? Would be good to know what you’re trying to achieve here — the underlying problem.
Triggered how? If you’ll be calling the second automation then it’s just invoking a script. Or if the second does the second trigger by itself and you just want to ensure the first isn’t running? Then it’s just a condition in the second using that current
attribute that was mentioned.
That won’t work.
the on/off state of the automation has nothing to do with whether the automation is running or not (IOW, actually in the course of running it’s actions).
That state is only based on whether the automation is enabled (on) or disabled (off).
It’s possible … but you’re asking for something that may indicate a deficiency in the application’s design.
Post the two automations.
It is about the following automations:
the first:
alias: Somfy Buitenscreen close!
description: ""
trigger:
- platform: time_pattern
hours: /1
condition:
- condition: numeric_state
entity_id: sensor.aircooverloop_outside_temperature
above: 20
below: 99
- condition: numeric_state
entity_id: sensor.buienradar_rain_last_hour
below: 0.1
action:
- device_id: 2148876ca4359faa3c7ad0d9f524088c
domain: cover
entity_id: cover.somfybuitenscreen
type: close
mode: single
and the second:
alias: Somfy screen open!
description: ""
trigger:
- platform: numeric_state
entity_id: sensor.buienradar_rain_last_hour
above: 0.1
condition:
- condition: numeric_state
entity_id: sensor.aircooverloop_outside_temperature
above: 4
below: 99
action:
- device_id: 2148876ca4359faa3c7ad0d9f524088c
domain: cover
entity_id: cover.somfybuitenscreen
type: open
mode: single
So what Im trying to achieve: only execute the second automation (to open the screen) when the first automation has executed (so when the screen has been closed)…
because this somfy screen doesn’t have a correct state (unknown) I can’t define a condition at the second automation, unfortunately.
Your two automations are designed to open/close the cover depending on outdoor temperature and rainfall. You should simply consolidate the two automations.
Are you saying that when you command cover.somfybuitenscreen
to open or close it never reports the correct state?
Why not use a boolean helper that sets the state open/close, and use that as condition?
action:
- device_id: 2148876ca4359faa3c7ad0d9f524088c
domain: cover
entity_id: cover.somfybuitenscreen
type: open:
- services: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.somfybuitenscreen
and than when triggering closing:
condition:
- condition: state
entity_id: input_boolean. somfybuitenscreen
state: "on"
And yeah, it is fairly easy to consolidate these 2 by using condition ‘trigger_id’