Doorbell cam actionable notification with app launcher

Based on @AndreiRadchenko’s blueprint found here: 414976

I modified the original blueprint to allow for one of the actions to launch a custom app on your phone. Tested and working on Android.

Quoted/modified info from original:

Blueprint for automation that sends actionable notifications with a photo on doorbell press.
Notifications are sent to home assistant companion app on android or ios.

Automation can be triggered by any entity that changes state from ‘on’ to ‘off’. i.e. switch, motion sensor, input_boolean, binary_sensor can bee chosen as automation trigger.
You can edit notification title . Message is day and time of automation triggering.
Snapshots are stored in config/www/doorbell folder and can bee used with gallery card.

You can specify mobile_app device or group of devices for notification to be sent to.
For iOS yor can chose notification sound from dropdown list, or set you own sound.
There are three action button in notification. The first one opens dashboard view that specified in blueprint. The second one launches the phone app you specify. And the third one performs configurable action2.

You can also set the time during which the actions in the notification are active.

blueprint:
  name: Doorbell cam actionable notification with app launcher
  description: Blueprint for automation that send actionable notification with photo
    on doorbell press. Notification are sending to home assistant companoin app on
    android or ios. Automation can triggering by any entity that change state from
    <on> to <off>. i.e. switch, motion sensor, input_boolean, binary_sensor can bee
    chosen as automation trigger. You can edit notification title . Message is day
    and time of automation triggering. Snapshots are stored in <config/www/doorbell>
    folder and can bee used with gallery card. You can specify mobile_app device or
    group of devices for notification to be sent to. For iOS yor can chose notification
    sound from dropdown list. There are three action button in notification. The first
    one opens dashboard view that specified in blueprint. Next two buttons perform
    configurable action1 and action2. You can set the time during which the actions
    in the notification are active.
  domain: automation
  input:
    notification_title:
      name: Notification title (Optional)
      description: 'Default: "Someone rang the doorbell!"'
      default: Someone rang the doorbell!
    doorbell_button:
      name: Trigger entity
      description: Changing state of this entity fom <off> to <on> will start doorbell
        notification automation.
      selector:
        entity: {}
    doorbell_cam:
      name: Doorbell Cam
      description: The Camera from wich take photo for notification.
      selector:
        entity:
          domain: camera
          multiple: false
    notify_dev:
      name: Device to notify
      description: Device or group of devices for notification through mobile_app
        notification service. For example <notify.mobile_app_iphone>, <notify.all_devices>
      selector:
        text:
          type: search
          multiline: false
    ios_sound:
      name: Notification sound
      description: Notification sound for iOS (Optional). Default <US-EN-Morgan-Freeman-Someone-Is-Arriving.wav>
      default: US-EN-Morgan-Freeman-Someone-Is-Arriving.wav
      selector:
        select:
          mode: dropdown
          custom_value: true
          options:
          - US-EN-Morgan-Freeman-Someone-Is-Arriving.wav
          - US-EN-Morgan-Freeman-Wife-Is-Arriving.wav
          - US-EN-Morgan-Freeman-Boss-Is-Arriving.wav
          - US-EN-Morgan-Freeman-Girlfriend-Is-Arriving.wav
          - US-EN-Morgan-Freeman-Welcome-Home.wav
          - US-EN-Morgan-Freeman-Son-Is-Arriving.wav
          - US-EN-Morgan-Freeman-Roommate-Is-Arriving.wav
          - US-EN-Morgan-Freeman-Motion-Detected.wav
          - US-EN-Morgan-Freeman-Motion-In-Wine-Cellar.wav
          - US-EN-Morgan-Freeman-Motion-In-Garage.wav
          - US-EN-Daisy-Back-Door-Motion.wav
          - US-EN-Daisy-Front-Door-Motion.wav
          - US-EN-Alexa-Motion-In-Garage.wav
          - US-EN-Alexa-Motion-In-Back-Yard.wav
          - US-EN-Alexa-Motion-Detected-Generic.wav
          multiple: false
    uri_:
      name: Dashboard tab
      description: Dashboard tab to open by click <Dashboard> button. Default </lovelace/default_view>
      default: /lovelace/default_view
    uri2_:
      name: Cam App
      description: Phone app to launch
      default: app://replace.with.app.uri
    action2_title:
      name: Action 2 title (Optional)
      description: Action to perform on click action 2 button
      default: action2
    action2:
      name: Action 2
      description: Action to run on action button 2 press
      default: []
      selector:
        action: {}
    delay:
      name: Delay (Optional)
      description: The time during which the actions in the notification are active
      default: '30'
      selector:
        number:
          min: 0.0
          max: 120.0
          unit_of_measurement: seconds
          mode: slider
          step: 1.0
  source_url: https://community.home-assistant.io/t/doorbell-cam-actionable-notification-with-app-launcher/489144
variables:
  button: !input doorbell_button
  image_file: /local/doorbell/{{ expand(button)[0].last_changed | as_timestamp  |
    timestamp_custom("%Y-%m-%d_%H-%M-%S") }}.jpg
trigger:
- entity_id: !input doorbell_button
  platform: state
  from: 'off'
  to: 'on'
condition: []
action:
- alias: Set up variables for the actions
  variables:
    action_2: '{{ ''ACTION_2'' ~ context.id }}'
- data_template:
    entity_id: !input doorbell_cam
    filename: /config/www/doorbell/{{ expand(button)[0].last_changed | as_timestamp  |
      timestamp_custom("%Y-%m-%d_%H-%M-%S") }}.jpg
  service: camera.snapshot
- service: !input notify_dev
  data:
    title: !input notification_title
    message: '{{ as_timestamp(now()) | timestamp_custom(''%d:%m %H:%M'', true) }}'
    data:
      push:
        sound: !input ios_sound
      ttl: 0
      priority: high
      image: '{{ image_file }}'
      actions:
      - action: URI
        title: Dashboard
        uri: !input uri_
      - action: URI
        title: App
        uri: !input uri2_
      - action: '{{ action_2 }}'
        title: !input action2_title
- alias: Wait for a response
  wait_for_trigger:
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: '{{ action_2 }}'
  timeout: !input delay
  continue_on_timeout: true
- alias: Perform the action
  choose:
  - conditions:
    - condition: template
      value_template: '{{ wait.trigger.event.data.action == action_2 }}'
    sequence: !input action2

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Apologies to those who may have tried importing early on. Still learning how to share these things, but I believe it should import correctly now. Please let me know if not! :slight_smile:

Also, here is the information on device groups from the original blueprint too (it still applies here):

To create notification groups, add the following to your configuration.yaml. Be sure to replace the example device names with names of your own devices:

notify:
  - name: ALL_DEVICES
    platform: group
    services:
      - service: mobile_app_iphone
      - service: mobile_app_mi_a3
      - service: mobile_app_nokia_5_3
      - service: mobile_app_pocox3 

Btw, @McDAlexander has a similar (and dare I say, better?!) blueprint that you can find here: Actionable notifications for Android w/ Cam Snapshot

2 Likes

Hello,
After create automation, it don’t apear in the list of automation.
Thanks

Sorry for not getting back to you sooner, but it looks like you got this resolved with McDAlexander’s help. Appears to have been a typo in your automation that prevented it from showing up in your automations list.

This blueprint does everything really well for my needs, with one exception in my use case. The button on the Doorbird D1101 door cam is not an entity for me, but it does generate an event when pressed, so I’ve typically used events to trigger automations from the ‘pressing of the button’.

Is anyone aware of a blueprint (as close to this one as possible) that uses an event as the trigger instead of a specific entity state change from off to on. I’ve had an initial attempt at modifying this one to change entity status trigger to event trigger, but can’t get it right.

Perhaps there is a way to create a ‘virtual’ entity that changes state based on an event and handle that challenge outside of this blueprint, but that feels like an unnecessary step.

I fee like I’m missing something really fundamental in my understand or maybe it’s just not good practice to include events as triggers in blueprints (for reasons I don’t know). Anyone willing to educate me on this?

Until someone creates/finds a blueprint that reacts to events, you could try something like this:

  1. Create a new input boolean helper that will be used to track the on/off status of your doorbell event. Maybe call it something like “Doorbell Button Pressed” or something else easy to identify.
  2. Create a new automation that flips that input boolean helper on then back off after a few seconds (i.e. your action) whenever that event is detected (i.e. your trigger). This will basically emulate a doorbell entity, ala “virtual” entity. Sure it may seem unnecessary, but in you’re doorbell’s case it sounds like it may actually be necessary.
  3. Then use your new input boolean helper as the “virtual” (or trigger) entity in this or whichever blueprint you choose

Hope that helps for now. There’s probably a more elegant solution out there, but this seems like the easiest to achieve from the UI

On a separate note, I am now noticing that this blueprint (as well as @McDAlexander’s) appears to be letting snapshots build up (they are not automatically deleted). Leaving this note here for myself and others in case someone has some time to maybe add a file delete action at the end of the automation. We probably don’t want to fill our storage with doorbell snapshots over time :confused:

Perhaps a simple and separate automation to periodically delete the snapshots would suffice for now.

Another note to self and others… this may be the way to go for deleting snapshots:

Is it possible to also change the notification icon?
mdi:human-greeting-variant

Hello, this blueprint works perfectly! I am using a reolink doorbell but how can I find this back? app://replace.with.app.uri
so I can open the app directly from Reolink

app://com.mcu.reolink