Tips to improve this script (doorbell and notification) for use with the companion app?

So I’m using the script below when someone rings the doorbell.
Are there better ways/solutions to make this more foolproof for:

  • when another app has focus
  • display is off/locked
alias: "Notification: Doorbell => phone"
sequence:
  - service: notify.mobile_app_phone
    data:
      message: TTS
      data:
        ttl: 0
        priority: high
        media_stream: alarm_stream_max
        tts_text: Someone is at the door
    enabled: true
  - service: notify.mobile_app_phone
    data:
      message: command_screen_on
    enabled: true
  - service: notify.mobile_app_phone
    data:
      message: command_webview
    enabled: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: browser_mod.popup
    data:
      size: fullscreen
      browser_id: 75e1bad0-5ccf9174
      content:
        type: vertical-stack
        cards:
          - square: false
            columns: 3
            type: grid
            cards:
              - type: custom:config-template-card
                entities:
                  - switch.gate1_status
                card:
                  type: button
                  tap_action:
                    action: none
                  hold_action:
                    action: call-service
                    service: script.switch_gate1
                    data: {}
                    target: {}
                  name: Gate 1
                  show_name: false
                  entity: switch.gate1_status
                  icon: >-
                    ${ states['switch.gate1_status'].state  === 'on' ?
                    'mdi:gate-alert' : 'mdi:gate-arrow-right' }
              - type: custom:config-template-card
                entities:
                  - switch.gate2_status
                card:
                  type: button
                  tap_action:
                    action: none
                  hold_action:
                    action: call-service
                    service: script.switch_gate2
                    data: {}
                    target: {}
                  name: Gate 2
                  show_name: false
                  entity: switch.gate2_status
                  icon: >-
                    ${ states['switch.gate2_status'].state  === 'on' ?
                    'mdi:gate-open' : 'mdi:gate' }
              - type: custom:config-template-card
                entities:
                  - switch.garagedoor_status
                card:
                  type: button
                  tap_action:
                    action: none
                  hold_action:
                    action: call-service
                    service: script.switch_garagedoor
                    data: {}
                    target: {}
                  name: Garagedoor
                  show_name: false
                  entity: switch.garagedoor_status
                  icon: >-
                    ${ states['switch.garagedoor_status'].state  === 'on' ?
                    'mdi:garage-open-variant' : 'mdi:garage-variant' }
          - camera_view: live
            type: picture-glance
            entities: []
            camera_image: camera.door
      dismissable: true
      autoclose: false
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: browser_mod.close_popup
    data:
      browser_id: 75e1bad0-5ccf9174
mode: single

Thanks for any help!

I have a script that does the following steps on Android phones:

  1. set ringer volume to 100%
  2. set ringer mode to normal
  3. post sticky notification with DISMISS button to alarm_stream channel
  4. wait for the user to press DISMISS button
  5. remove notification
  6. set ringer to previous mode (like silence or vibrate, if it wasn’t already in normal mode)

I also downloaded a custom mp3 alarm sound that plays when the notification is triggered (this is set on the phone, nothing to do with HA). It only stops when I press one of the volume keys on the phone, when the notification panel is expanded or when I press the dismiss button.

If you’re interested, I can post it here.

1 Like

Hi Tristan, thanks for dropping by.

As you can see from my automation, I create that TTS with high priority. That does work well and I don’t have to touch anything else (volume, ringer mode) and do not have to reset at the end.

A notification is not a problem, that will be shown anyway most of the time.
Opening a camera stream seems to be more of a challenge.