Automation for door chime

Does anyone have some examples of their automation to make the piezo buzzer chime when the door opens/closes? I can get the buzzer to chime when the door opens but having difficulty getting it to shut off.

Greg,


Here is the automation I was using with the delay.  It was set to play the chime for 2 seconds, however in reality it was always something like 5 seconds.  However, it became unreliable, and I would have to turn the chimes off manually,


- id: '1531025654050'

  alias: Opened Door

  trigger:

  - entity_id: group.doors

    from: 'off'

    platform: state

    to: 'on'

  condition: []

  action:

  - data:

      entity_id: group.alarm_chimes

    service: switch.turn_on

  - delay: 00:00:02

  - data:

      entity_id: group.alarm_chimes

    service: switch.turn_off



I posted a message on the other thread with what I am doing now.


Hope this helps, and maybe someone has a better way to do it than me.