Automation trigger when *either* window has been open long enough or weather condition becomes true

Hi everyone,

I’m struggling with an automation and can’t figure out the best approach.

My goal is to receive a notification when:

  • a window has been open for a certain amount of time, and
  • a specific weather condition is true (for example, the outside temperature exceeds a certain value).

The problem is that the order in which these two conditions become true matters.

Scenario 1:

  • The window is opened.
  • After the configured time (e.g. 15 minutes), the automation is triggered.
  • The weather condition is not true yet.
  • Ten minutes later, the weather condition becomes true.

In this case, I don’t receive a notification because the trigger already fired earlier, and conditions are only checked at that moment.

Scenario 2: If I instead use the weather condition as the trigger and check whether the window has already been open for at least 15 minutes as a condition, it works for the scenario above. However, the opposite case no longer works:

  • The weather condition is already true.
  • I open the window.
  • The window stays open for 15 minutes.

Since the weather condition doesn’t change, the automation never triggers, so I don’t get a notification.

Basically, I want a notification whenever both conditions are true, regardless of which one becomes true first.

What would be the recommended way to implement this in Home Assistant? Is there a common pattern for this, or should I use multiple automations, template triggers, or something else?

Thanks in advance!

Here is some code:

alias: Fenster - schließen OG Balkontür
description: ""
triggers:
  - entity_id:
  - trigger: state
    entity_id:
      - binary_sensor.haus_fenster_meldung_bedingung
    to:
      - "on"
    from:
      - "off"
conditions:
  - condition: state
    entity_id: binary_sensor.og_panorama_balkontur_fensterkontakt
    state:
      - "on"
    for: >-
      {{ states('input_number.fenster_offen_meldung_zeitspanne_initial') |
      multiply(60) | int }}
actions:
  - repeat:
      while:
        - condition: state
          entity_id: binary_sensor.og_panorama_balkontur_fensterkontakt
          state: "on"
        - condition: state
          entity_id: binary_sensor.haus_fenster_meldung_bedingung
          state:
            - "on"
      sequence:
        - action: tts.speak
          metadata: {}
          data:
            cache: true
            media_player_entity_id: media_player.og_eingang
            message: Bitte OG Balkontür schließen
          target:
            entity_id: tts.google_de_de
          enabled: true
        - choose:
            - conditions:
                - condition: template
                  value_template: "{{ repeat.index > 2 }}"
              sequence:
                - action: telegram_bot.send_message
                  metadata: {}
                  data:
                    message: OG Balkontür Fenster schließen
                  enabled: true
        - delay: >-
            {{
            states('input_number.fenster_offen_meldung_zeitspanne_wiederholen')
            | multiply(60) | int }}
mode: single

Add both the window being open for 15 mins and the Weather condition as triggers (so you have 2 triggers).
Add both the window being open for 15 mins and the Weather condition as conditions (so you have 2 conditions).

Now whichever one triggers first, it will check the conditions & it won’t notify you since one of the conditions will be false. When the other one triggers, it will check the conditions & notify you since both conditions are now true.

what if you trigger on all three; weather, window opened, timer-end
then using the trigger_id and a choose you can do whatever you want for each of them checking the timer/window status.

But AFAIK are 2 trigger logical OR and not AND or? So it would trigger if only one is trigger is true right?

Triggers don’t care about each other. Not or, and, or anything else.
There is a mode that will keep a second trigger from ‘triggering’ if the automation is running. Another mode that will interrupt the running automation if another trigger happens.
But no and / or stuff. Each trigger is an independent event.

What he is saying is one trigger will trigger and all the conditions are not met. It drops out and nothing happens. Then the other will trigger. It sees that both conditions are now met and things continue. Don’t matter what is first or last. If the first condition drops out then it will not do anything.

What he said ^^

Thanks a lot guys, that solves my issue :smiley: