Automation as condition or trigger

Is it possible to have an automation as condition (or trigger)?

Automation:
  - condition: state
    entity_id: 
      - automation.nummer_1_kom_hem
      - automation.nummer_2_kom_hem
    state: 'off'

An automation requires at least a trigger and an action.
Conditions are optional.

If you you’re looking at manual triggering with ( optional conditions and ) actions, scripts are where you want to be.

I think you need to add a trigger like time so that it checks those condition every second / minutes.

More like if there is possible to have an automation as condition or trigger

I have tried:

- alias: 'Tänd i hallen vid upptäckt rörelse'
  initial_state: true
  trigger:
  - platform: state
    entity_id: binary_sensor.net_dorrvakt
    to: 'on'
  condition:
  - condition: state
    entity_id: 
      - automation.nummer_1_kom_hem
      - automation.nummer_2_kom_hem
    state: 'off'
  - condition: state
    entity_id: input_select.status_hemma
    state: 'Hemma'
  - condition: numeric_state
    entity_id: sensor.net_dorrvakt_luminance
    below: 15
  - condition: state
    entity_id: group.all_devices
    state: home
  action:
  - service: homeassistant.turn_on
    entity_id: 
      - switch.hall_entre
      - switch.hall_golvlampa
      - switch.hall_kladhangare

Rather than having a time-based trigger, there’s a more elegant solution available through “template trigger”: https://home-assistant.io/docs/automation/trigger/

Then the trigger would look like this:

trigger: 
  platform: template
  value_template: {{ is_state('state.automation.nummer_1_kom_hem', 'off') }}

Have fun!

How to use two automations?

Okey i will try:

- alias: 'Tänd i hallen vid upptäckt rörelse'
  initial_state: true
  trigger:
  - platform: state
    entity_id: binary_sensor.net_dorrvakt
    to: 'on'
  - platform: template
    value_template: "{% if is_state('state.automation.1_kom_hem','state.automation.2_kom_hem', 'off') %}true{% endif %}"
  condition:
  - condition: state
    entity_id: input_select.status_hemma
    state: 'Hemma'
  - condition: numeric_state
    entity_id: sensor.net_dorrvakt_luminance
    below: 15
  - condition: state
    entity_id: group.all_devices
    state: home
  action:
  - service: homeassistant.turn_on
    entity_id: 
      - switch.hall_entre
      - switch.hall_golvlampa
      - switch.hall_kladhangare

looks good to me :slight_smile: Does it work?

Hope so, will be tested tomorrow when my girlfriend comes home :slight_smile:

It did work :slight_smile: