Event triggers? I need help!

HA yelled at me this morning because it no longer likes my years-old automation based on my binary_sensor from my Ring Doorbell. This was my old automation:

image

But now I guess it wants me to use the Ding event rather than the binary_sensor:
image

I just can’t figure out what the syntax would be. The entity_id of the ding event is event.front_door_ding. Can anyone help?

You should just need a State trigger:

trigger:
  - platform: state
    entity_id: event.front_door_ding

Thanks @Didgeridrew, but I feel like there should be more to it than that. When I look at my event states, the current state is a timestamp.

Just to clarify, don’t confuse Event triggers with what you are asking about… Event entities

Yes, event entities return a timestring for their state; just like the other “stateless” entity types: button, input_button, scene, and conversation. This timestring is when the event last occurred.

By using an open State trigger (without a defined to or from), the trigger will fire whenever the state updates. The attributes of the event entity should be static. If you want to be extra safe and guard against the possibility that an attribute change causes the trigger to fire, you can add a to or from or one of the “not” variations as follows:

triggers:
  - trigger: state
    entity_id: event.front_door_ding
    not_to: 
      - unknown
      - unavailable
conditions: []
actions:
....

I think you just nailed it. Thank you!

Hi Mike,

Did it yell anything in particular?

What you show appears to be the legacy syntax, but it should work that way and continue to work that way al-be-it with a warning that it’s legacy syntax from Code Server Ha extension.

Unfortunately I dismissed the notifications a little too quickly, but I think it said that the binary_sensor would be removed in 2024.11.0. I’m not sure if it is a HA thing or specific to the Ring integration. But we’ll know in a couple of days!

Hi there,
Maybe somebody can help with a similar issue I am having.
I am trying to get my event doorbird doorbell ring to trigger an audio sound file.
So far I am able to get the sound clip to play (Run action in the automations section), but when I actually go to ring the doorbell nothing happens.
I have added this to a manual event (add trigger → manual event) as mentioned above

trigger:

  • platform: state
    entity_id: event.doorbird_outside_station_somebody_pressed_the_doorbell
    not_to: unknown

Maybe I am not understanding this correctly and somebody can help.
Thanks a lot. Any help is highly appreciated.

Hi Sebastian, do you see the trigger firing when you look at the traces and/or can you see the state changing in Developer tools → STATES?

The trigger configuration you have posted is a (improperly formatted) State trigger, but you claim:

… it cannot be both.

Please clarify what you are actually using and post the full automation. Showing only snippets often prolongs the process of us figuring out what is actually going on.

@Nick4
This is what I have in Developer Tools → States when I push the doorbell:

I don’t know what the button Set State means. I clicked on it, but nothing happens. Also I can look at the History showing that the Event was noted.
(I tried adding another screenshot, but I am limited to so many screenshots and replies)

So it seems that when I physically push the doorbell the state is recorded in Home Assistant. (Detected an event - 2 minutes ago)

@Didgeridrew
This is what I have set up as an automation. Under the “Add trigger” I have set it to “manual event” . So I guess I am going completely wrong with the “event data” section.


Right now, I have added an mp3 file to be played, just for testing purposes. This would then be replaced with a ding dong mp3 file.
Does this information help?
Thanks everybody for helping on this matter. I am fairly new to Home Assistant and appreciate any help on this.

Please follow Questions Guidelines #14 and #11 by sharing your automation’s configuration as properly formatted YAML…

Based on the provided screenshot you are using an Event trigger (labelled “Manual Event” in the “Add Trigger” menu). While it is possible to achieve your goal that way, it is more complicated and unnecessary. Since you have an event entity, the easier way is to use a State trigger. When using the graphical Automation editor, you can find State triggers either by typing “State” in the search bar of the “Add Trigger” menu or by selecting “Entity”, then “State”.

Be aware, in order to use the not_to configuration variable, you will need to edit the trigger in YAML which can be done by clicking the “breadcrumbs” menu and selecting “Edit in YAML”.

trigger: state
entity_id: event.doorbird_outside_station_somebody_pressed_the_doorbell
not_to: 
  - unknown
  - unavailable

When complete it should look something like the following in the Automation editor:

1 Like

This is what I copied out from the complete YAML code:

alias: TEST Doorbell
description: ""
triggers:
  - trigger: event
    event_type: doorbell_ring
conditions: []
actions:
  - action: sonos.snapshot
    metadata: {}
    data:
      with_group: true
      entity_id: media_player.office
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - action: media_player.play_media
    target:
      entity_id: media_player.office
    data:
      media_content_id: >-
        x-file-cifs://192.168.1.4/Media/Music/Misc/SoundFiles/001%20-%20%20youve-got-mail-sound.mp3
      media_content_type: track
    metadata:
      title: 001 -  youve-got-mail-sound.mp3
      thumbnail: >-
        http://192.168.1.72:1400/getaa?u=x-file-cifs://192.168.1.4/Media/Music/Misc/SoundFiles/001%20-%20%20youve-got-mail-sound.mp3&v=279
      media_class: track
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: library
          media_content_id: ""
        - media_content_type: track
          media_content_id: A:TRACKS
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - action: sonos.restore
    metadata: {}
    data:
      with_group: true
      entity_id: media_player.office
mode: single

I also had this code in another test version, also this one does not work:

alias: Doorbell Ring
description: ""
triggers:
  - trigger: event
    event_type: doorbell_ring
    event_data:
      automation:
        triggers:
          - trigger: event
            event_type:
              - doorbird_outside_station_somebody_pressed_the_doorbell
conditions: []
actions:
  - action: sonos.snapshot
    metadata: {}
    data:
      with_group: true
      entity_id: media_player.office
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - action: media_player.play_media
    target:
      entity_id: media_player.office
    data:
      media_content_id: >-
        x-file-cifs://192.168.1.4/Media/Music/Misc/SoundFiles/001%20-%20%20youve-got-mail-sound.mp3
      media_content_type: track
    metadata:
      title: 001 -  youve-got-mail-sound.mp3
      thumbnail: >-
        http://192.168.1.72:1400/getaa?u=x-file-cifs://192.168.1.4/Media/Music/Misc/SoundFiles/001%20-%20%20youve-got-mail-sound.mp3&v=279
      media_class: track
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: library
          media_content_id: ""
        - media_content_type: track
          media_content_id: A:TRACKS
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - action: sonos.restore
    metadata: {}
    data:
      with_group: true
      entity_id: media_player.office
mode: single

None of those are what I provided previously…

My bad, I thought I was supposed to share my code what I had.
Thanks a lot for your help. This now works !

trigger: state
entity_id: event.doorbird_outside_station_somebody_pressed_the_doorbell
not_to:
  - unknown
  - unavailable

Awesome ! Thanks a lot for helping.