Send message to Telegram and repeat it

I created an automation in HA that looks like this and works fine. It triggers when the sensor is turned on. Can I adjust it so that it sends the message again every 5 minutes, for example, until the sensor status is turned off again?

- id: '1234567890'
  alias: Telegram_Garagedeur_OPEN
  description: ''
  triggers:
  - trigger: state
    entity_id:
    - binary_sensor.garagedeur_input_100
    from:
    - 'off'
    to:
    - 'on'
  conditions: []
  actions:
  - action: telegram_bot.send_message
    metadata: {}
    data:
      config_entry_id: 03KE62HST543SBDH789DKW5
      message: Garagedeur is OPEN
      title: Waarschuwing !!
      target:
      - '007'
  mode: single

Ofcourse you can, there is building blocks repeat

repeat:
  until:
    - condition: state
      entity_id: binary_sensor.garageopen
      state:
        - "off"
  sequence: []

And fillin the sequence with a wait of 5 minutes and telegram action

There is also ’ repeat while’, check the difference on when condition is validated

Thanks, I’m new to HA and not very familiar with yaml configs But will try to get this repeat action into the yaml.

It’s also in UI building blocks

I used UI building blocks but couldn’t find it there. Can you tell me where?

Thanks, I found it, and everything works fine. Except for the time delay function. If I set the condition “Sensor equals ON” for a duration of 5 minutes, the action isn’t executed. Only if there’s no duration, the action is executed immediately. It would be great if I could wait 5 minutes after the sensor is set to ON before the action is executed.

If Garage_door_sensor is equal to On for 5:00

To delay the trigger so that the door must be open for a certain amount of time before the actions are executed, you can add a duration with the for key:

  - trigger: state
    entity_id: binary_sensor.garagedeur_input_100
    from: 'off'
    to: 'on'
    for: "00:05:00"

Then, to delay how often the message is sent you’ll need to use a Delay action inside the Repeat action’s sequence. In the UI selector, the Delay action is in “Blocks” as well… at the bottom under “Wait for time to pass(delay)”:

image

Putting it all together:

- id: '1234567890'
  alias: Telegram_Garagedeur_OPEN
  description: ''
  triggers:
    - trigger: state
      entity_id: binary_sensor.garagedeur_input_100
      from: 'off'
      to: 'on'
      for: "00:05:00"
  conditions: []
  actions:
    - repeat:
        until:
          - condition: state
            entity_id: binary_sensor.garagedeur_input_100
            state: "off"
        sequence: []
          - action: telegram_bot.send_message
            metadata: {}
            data:
              config_entry_id: 03KE62HST543SBDH789DKW5
              message: Garagedeur is OPEN
              title: Waarschuwing !!
              target:
                - '007'
          - delay: "00:01:00"
  mode: single

Thank you Yes i did it. My first automatation. :slightly_smiling_face:

1 Like