Doorbell - Notify Alexa

Blueprint to make a TTS announcement when a binary sensor goes from off to on, e.g. a doorbell sensor.

You can select a binary sensor, an echo device to make the announcement and customise the announced message.

NOTE: This only works with amazon echo devices and you require the alexa media player add-on.

You can announce to multiple echo devices by inputting a comma separated list or a group.

Blueprint screen:

Blueprint to import:

blueprint:
  name: Doorbell - Notify Alexa
  description: "Make an announcement over Amazon Echo devices when the doorbell is pushed."

  domain: automation
  input:
    doorbell:
      name: Doorbell
      description: This is the doorbell binary sensor
      selector:
        entity:
          domain: binary_sensor
    echo_device1:
      name: First Alexa
      description: The First Alexa device to make the announcement on. Make a comma seperated list to announce on multiple devices.
      selector:
        entity:
          domain: media_player
    echo_device2:
      name: Second Alexa
      description: The Second Alexa device to make the announcement on. Make a comma seperated list to announce on multiple devices.
      selector:
        entity:
          domain: media_player
      default: ""
    echo_device3:
      name: Third Alexa
      description: The Third Alexa device to make the announcement on. Make a comma seperated list to announce on multiple devices.
      selector:
        entity:
          domain: media_player
      default: ""
    echo_device4:
      name: Fourth Alexa
      description: The Fourth Alexa device to make the announcement on. Make a comma seperated list to announce on multiple devices.
      selector:
        entity:
          domain: media_player
      default: ""
    echo_device5:
      name: Fifth Alexa
      description: The Fifth Alexa device to make the announcement on. Make a comma seperated list to announce on multiple devices.
      selector:
        entity:
          domain: media_player
      default: ""
    announcement_volume:
      name: Announcement Volume
      description: The volume the Alexa devices will be changed to for the announcement. Set to zero (0) for no change.
      default: 0.5
      selector:
        number:
          min: 0
          max: 1
          step: 0.1
          mode: slider
    repeat_after:
      name: Repeat Timer
      description: Set a time delay to repeat the message. Set to zero (0) for no repeat.
      default: 0
      selector:
        number:
          min: 0
          max: 10
          step: 1
          mode: slider
    message:
      name: Message (Optional)
      description: 'Default: "There is Somebody at the Door!"'
      default: There is Somebody at the Door
  source_url: https://gist.github.com/seamus65/66ec3d2ac935686684c95fe79bbf309a
mode: single

variables:
  echo_device1: !input echo_device1
  echo_device2: !input echo_device2
  echo_device3: !input echo_device3
  echo_device4: !input echo_device4
  echo_device5: !input echo_device5
  inputs:
    "{% if (echo_device1 and echo_device2 and echo_device3 and echo_device4 and echo_device5) %}
    {{ echo_device1 }}, {{ echo_device2 }}, {{ echo_device3 }}, {{ echo_device4 }}, {{ echo_device5 }}
    {% elif (echo_device1 and echo_device2 and echo_device3 and echo_device4) %}
    {{ echo_device1 }}, {{ echo_device2 }}, {{ echo_device3 }}, {{ echo_device4 }}
    {% elif (echo_device1 and echo_device2 and echo_device3) %}
    {{ echo_device1 }}, {{ echo_device2 }}, {{ echo_device3 }}
    {% elif (echo_device1 and echo_device2) %}
    {{ echo_device1 }}, {{ echo_device2 }}
    {% elif (echo_device1) %}
    {{ echo_device1 }}
    {% endif %}"
  volume1: "{% if (echo_device1) %} {{ state_attr(echo_device1, 'volume_level') }} {% endif %}"
  volume2: "{% if (echo_device2) %} {{ state_attr(echo_device2, 'volume_level') }} {% endif %}"
  volume3: "{% if (echo_device3) %} {{ state_attr(echo_device3, 'volume_level') }} {% endif %}"
  volume4: "{% if (echo_device4) %} {{ state_attr(echo_device4, 'volume_level') }} {% endif %}"
  volume5: "{% if (echo_device5) %} {{ state_attr(echo_device5, 'volume_level') }} {% endif %}"
  announcement_volume: !input announcement_volume
  repeat_after: !input repeat_after

trigger:
  - platform: state
    entity_id: !input "doorbell"
    from: "off"
    to: "on"
action:
  - choose:
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ echo_device1 != '' }}"
              - condition: template
                value_template: "{{ echo_device2 != '' }}"
              - condition: template
                value_template: "{{ echo_device3 != '' }}"
              - condition: template
                value_template: "{{ echo_device4 != '' }}"
              - condition: template
                value_template: "{{ echo_device5 != '' }}"
              - condition: template
                value_template: "{{ repeat_after > 0 }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: !input repeat_after
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume2 }}"
            target:
              entity_id: "{{ echo_device2 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume3 }}"
            target:
              entity_id: "{{ echo_device3 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume4 }}"
            target:
              entity_id: "{{ echo_device4 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume5 }}"
            target:
              entity_id: "{{ echo_device5 }}"
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ echo_device1 != '' }}"
              - condition: template
                value_template: "{{ echo_device2 != '' }}"
              - condition: template
                value_template: "{{ echo_device3 != '' }}"
              - condition: template
                value_template: "{{ echo_device4 != '' }}"
              - condition: template
                value_template: "{{ repeat_after > 0 }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: !input repeat_after
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume2 }}"
            target:
              entity_id: "{{ echo_device2 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume3 }}"
            target:
              entity_id: "{{ echo_device3 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume4 }}"
            target:
              entity_id: "{{ echo_device4 }}"
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ echo_device1 != '' }}"
              - condition: template
                value_template: "{{ echo_device2 != '' }}"
              - condition: template
                value_template: "{{ echo_device3 != '' }}"
              - condition: template
                value_template: "{{ repeat_after > 0 }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: !input repeat_after
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume2 }}"
            target:
              entity_id: "{{ echo_device2 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume3 }}"
            target:
              entity_id: "{{ echo_device3 }}"
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ (echo_device1 != '') }}"
              - condition: template
                value_template: "{{ (echo_device2 != '') }}"
              - condition: template
                value_template: "{{ repeat_after > 0 }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: !input repeat_after
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume2 }}"
            target:
              entity_id: "{{ echo_device2 }}"
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ echo_device1 != '' }}"
              - condition: template
                value_template: "{{ repeat_after > 0 }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: !input repeat_after
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ echo_device1 != '' }}"
              - condition: template
                value_template: "{{ echo_device2 != '' }}"
              - condition: template
                value_template: "{{ echo_device3 != '' }}"
              - condition: template
                value_template: "{{ echo_device4 != '' }}"
              - condition: template
                value_template: "{{ echo_device5 != '' }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume2 }}"
            target:
              entity_id: "{{ echo_device2 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume3 }}"
            target:
              entity_id: "{{ echo_device3 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume4 }}"
            target:
              entity_id: "{{ echo_device4 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume5 }}"
            target:
              entity_id: "{{ echo_device5 }}"
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ echo_device1 != '' }}"
              - condition: template
                value_template: "{{ echo_device2 != '' }}"
              - condition: template
                value_template: "{{ echo_device3 != '' }}"
              - condition: template
                value_template: "{{ echo_device4 != '' }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume2 }}"
            target:
              entity_id: "{{ echo_device2 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume3 }}"
            target:
              entity_id: "{{ echo_device3 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume4 }}"
            target:
              entity_id: "{{ echo_device4 }}"
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ echo_device1 != '' }}"
              - condition: template
                value_template: "{{ echo_device2 != '' }}"
              - condition: template
                value_template: "{{ echo_device3 != '' }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume2 }}"
            target:
              entity_id: "{{ echo_device2 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume3 }}"
            target:
              entity_id: "{{ echo_device3 }}"
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ (echo_device1 != '') }}"
              - condition: template
                value_template: "{{ (echo_device2 != '') }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
          - delay: 0.5
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume2 }}"
            target:
              entity_id: "{{ echo_device2 }}"
      - conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ announcement_volume > 0 }}"
              - condition: template
                value_template: "{{ echo_device1 != '' }}"
        sequence:
          - service: media_player.volume_set
            data:
              volume_level: !input announcement_volume
            target:
              entity_id: "{{ inputs }}"
          - delay: 0.5
          - service: notify.alexa_media
            data:
              target: "{{ inputs }}"
              message: !input message
              data:
                type: tts
          - delay: 3
          - service: media_player.volume_set
            data:
              volume_level: "{{ volume1 }}"
            target:
              entity_id: "{{ echo_device1 }}"
    default:
      - service: notify.alexa_media
        data:
          target: "{{ inputs }}"
          message: !input message
          data:
            type: tts
      - delay: !input repeat_after
      - service: notify.alexa_media
        data:
          target: "{{ inputs }}"
          message: !input message
          data:
            type: tts

4 Likes

Note: Amazon Alexa can natively support this kind of announcement if you don’t want to use the Alexa Media Player. I’ve posted details on using that here: Alexa Doorbell Announcements

1 Like

Hi,

I want to create a similar automation with a zigbee door contact, however I would like to be able to change which Alexa the sound will play on based on the state of a helper button. Ideally I’d like to change the state via a Alexa voice command.

My current setup is through the zigbee hub within Alexa in the kitchen, it plays a door chime notification sound when door sensor is activated between 09:00 till 22:00.

Project
I have purchased a Sonoff Zigbee 3.0 USB Dongle Plus and therefore would like to setup the following voice activated automation with the two Alexa’s located in the Bedroom and Kitchen.

The two states would be as follows:

State 1
Kitchen only

State 2
Bedroom and Kitchen.

I’m still new to coding and am struggling on how to configure this, especially the IF/ELSE part?

Updated to allow you to change the volume of the targeted Alexa devices, if you want to, and repeat the message, also if you want to.

With either the volume or the repeat, if you set the slider to zero that action will not be carried out.

The code is a bit messy, but it works for me.

Change requested by @MBR74

Thanks for the quick and working solution.
I noticed a problem.
If I listen to the radio and then the announcement comes, Alexa changes the volume, but does not switch back to the volume that was previously played the music.
And maybe a little break before the announcement 1-2 seconds. That would still be great. That would make the notification stand out a bit.

Thank you and it would be great if these changes were still possible.

In order to return to th previous volume you need to use variables etc.
I am not sure if I can do that with blueprints, but I will have a look when I get a chance.

This should work now, but there will be a moment at the beginning and end of the message where the radio is at the notification volume

Thank you you are the greatest.
Works well

If anyone is interested, I made a version of this blueprint that uses a sound/chime rather than a message: