Help automation - something I am missing

Hi all
I am trying to make an automation to get notified if a window is open more than 10’’ minutes in winter.
I have made the following, where if I test it for 1 minute (if the window is open for 1 minute and the delay is 1 minute) it is working. But if I set the limit in 10 minutes (delay 5 minutes) isn’t working. I also tried to set it at 6 minutes with 6 minutes delay again it is not responding. What am I missing??

# Alert if windows open in winter  ******************************************************************
- id: Alert if windows open in winter
  alias: Alert if windows open in winter
  trigger:
  - platform: state
    entity_id: group.windows
    from: 'off'
    to: 'on'
    for:
      hours: 0
      minutes: 6
      seconds: 0
      milliseconds: 0
  condition:
  - condition: numeric_state
    entity_id: sensor.outdoor_temperature_2
    below: '20'
  - "{{ trigger.for.seconds == 1 * 60 and now().month in [1, 2, 3, 4, 10, 11, 12] }}"
  action:
    - repeat:
        until: "{{ is_state('binary_sensor.windows_open_winter_to_close_is_cold','off') }}"
        #count: '4'
        sequence:

        - service: tts.google_translate_say
          data_template:
            entity_id: media_player.googlehome3359
            message: "It is cold outside, and window {{ expand('group.windows') | selectattr('state', 'eq', 'on') | map(attribute='name') | list | join(', ') }} is opened."

        - service: notify.mobile_app_sm_g955f
          data_template:
            message: "It is cold outside, and window {{ expand('group.windows') | selectattr('state', 'eq', 'on') | map(attribute='name') | list | join(', ') }} is opened."
            data:
             color: '#2DF56D'
             vibrationPattern: "1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500" # The pattern you wish to set for vibrations
             ledColor: "blue"
             channel: Home Assistant notify channel # name of the channel you wish to create or utilize
             importance: high
             priority: high
             ttl: 0
   
        - delay: 00:06:00

Yes, because you have a condition that checks if the trigger.for.seconds is equal to 60, which is only true for 1 minute :wink:

Anyway, why do you even have this condition? There’s only one trigger.

I see now :upside_down_face:
I need the automation to run from November to March. I have found this solution here in the forum and I am already using it in another automation so I thought it is ok to apply it in this one too…

It’s probably even my automation that you saw lol

I was not talking about the whole condition, only the part trigger.for.seconds == 1 * 60, you can remove this part from the condition.

1 Like

maybe :slight_smile:
to be honest I was confused and as you understand I didn’t know what excactly the condition did…
anyway I will change it to the following and I will I test it later when I return home. Hopefully it will work

  - condition: template
    value_template: '{{ now().month >= 10 or now().month <= 3 }}'

What did you think that condition was actually doing for you?

It’s usually not good practice to randomly copy bits of code you don’t understand into your config.it could cause unexpected (possibly bad) results.

I thought that 1 * 60 was needed to do the calculation of the month :frowning:
I just test it in without it in developers tool and saw that it is still working.

Thankfully now is working.

Thanks again @Burningstone