Help with notification if it hasn't rained

Hello,

I hope someone can help me.

Has anyone realized that if it hasn’t rained for 2 days, a notification is sent?

Or that the window has to be open for at least 5 minutes before 10 a.m. once a day?
If this was not the case, there should be a message via Notify.

I hope you can give me a little help on how to do this.

What sensors do you already have for the state of the weather, and for your window being open?

For the weather i would use openweathermap.

For the window i have door sensors on it (binary)

My approach would be to use helpers for this.
You could have an automation trigger at the state “Rain” and have it write the time stamp to a datetime helper with:

{{ now() + timedelta( days = 2) }}

That helper then is the trigger for the alert automation. Since the datetime is set to later time each time it rains, it will only trigger when it isn’t set for two days. Of course one could decide to set it at a certain time, todays ahead. But that’s fine tuning.

The window case is slightly more challenging and I do not have time for that at the moment. Maybe tomorrow, if not someone else already responded with a brilliant solution.

For the window one, I think I’d create an input_boolean helper. An automation would reset it to off at midnight (or whenever you want your “before 10am” to start):

trigger:
  - platform: time
    at: "00:00"
action:
  - service: input_boolean.turn_off
    data:
      entity_id: input_boolean.window_flag

A second automation would turn the helper on if the window has been opened for 5 minutes:

trigger:
  - platform: state
    entity_id: binary_sensor.window_open
    to: 'on'
    for:
      minutes: 5
action:
  - service: input_boolean.turn_on
    data:
      entity_id: input_boolean.window_flag

…and a third automation would send the notification at 10am if the flag remains unset:

trigger:
  - platform: time
    at: "10:00"
condition:
  - condition: state
    entity_id: input_boolean.window_flag
    state: 'off'
action:
    [whatever your notification method is]

Do you mean five minutes in one go or 2+2+1 = 5?
If you want the accumulative then you can use a history stats sensor that will count the time the window has been opened.
If you mean 5 minutes in one go then what Troon posted is a good solution.
Except I would make it one automation with choose.

alias: New Automation
description: ''
mode: single
trigger:
  - platform: time
    at: '00:00'
    id: reset_boolean


  - platform: state
    entity_id: binary_sensor.window_open
    to: 'on'
    for:
      minutes: 5
    id: window_open


  - platform: time
    at: '10:00'
    id: notification

action:
  - choose:
      - conditions:
          - condition: trigger
            id: reset_boolean
        sequence:
          - service: input_boolean.turn_off
            data:
              entity_id: input_boolean.window_flag
    default: []


  - choose:
      - conditions:
          - condition: trigger
            id: window_open
        sequence:
          - service: input_boolean.turn_on
            data:
              entity_id: input_boolean.window_flag
    default: []


  - choose:
      - conditions:
          - condition: trigger
            id: notification
        sequence:
          - condition: state
            entity_id: input_boolean.window_flag
            state: 'off'
          - service: notify.notify
            data: {}
    default: []