Skip to content

Instantly share code, notes, and snippets.

@MattJeanes
Last active November 20, 2023 00:26
Show Gist options
  • Save MattJeanes/0bb4cb11f20b327809b7e7f1d45921be to your computer and use it in GitHub Desktop.
Save MattJeanes/0bb4cb11f20b327809b7e7f1d45921be to your computer and use it in GitHub Desktop.
A Home Assistant blueprint for emulating the Nest Hub doorbell notification with any sound and feed, uses WebRTC and DashCast custom components
blueprint:
name: Doorbell cast notification
description: A script that emulates the Nest Hub doorbell notification with any sound and feed
domain: script
source_url: https://gist.github.com/MattJeanes/0bb4cb11f20b327809b7e7f1d45921be
author: MattJeanes
input:
notify_device:
name: Device to notify
description: Device to cast the sound and doorbell camera to
selector:
entity:
filter:
domain: media_player
camera:
name: Camera feed
description: Camera feed to cast
selector:
entity:
filter:
domain: camera
sound:
name: "Sound"
description: "The sound to play before casting the camera, e.g. doorbell ringing / spoken message"
selector:
media:
ha_url:
name: "Home Assistant URL"
description: "URL to Home Assistant instance, must include protocol e.g. http/https and port if appropriate"
selector:
text:
duration:
name: "Duration"
description: "How long the camera feed should cast for before dismissing automatically"
selector:
duration:
default:
hours: 0
minutes: 0
seconds: 30
mode: single
sequence:
- variables:
link_id: "{% for _ in range(40) %}{{ range(10)|random }}{% endfor %}"
ha_url: !input ha_url
sound: !input sound
- service: webrtc.create_link
data:
entity: !input camera
link_id: "{{ link_id }}"
time_to_live: 60
open_limit: 1
enabled: true
- if:
- condition: not
conditions:
- condition: state
entity_id: !input notify_device
state: "off"
then:
- service: media_player.turn_off
data: {}
target:
entity_id: !input notify_device
- wait_for_trigger:
- platform: state
entity_id:
- !input notify_device
to: "off"
timeout:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: media_player.play_media
target:
entity_id: !input notify_device
data:
media_content_id: "{{ sound.media_content_id }}"
media_content_type: "{{ sound.media_content_type }}'"
extra:
thumb: "https://brands.home-assistant.io/_/homeassistant/logo.png"
title: Doorbell
- wait_for_trigger:
- platform: state
entity_id:
- !input notify_device
from: playing
to: idle
timeout:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: dash_cast.load_url
data:
entity_id: !input notify_device
url: "{{ ha_url }}/webrtc/embed?url={{ link_id }}&mode=mse"
force: true
enabled: true
- delay: !input duration
- if:
- condition: state
entity_id: !input notify_device
attribute: app_name
state: DashCast
for:
hours: 0
minutes: 0
seconds: 0
then:
- service: media_player.turn_off
data: {}
target:
entity_id: !input notify_device
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment