Trigger event

Hey stupid question but I have a automation trigger based on a event which runs only when I launch a script. When the automation runs it keeps looping itself over and over again. I am assuming it’s because it finds the event and nothing tells it to stop. Is there way to clear the event after the automation has run, or can I run the automation only once somehow?

You’ll have to help us to help you by pasting your code. An event is fired once.

- id: '1594069466754'
  alias: shoe finder
  description: rekognition to find shoes
  trigger:
  - event_data:
      event_data:
        name: shoe
    event_type: rekognition.label_detected
    platform: event
  condition: []
  action:
  - data:
      Preformatted textdata:
        type: tts
      message: shoe found in bedroom
    service: notify.alexa_media_mikko_s_fire



So this is a test automation. It just takes the label ‘shoe’ from the rekognition.label.detected and send a tts to alexa. Alexa just keeps repeating the line. I have to manually disable the automation. Any ideas why? Or how it stop it doing that.

To be honest I have no idea what I am doing but this is fun. :smiley:

Why the nested event_data lines?

Oh! That’s just a mistake. Man how blind I can be.

When you listen to the event under Developer Tools / Events, does it fire once or multiple times?

As I see, it only fires once. And removing the nesting seemed to fix to problem. It only ran the tts only once on Alexa.

Thank you for helping me.

1 Like

Just a bit of explanation, because the event trigger works a little differently than most people expect.

If anything is specified under the optional event_data parameter, then it only “cares” about keys that are actually in the event. It doesn’t require the key to be in the event. But if the key is in the event, then the value has to match.

So, you had:

event_data:
  event_data:
    name: shoe

That means the event data had to have a key of event_data, and its value had to be name: shoe. But since the event did not have a key named event_data, it was ignored. So any event whose type was rekognition.label_detected would trigger the automation regardless of what the event data was.

Now, when you changed it to:

event_data:
  name: shoe

That meant if the event data contained a key of name, then its value must be shoe for the trigger to fire. It didn’t have to have the key name, but if it did, then again, its value must be shoe.

2 Likes