Automation request

Hello ,

I paste the code of my automation. It works. I only wish that the message I read to my minigoogle of the house was continuous. I would like this message to occur every 20 seconds until I deactivate it or until the sensor has resumed its initial state.
Can someone help me write the missing part ??

alias: Cancello attivato
attivato trigger trigger:

  • entity_id: binary_sensor.door_window_sensor_158d000273586e
    per: 00:00:10
    da: ‘off’
    platform: stato
    a: ‘on’

- piattaforma: time_pattern

minuti: 1

condizione: []
azione:

  • servizio: tts.google_say
    entity_id: media_player.casa_xx
    data_template:
    messaggio:> -
    {{[
    “Cancello aperto da almeno cinque minuti”,
    ] casuale}}

1 Like

I did it but the results are the same. sorry. I will learn’

alias:
trigger trigger Cancello automatico attivato:

  • entity_id: binary_sensor.door_window_sensor_158d000273586e
    per: 00:00:10
    da: ‘off’
    platform: stato
    a: ‘on’

- piattaforma: time_pattern

minuti: 1

condizione: []
azione:

  • servizio: tts.google_say
    entity_id: media_player.casa_xx
    data_template:
    messaggio:> -
    {{[
    “Cancello aperto da almeno cinque minuti”,
    ] casuale}}

Keep trying. Without properly formatted code it is very difficult to help you.

Edit your post. Paste the code again. Make sure there is a blank line above your code. Select all your pasted code and hit the </> button.

ok. Thank you for your answer. I just want to clarify:
the code I’ve pasted is ok. It works. I have no problems on that piece of code I’ve pasted.
I just want to know what to use to be able to repeat the message indefinitely or until the initial conditions return to the initial state.

Have you looked at the Alert component? I haven’t used it myself, but I suspect it will do just what you want.

Thank you, friend, for your kind reply. I’ll try to do it and I’ll let you know if it worked!
It seems just what I was looking for!

1 Like

Hello
unfortunately this function you suggested does not work for me.
Can you give me an example of how to recall the loop from a script as you suggested above?
how the script should be composed, can you do an example? grzie

ecco il mio codice di nuovo:

- id: '1549038088131'
  alias: Cancello lasciato aperto test
  trigger:
  - entity_id: binary_sensor.door_window_sensor_158d000273586e
    for: 00:03:00
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: binary_sensor.door_window_sensor_158d000273586e
    state: 'on'
  action:
  - data_template:
      message: '{{ [ "Cancello aperto da almeno cinque minuti " , ] |random }}    '
    entity_id: media_player.casa_xx
    service: tts.google_say

Ah, ok, alerts use notifications, not media_player. Sorry about that.

The easiest way is probably to add a step to your existing automation that calls a script. E.g.:

  - service: script.cancello_lasciato_aperto_loop

Then add this script:

cancello_lasciato_aperto_loop:
  sequence:
    - delay: 15
    - condition: state
      entity_id: binary_sensor.door_window_sensor_158d000273586e
      state: 'on'
    - service: automation.trigger
      entity_id: automation.cancello_lasciato_aperto_test

This script will wait 15 seconds (change it if you want it to wait a different amount of time), then if the binary_sensor is still on it will re-trigger the automation. Once the binary_sensor changes to off the script will stop re-triggering the automation.

A slightly different way would be to use two scripts. You’d change the automation action to call the first script instead of calling tts.google_say. Then the first script would do that, then call the second script. The second script would be the same as the script shown above.