Delay telegram message but only if still needed

The automation below tells me if a smartplug is using more than 275 Watts.

I am trying to avoid that i will get Telegram messages all the time.

I am trying to build in a delay. So i would like a Telegram after the first 5 minutes and after that after every hour the smart plug is still using more than 275 watts. At the moment i will get the Telegram after a hour even if the watts are below 275 after 10 minutes.

If i don’t use a delay i will get a Telegram constantly as long as the plug uses more than 275 watts.

alias: Zolder - Verbruik hoger dan 275 Watt (standaard verbruik)
description: ""
trigger:
  - type: power
    platform: device
    device_id: a03bad515956885c71b8a35fc09756fb
    entity_id: sensor.zolder_smartplug_active_power_3
    domain: sensor
    above: 275
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition: []
action:
  - repeat:
      until:
        - type: is_power
          condition: device
          device_id: a03bad515956885c71b8a35fc09756fb
          entity_id: sensor.zolder_smartplug_active_power_3
          domain: sensor
          below: 275
      sequence:
        - delay: "01:00:00"
        - service: notify.telegram_bericht_nick
          data:
            title: "!!!!!ZOLDER verbruik hoger dan 275 Watt!!!!!"
            message: Servers of WIN11CLT01 aanlaten staan?
mode: single
trace:
  stored_traces: 50

Put the delay after the notification, but be advised that long-running automations such as this is often not preferred, since a reload (if this automation was modified) or restart (of HA) could interrupt it.

The help here often makes so much sense, but also often not sure how to do that.

Could you show me how?

Do you have a better way to do it?

        - service: notify.telegram_bericht_nick
          data:
            title: "!!!!!ZOLDER verbruik hoger dan 275 Watt!!!!!"
            message: Servers of WIN11CLT01 aanlaten staan?
        - delay: "01:00:00"

Think I would use an alert for this rather than such a long delay. If your happy using a long delay then you could place a condition under your above delay to check the watts before sending the message.

Okee it looked at an Alert and that sounds like a better option. But how do i change it from an on/off script to above x watts ?

# Example configuration.yaml entry
alert:
  garage_door:
    name: Garage is open
    entity_id: input_boolean.garage_door
    state: "on"   # Optional, 'on' is the default value
    repeat:
      - 15
      - 30
      - 60
    can_acknowledge: true  # Optional, default is true
    skip_first: true  # Optional, false is the default
    notifiers:
      - ryans_phone
      - kristens_phone

You can create a template binary sensor as described in the documentation I linked to:

OR
You could create a threshold sensor that would achieve the same results: