Allow Automations to Automatically Derive Triggers From Conditions

Summary

In many common automations, the user must manually define triggers and define conditions that describe the exact same state change.
This leads to duplicated logic and unnecessary complexity.

I propose a new feature:

Automatically infer triggers from conditions, so that an automation can be written using only conditions, and Home Assistant determines when the conditions become true and executes the actions.


Problem Description

Currently, Home Assistant requires explicitly defined trigger blocks in automations.
However, in many real-world cases, the necessary trigger is already implicitly defined by the conditions.

Example:

triggers:
  - platform: state
    entity_id: switch.bathroom_light
    from: "off"
    to: "on"
  - platform: time
    at: "21:00:00"

conditions:
  - condition: time
    after: "21:00:00"
    before: "05:30:00"

Both the trigger and the condition express the same logic:

  • The light becomes on
  • Or the time becomes 21:00
  • And the action should run only between 21:00 and 05:30

This duplication is error-prone and makes simple automations more complicated than necessary.


Proposed solution

Allow automations without explicit triggers

A user could define:

conditions:
  - condition: state
    entity_id: switch.bathroom_light
    state: "on"
  - condition: time
    after: "21:00:00"
    before: "05:30:00"

actions:
  - service: switch.turn_off
    target:
      entity_id: switch.bathroom_light

Home Assistant should then automatically:

  • Determine which state or time changes could make the conditions become true
  • Register the necessary triggers internally (state, time, sun, numeric_state, etc.)
  • Execute the automation when the condition set becomes satisfied

The user only writes the logic once.

Note: writing a lengthy trigger template is not the same, as it is not selectable in the UI and less maintainable.


Benefits

  • Eliminates duplicate logic

  • Makes automations significantly easier for beginners

  • Reduces mistakes from mismatched triggers and conditions

  • Conditions become the single source of truth

  • More powerful, high-level logic without extra YAML


Example Use Case

“Turn off the guest bathroom light 5 minutes after it was turned on, but only during the night.”

Today this requires multiple triggers and redundant conditions.
With this feature, the user writes only the actual logic:

conditions:
  - condition: state
    entity_id: switch.guest_bathroom
    state: "on"
  - condition: time
    after: "21:00:00"
    before: "05:30:00"

actions:
  - delay: "00:05:00"
  - service: switch.turn_off
    target:
      entity_id: switch.guest_bathroom

No manual triggers required, as they can be derived from the condition.

Um…

triggers:
  - trigger: state
    entity_id:
      - light.bathroom
    to:
      - "on"
    for:
      hours: 0
      minutes: 5
      seconds: 0
conditions:
  - condition: time
    after: "21:00:00"
  - condition: time
    before: "05:00:00"
actions:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.bathroom

I think I must have misunderstood the point you’re making.

A trigger is not a condition, it’s an event. The function of the condition block is to stop the automation if it is not true - not the same as an if action.

1 Like

Did AI write this for you? If so, you need to teach it there’s a fundamental flaw in its logic.

Triggers trigger when a state becomes true.
Conditions pass when a state is true.

See the subtle difference?

This is not the place for feature requests. This is: home-assistant · Discussions · GitHub Don’t post AI slop there. Or here for that matter.