Skip to content

Instantly share code, notes, and snippets.

@benrowe
Created May 25, 2025 01:21
Show Gist options
  • Save benrowe/47f5f67a948e463d2fab6140694f970b to your computer and use it in GitHub Desktop.
Save benrowe/47f5f67a948e463d2fab6140694f970b to your computer and use it in GitHub Desktop.
Hass Automation Scripts

Automation Scripts

Doorbell

dectects a unifi doorbell press and does the following

  1. stores the current speaker volume values for 2 speakers
  2. increases speaker volume to 80%
  3. plays a doorbell chime on both speakers
  4. tts "someone at door"
  5. restores old speaker volume

Requires a numerical helper input_number.man_cave_speaker_volume with

  • min: 0
  • max: 1
  • step: 0.01
alias: Announce Doorbell with Chime and Volume Restore
triggers:
- entity_id: binary_sensor.doorbell_doorbell
to: "on"
trigger: state
conditions: []
actions:
- data:
value: >-
{{ state_attr('media_player.man_cave_speaker', 'volume_level') |
float(0.3) }}
target:
entity_id: input_number.man_cave_speaker_volume
action: input_number.set_value
- data:
value: >-
{{ state_attr('media_player.kitchen_speaker', 'volume_level') |
float(0.3) }}
target:
entity_id: input_number.kitchen_speaker_volume
action: input_number.set_value
- data:
volume_level: 0.8
target:
entity_id:
- media_player.man_cave_speaker
- media_player.kitchen_speaker
action: media_player.volume_set
- delay: "00:00:01"
- metadata:
title: vintage-doorbell-ring-sound-effect-325247.mp3
thumbnail: null
media_class: music
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://media_source
data:
media_content_id: >-
media-source://media_source/local/vintage-doorbell-ring-sound-effect-325247.mp3
media_content_type: audio/mpeg
target:
entity_id:
- media_player.man_cave_speaker
- media_player.kitchen_speaker
action: media_player.play_media
- delay: "00:00:02"
- data:
cache: true
media_player_entity_id: media_player.man_cave_speaker
message: There's someone at the door
language: en
target:
entity_id: tts.google_translate_en_com
action: tts.speak
- delay: "00:00:05"
- data:
volume_level: "{{ states('input_number.man_cave_speaker_volume') | float(0.3) }}"
target:
entity_id: media_player.man_cave_speaker
action: media_player.volume_set
- data:
volume_level: "{{ states('input_number.kitchen_speaker_volume') | float(0.3) }}"
target:
entity_id: media_player.kitchen_speaker
action: media_player.volume_set
mode: restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment