Automation with time delay, e-mail sending

Hello,

I am new to HA and so far I have implemented my scripts with Blockly in IOBroker.

I would like to run the following automation:
If the window contact (is already created via ZigBee as an entity) is on (true) for 10 minutes, then send an e-mail saying: window is open for more than 10 minutes, please close.

If the window contact is closed (false) for at least 20 seconds (to avoid false messages when changing from open/tilted the time delay) then also send an e-mail with the content: Window is closed.

How must this automation look like? Especially in relation to the time delays.
Is there anything that needs to be set for sending e-mails?

Thanks a lot

Anyone any idea?

You will need to set up a notifier for whatever email service you use.

SMTP email notifier

Then you will need to create your automation:

trigger:
  - platform: state
    entity_id: binary_sensor.window
    to: 'on'
    from: 'off'
    for: "00:10:00"
  - platform: state
    entity_id: binary_sensor.window
    to: 'off'
    from: 'on'
    for: "00:00:20"
condition: []
action:    
  - service: notify.YOUR_EMAIL_NOTIFIER
    data:
      title: Window
      message: |
        Window is {{ "open for more than 10 minutes, please close" if trigger.to_state.state == 'on' else "closed" }}

@Didgeridrew Thanks for the answer. The automation works fine so far.

One question about the e-mail text: Do you happen to know how I can modify it with HTML tags? e.g. <b><h2>.

There is an html example in the SMTP documentation link above, but that’s not something I’ve ever bothered with.

Ok, I will try. Thanks :wink: