Make an automation that reloads if trigger is still true

Good morning everyone!
I’m back here:
is it possible to make an automation that reloads as long as the trigger is true?

To explain me better: I have some netatmo valves and I have created a trigger that when I open the windows the valves are set to X degrees. Netatmo allows me to manually set the temperature for a maximum of 3 hours … if I have the window open for 4 hours the valves start working again … so I would need something that after YY time will collapse the trigger and if it is still true, reset the valves to X degrees.
Thanks to those who will dedicate time to me!

several ways, depending on what seems best.

at the end of you current automation add a delay for x hours, then trigger itself.
this won’t work if HA gets interrupted

or

Instead of a trigger of when you open the window, perhaps a time pattern trigger, so trigger every 30 mins
Of course you then need to adjust the conditions to check if the window has been open for a certain length of time, otherwise it may coincidently activate 2 mins after you have first opened them

Keep in mind when you want to explain better then make sure it actually is better.
Why do you say X and YY don’t give us any entities? Do you really think that is good?

you could use the repeat until

description: ""
mode: single
trigger: []
condition: []
action:
  - repeat:
      while:
        - condition: state
          entity_id: input_boolean.ac_override
          state: "on"
      sequence: []

Just add a delay in the sequence or it will trigger every millisecond or however fast your HA is.

Blockquote
Keep in mind when you want to explain better then make sure it actually is better.
Why do you say X and YY don’t give us any entities? Do you really think that is good?

Excuse me I thought I would explain better, next time I will improve!

===

I read about the repeat-until function, thanks but I have a doubt: my code (which I now post) is a bit more complex, if I put the repeat as I put it it repeats all the actions or only those inside the repeat ? Because the snapshot of the air conditioner I would not want to be repeated, only the setting of the valves at 7 degrees I would like it to be repeated

alias: Apertura Finestre Piano Terra
description: ''
trigger:
  - type: opened
    platform: device
    device_id: 7056d1e82a704b76d9eb09c47dddf079
    entity_id: binary_sensor.sensore_apertura_soggiorno_1_contact
    domain: binary_sensor
    for:
      hours: 0
      minutes: 1
      seconds: 0
  - type: opened
    platform: device
    device_id: ce48080bf1077d7e9de173386845071c
    entity_id: binary_sensor.sensore_apertura_soggiorno_2_contact
    domain: binary_sensor
    for:
      hours: 0
      minutes: 1
      seconds: 0
  - type: opened
    platform: device
    device_id: 4a8c9cbde9d2fd9dbcc3412568c9d4bf
    entity_id: binary_sensor.sensore_apertura_soggiorno_3_contact
    domain: binary_sensor
    for:
      hours: 0
      minutes: 1
      seconds: 0
  - type: opened
    platform: device
    device_id: 0353b56edd665973dc4cd27c84f5b5ba
    entity_id: binary_sensor.sensore_apertura_cucina_1_contact
    domain: binary_sensor
    for:
      hours: 0
      minutes: 1
      seconds: 0
  - type: opened
    platform: device
    device_id: cac2c91d8e0c90ee05c2acd5dd77b20e
    entity_id: binary_sensor.sensore_apertura_cucina_2_contact
    domain: binary_sensor
    for:
      hours: 0
      minutes: 2
      seconds: 0
condition: []
action:
  - service: scene.create
    data:
      snapshot_entities: climate.daikin_soggiorno
      scene_id: before_soggiorno
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 500
  - if:
      - condition: state
        entity_id: climate.daikin_soggiorno
        state: fan_only, heat, cool, heat_cool, dry
    then:
      - device_id: 08df77ca5eb41bbe6bf91082e4edc622
        domain: climate
        entity_id: climate.daikin_soggiorno
        type: set_hvac_mode
        hvac_mode: 'off'
    else: []
  - repeat:
      while:
        - condition: or
          conditions:
            - type: is_open
              condition: device
              device_id: 7056d1e82a704b76d9eb09c47dddf079
              entity_id: binary_sensor.sensore_apertura_soggiorno_1_contact
              domain: binary_sensor
            - type: is_open
              condition: device
              device_id: ce48080bf1077d7e9de173386845071c
              entity_id: binary_sensor.sensore_apertura_soggiorno_2_contact
              domain: binary_sensor
            - type: is_open
              condition: device
              device_id: 4a8c9cbde9d2fd9dbcc3412568c9d4bf
              entity_id: binary_sensor.sensore_apertura_soggiorno_3_contact
              domain: binary_sensor
            - type: is_open
              condition: device
              device_id: 0353b56edd665973dc4cd27c84f5b5ba
              entity_id: binary_sensor.sensore_apertura_cucina_1_contact
              domain: binary_sensor
            - type: is_open
              condition: device
              device_id: cac2c91d8e0c90ee05c2acd5dd77b20e
              entity_id: binary_sensor.sensore_apertura_cucina_2_contact
              domain: binary_sensor
      sequence:
        - if:
            - type: is_open
              condition: device
              device_id: 7056d1e82a704b76d9eb09c47dddf079
              entity_id: binary_sensor.sensore_apertura_soggiorno_1_contact
              domain: binary_sensor
          then:
            - service: climate.set_temperature
              data:
                temperature: 7
              target:
                device_id: 4bf2224f3e476f19d8521d498f8150ec
        - if:
            - type: is_open
              condition: device
              device_id: ce48080bf1077d7e9de173386845071c
              entity_id: binary_sensor.sensore_apertura_soggiorno_2_contact
              domain: binary_sensor
          then:
            - service: climate.set_temperature
              data:
                temperature: 7
              target:
                device_id: 4bf2224f3e476f19d8521d498f8150ec
        - if:
            - type: is_open
              condition: device
              device_id: 4a8c9cbde9d2fd9dbcc3412568c9d4bf
              entity_id: binary_sensor.sensore_apertura_soggiorno_3_contact
              domain: binary_sensor
          then:
            - service: climate.set_temperature
              data:
                temperature: 7
              target:
                device_id: 4bf2224f3e476f19d8521d498f8150ec
        - if:
            - type: is_open
              condition: device
              device_id: 0353b56edd665973dc4cd27c84f5b5ba
              entity_id: binary_sensor.sensore_apertura_cucina_1_contact
              domain: binary_sensor
          then:
            - service: climate.set_temperature
              data:
                temperature: 7
              target:
                device_id: 2db932ab61638a1607cedc2d101cd8a9
        - if:
            - type: is_open
              condition: device
              device_id: cac2c91d8e0c90ee05c2acd5dd77b20e
              entity_id: binary_sensor.sensore_apertura_cucina_2_contact
              domain: binary_sensor
          then:
            - service: climate.set_temperature
              data:
                temperature: 7
              target:
                device_id: 2db932ab61638a1607cedc2d101cd8a9
        - delay:
            hours: 3
            minutes: 0
            seconds: 0
            milliseconds: 0
mode: single

Thanks again

I believe the biggest issue here is the three hour delay.

I’m just thinking out loud here, what if I stead of looping and delaying we trigger on temperature change on the climate set temperature and have a condition to check the window, if this is true then set it back down again.

This will split up your automation to one part that first triggers on the windows and sets the temperature down, then a second part (or second automation) that triggers on the set temperature change. That way the automations are instant and not waiting which is prone to failure.

Does it make sense? I don’t know the devices and what you can do so I just say what I’m thinking.