First thing is first, I made a guide on a given driveway sensor that is solar and works a half mile or so away. Guide - How to hook up eMacros driveway sensors to Home Assistant
But for the rest of this, it should work with whatever system you have.
The image above is a simple dashboard. Basically it list all the google speakers (and this means it likely will work with amazon and others too). And it allows a custom setting for each. This includes which sensors trigger in which room, volume per (I have it where at least with google speakers it will save the current sound, make it whatever listed here and then back to what it was after the message it played. And there is a global cool down. This prevents alarms from spamming you which was a MAJOR issue with the native emacros system.
I didn’t add in the code I will share on notifying you outside (sms, push, etc) but keep that in mind. Plus you can expand it to outside lights where they trigger things like that. But I wouldn’t recommend adding that to the dashboard since it will clutter it.
Note:
- You will see unknown with the time under the sensor if they haven’t trigger that day. You can still click on the sensor on the dashboard to see when it actually triggered. But if it triggered that day then it should show it.
- If you do this, you will need a mertic ton of helpers. I highly recommend having AI (gemini, chatgpt, etc) just make you the helpers and you can paste into the config file so it will save you time. Otherwise you will have to manually create each one.
There is in this code for
- The dashboard
- Driveway announcer (the core of it how it announces)
- Switch sync (this makes sure everything syncs)
- button so like if you have a speaker in your office and have a meeting you can get it to not do it. It saves, turns off for that room, then when you release it it restores. I think I also have a reset in it at midnight on the off chance the person forgets to reset it.
Note all the code is anonymize.
The dashboard
title: Driveway Controls
type: sections
views:
- title: Notifications
path: notifications
sections:
- type: grid
cards:
- type: entities
entities:
- entity: input_boolean.driveway_system_master
name: SYSTEM MASTER (All Zones)
icon: mdi:power
- entity: input_text.driveway_global_cooldown
name: Global Cooldown (Seconds)
- type: entities
title: Office
show_header_toggle: false
entities:
- entity: input_boolean.notify_office
name: Master Switch
- entity: input_text.office_alert_volume
name: Alert Volume (1-100)
- entity: input_button.test_office_alarm
name: Test Speaker Volume
- type: section
- entity: input_boolean.notify_office_front_door
name: Front Door
- entity: binary_sensor.front_door
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_office_driveway
name: Driveway
- entity: binary_sensor.driveway_alarm
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_office_east_side
name: East Side
- entity: binary_sensor.east_side_yard
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_office_west_side
name: West Side
- entity: binary_sensor.side_yard_next_to_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_office_zone_c
name: Neighbor
- entity: binary_sensor.neighbor_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_office_zone_d
name: Back Lot
- entity: binary_sensor.back_lot
name: Triggered
secondary_info: last-updated
- type: entities
title: Kitchen
show_header_toggle: false
entities:
- entity: input_boolean.notify_kitchen
name: Master Switch
- entity: input_text.kitchen_alert_volume
name: Alert Volume (1-100)
- entity: input_button.test_kitchen_alarm
name: Test Speaker Volume
- type: section
- entity: input_boolean.notify_kitchen_front_door
name: Front Door
- entity: binary_sensor.front_door
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_kitchen_driveway
name: Driveway
- entity: binary_sensor.driveway_alarm
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_kitchen_east_side
name: East Side
- entity: binary_sensor.east_side_yard
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_kitchen_west_side
name: West Side
- entity: binary_sensor.side_yard_next_to_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_kitchen_zone_c
name: Neighbor
- entity: binary_sensor.neighbor_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_kitchen_zone_d
name: Back Lot
- entity: binary_sensor.back_lot
name: Triggered
secondary_info: last-updated
- type: grid
cards:
- type: heading
heading: Room Controls
- type: entities
title: Living Room
show_header_toggle: false
entities:
- entity: input_boolean.notify_living_room
name: Master Switch
- entity: input_text.living_room_alert_volume
name: Alert Volume (1-100)
- entity: input_button.test_living_room_alert
name: Test Speaker Volume
- type: section
- entity: input_boolean.notify_living_room_front_door
name: Front Door
- entity: binary_sensor.front_door
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_living_room_driveway
name: Driveway
- entity: binary_sensor.driveway_alarm
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_living_room_east_side
name: East Side
- entity: binary_sensor.east_side_yard
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_living_room_west_side
name: West Side
- entity: binary_sensor.side_yard_next_to_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_living_room_zone_c
name: Neighbor
- entity: binary_sensor.neighbor_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_living_room_zone_d
name: Back Lot
- entity: binary_sensor.back_lot
name: Triggered
secondary_info: last-updated
- type: entities
title: Bedroom 1
show_header_toggle: false
entities:
- entity: input_boolean.notify_bedroom_1
name: Master Switch
- entity: input_text.bedroom_1_alert_volume
name: Alert Volume (1-100)
- entity: input_button.test_bedroom_1_alert
name: Test Speaker Volume
- type: section
- entity: input_boolean.notify_bedroom_1_front_door
name: Front Door
- entity: binary_sensor.front_door
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_1_driveway
name: Driveway
- entity: binary_sensor.driveway_alarm
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_1_east_side
name: East Side
- entity: binary_sensor.east_side_yard
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_1_west_side
name: West Side
- entity: binary_sensor.side_yard_next_to_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_1_zone_c
name: Neighbor
- entity: binary_sensor.neighbor_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_1_zone_d
name: Back Lot
- entity: binary_sensor.back_lot
name: Triggered
secondary_info: last-updated
- type: grid
cards:
- type: heading
heading: Primary Suite
- type: entities
title: Primary Bedroom
show_header_toggle: false
entities:
- entity: input_boolean.notify_primary_bedroom
name: Master Switch
- entity: input_text.primary_bedroom_alert_volume
name: Alert Volume (1-100)
- entity: input_button.test_primary_bedroom_alarm
name: Test Speaker Volume
- type: section
- entity: input_boolean.notify_primary_bedroom_front_door
name: Front Door
- entity: binary_sensor.front_door
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_primary_bedroom_driveway
name: Driveway
- entity: binary_sensor.driveway_alarm
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_primary_bedroom_east_side
name: East Side
- entity: binary_sensor.east_side_yard
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_primary_bedroom_west_side
name: West Side
- entity: binary_sensor.side_yard_next_to_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_primary_bedroom_zone_c
name: Neighbor
- entity: binary_sensor.neighbor_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_primary_bedroom_zone_d
name: Back Lot
- entity: binary_sensor.back_lot
name: Triggered
secondary_info: last-updated
- type: entities
title: Bedroom 2
show_header_toggle: false
entities:
- entity: input_boolean.notify_bedroom_2
name: Master Switch
- entity: input_text.bedroom_2_alert_volume
name: Alert Volume (1-100)
- entity: input_button.test_bedroom_2_alarm
name: Test Speaker Volume
- type: section
- entity: input_boolean.notify_bedroom_2_front_door
name: Front Door
- entity: binary_sensor.front_door
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_2_driveway
name: Driveway
- entity: binary_sensor.driveway_alarm
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_2_east_side
name: East Side
- entity: binary_sensor.east_side_yard
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_2_west_side
name: West Side
- entity: binary_sensor.side_yard_next_to_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_2_zone_c
name: Neighbor
- entity: binary_sensor.neighbor_driveway
name: Triggered
secondary_info: last-updated
- entity: input_boolean.notify_bedroom_2_zone_d
name: Back Lot
- entity: binary_sensor.back_lot
name: Triggered
secondary_info: last-updated
The Driveway announcer
alias: Driveway Announcer (Multi-Zone)
description: >-
Plays sync-ish alerts at clamped volumes (0-100) from dashboard text inputs.
Includes idiot-proofing and uses specific test button IDs.
triggers:
- trigger: state
entity_id:
- binary_sensor.front_door
- binary_sensor.front_porch_camera_motion
- binary_sensor.driveway_alarm
- binary_sensor.east_side_yard
- binary_sensor.side_yard_next_to_driveway
- binary_sensor.neighbor_driveway
- binary_sensor.back_lot
to:
- "on"
id: sensor_trigger
- trigger: state
entity_id:
- input_button.test_office_alarm
- input_button.test_kitchen_alarm
- input_button.test_living_room_alert
- input_button.test_primary_bedroom_alarm
- input_button.test_bedroom_1_alert
- input_button.test_bedroom_2_alarm
id: test_trigger
actions:
- variables:
mp3_map:
front_door: media-source://media_source/mp3/Front_door_Alarm.mp3
driveway: media-source://media_source/mp3/Driveway.mp3
east_side: media-source://media_source/mp3/East_yard.mp3
west_side: media-source://media_source/mp3/West_side.mp3
zone_c: media-source://media_source/mp3/Neighbor_driveway.mp3
zone_d: media-source://media_source/mp3/Back_lot.mp3
is_test: "{{ trigger.id == 'test_trigger' }}"
mp3_file: |
{% if is_test %}
{{ mp3_map.values() | list | random }}
{% else %}
{% set sensor_to_id = {
'binary_sensor.front_door': 'front_door',
'binary_sensor.front_porch_camera_motion': 'front_door',
'binary_sensor.driveway_alarm': 'driveway',
'binary_sensor.east_side_yard': 'east_side',
'binary_sensor.side_yard_next_to_driveway': 'west_side',
'binary_sensor.neighbor_driveway': 'zone_c',
'binary_sensor.back_lot': 'zone_d'
} %}
{{ mp3_map[sensor_to_id[trigger.entity_id]] }}
{% endif %}
trigger_id_map:
binary_sensor.front_door: front_door
binary_sensor.front_porch_camera_motion: front_door
binary_sensor.driveway_alarm: driveway
binary_sensor.east_side_yard: east_side
binary_sensor.side_yard_next_to_driveway: west_side
binary_sensor.neighbor_driveway: zone_c
binary_sensor.back_lot: zone_d
t_id: "{{ trigger_id_map[trigger.entity_id] if not is_test else '' }}"
- if:
- condition: template
value_template: >-
{{ not is_test and is_state('timer.driveway_global_cooldown',
'active') }}
then:
- stop: System is on global cooldown.
- if:
- condition: template
value_template: "{{ not is_test }}"
then:
- action: timer.start
target:
entity_id: timer.driveway_global_cooldown
data:
duration: "{{ states('input_text.driveway_global_cooldown') | int(30) }}"
- parallel:
- action: input_number.set_value
target:
entity_id: input_number.office_volume
data:
value: >-
{{ state_attr('media_player.office_speaker', 'volume_level') |
float(0.5) }}
- action: input_number.set_value
target:
entity_id: input_number.living_room_volume
data:
value: >-
{{ state_attr('media_player.living_room_speaker', 'volume_level') |
float(0.5) }}
- action: input_number.set_value
target:
entity_id: input_number.kitchen_display_volume
data:
value: >-
{{ state_attr('media_player.kitchen_display', 'volume_level') |
float(0.5) }}
- action: input_number.set_value
target:
entity_id: input_number.primary_bedroom_volume
data:
value: >-
{{ state_attr('media_player.primary_bedroom_speaker', 'volume_level')
| float(0.5) }}
- action: input_number.set_value
target:
entity_id: input_number.bedroom_1_volume
data:
value: >-
{{ state_attr('media_player.bedroom_1_speaker', 'volume_level') |
float(0.5) }}
- action: input_number.set_value
target:
entity_id: input_number.bedroom_2_volume
data:
value: >-
{{ state_attr('media_player.bedroom_2_speaker', 'volume_level') |
float(0.5) }}
- parallel:
- if:
- condition: template
value_template: |
{{ (trigger.entity_id == 'input_button.test_office_alarm') or
(not is_test and is_state('input_boolean.notify_office', 'on') and is_state('input_boolean.notify_office_' ~ t_id, 'on')) }}
then:
- action: media_player.volume_set
target:
entity_id: media_player.office_speaker
data:
volume_level: >
{% set val = states('input_text.office_alert_volume') |
float(80) %} {{ ([0, val, 100] | sort)[1] / 100 }}
- action: media_player.play_media
target:
entity_id: media_player.office_speaker
data:
announce: true
media:
media_content_id: "{{ mp3_file }}"
media_content_type: audio/mpeg
metadata: {}
- if:
- condition: template
value_template: |
{{ (trigger.entity_id == 'input_button.test_kitchen_alarm') or
(not is_test and is_state('input_boolean.notify_kitchen', 'on') and is_state('input_boolean.notify_kitchen_' ~ t_id, 'on')) }}
then:
- action: media_player.volume_set
target:
entity_id: media_player.kitchen_display
data:
volume_level: >
{% set val = states('input_text.kitchen_alert_volume') |
float(80) %} {{ ([0, val, 100] | sort)[1] / 100 }}
- action: media_player.play_media
target:
entity_id: media_player.kitchen_display
data:
announce: true
media:
media_content_id: "{{ mp3_file }}"
media_content_type: audio/mpeg
metadata: {}
- if:
- condition: template
value_template: |
{{ (trigger.entity_id == 'input_button.test_bedroom_1_alert') or
(not is_test and is_state('input_boolean.notify_bedroom_1', 'on') and is_state('input_boolean.notify_bedroom_1_' ~ t_id, 'on')) }}
then:
- action: media_player.volume_set
target:
entity_id: media_player.bedroom_1_speaker
data:
volume_level: >
{% set val = states('input_text.bedroom_1_alert_volume') |
float(80) %} {{ ([0, val, 100] | sort)[1] / 100 }}
- action: media_player.play_media
target:
entity_id: media_player.bedroom_1_speaker
data:
announce: true
media:
media_content_id: "{{ mp3_file }}"
media_content_type: audio/mpeg
metadata: {}
- if:
- condition: template
value_template: >
{{ (trigger.entity_id == 'input_button.test_living_room_alert')
or
(not is_test and is_state('input_boolean.notify_living_room', 'on') and is_state('input_boolean.notify_living_room_' ~ t_id, 'on')) }}
then:
- action: media_player.volume_set
target:
entity_id: media_player.living_room_speaker
data:
volume_level: >
{% set val = states('input_text.living_room_alert_volume') |
float(80) %} {{ ([0, val, 100] | sort)[1] / 100 }}
- action: media_player.play_media
target:
entity_id: media_player.living_room_speaker
data:
announce: true
media:
media_content_id: "{{ mp3_file }}"
media_content_type: audio/mpeg
metadata: {}
- if:
- condition: template
value_template: >
{{ (trigger.entity_id == 'input_button.test_primary_bedroom_alarm')
or
(not is_test and is_state('input_boolean.notify_primary_bedroom', 'on') and is_state('input_boolean.notify_primary_bedroom_' ~ t_id, 'on')) }}
then:
- action: media_player.volume_set
target:
entity_id: media_player.primary_bedroom_speaker
data:
volume_level: >
{% set val = states('input_text.primary_bedroom_alert_volume') |
float(80) %} {{ ([0, val, 100] | sort)[1] / 100 }}
- action: media_player.play_media
target:
entity_id: media_player.primary_bedroom_speaker
data:
announce: true
media:
media_content_id: "{{ mp3_file }}"
media_content_type: audio/mpeg
metadata: {}
- if:
- condition: template
value_template: |
{{ (trigger.entity_id == 'input_button.test_bedroom_2_alarm') or
(not is_test and is_state('input_boolean.notify_bedroom_2', 'on') and is_state('input_boolean.notify_bedroom_2_' ~ t_id, 'on')) }}
then:
- action: media_player.volume_set
target:
entity_id: media_player.bedroom_2_speaker
data:
volume_level: >
{% set val = states('input_text.bedroom_2_alert_volume') | float(80)
%} {{ ([0, val, 100] | sort)[1] / 100 }}
- action: media_player.play_media
target:
entity_id: media_player.bedroom_2_speaker
data:
announce: true
media:
media_content_id: "{{ mp3_file }}"
media_content_type: audio/mpeg
metadata: {}
- delay: "00:00:10"
- parallel:
- action: media_player.volume_set
target:
entity_id: media_player.office_speaker
data:
volume_level: "{{ states('input_number.office_volume') | float(0.5) }}"
- action: media_player.volume_set
target:
entity_id: media_player.living_room_speaker
data:
volume_level: "{{ states('input_number.living_room_volume') | float(0.5) }}"
- action: media_player.volume_set
target:
entity_id: media_player.kitchen_display
data:
volume_level: "{{ states('input_number.kitchen_display_volume') | float(0.5) }}"
- action: media_player.volume_set
target:
entity_id: media_player.primary_bedroom_speaker
data:
volume_level: "{{ states('input_number.primary_bedroom_volume') | float(0.5) }}"
- action: media_player.volume_set
target:
entity_id: media_player.bedroom_1_speaker
data:
volume_level: "{{ states('input_number.bedroom_1_volume') | float(0.5) }}"
- action: media_player.volume_set
target:
entity_id: media_player.bedroom_2_speaker
data:
volume_level: "{{ states('input_number.bedroom_2_volume') | float(0.5) }}"
mode: queued
max: 10
Smart switch
alias: Driveway Smart Switch Sync
description: Cascades master switches to sub-switches and updates master status.
triggers:
- trigger: state
entity_id: input_boolean.driveway_system_master
id: system_master
- trigger: state
entity_id:
- input_boolean.notify_office
- input_boolean.notify_living_room
- input_boolean.notify_kitchen
- input_boolean.notify_primary_bedroom
- input_boolean.notify_bedroom_1
- input_boolean.notify_bedroom_2
id: room_master
actions:
- choose:
- conditions:
- condition: trigger
id: system_master
sequence:
- action: >-
input_boolean.turn_{{
states('input_boolean.driveway_system_master') }}
target:
entity_id:
- input_boolean.notify_office
- input_boolean.notify_living_room
- input_boolean.notify_kitchen
- input_boolean.notify_primary_bedroom
- input_boolean.notify_bedroom_1
- input_boolean.notify_bedroom_2
- conditions:
- condition: trigger
id: room_master
sequence:
- variables:
new_state: "{{ states(trigger.entity_id) }}"
- action: input_boolean.turn_{{ new_state }}
target:
entity_id: >
{{ trigger.entity_id }}_front_door, {{ trigger.entity_id
}}_driveway, {{ trigger.entity_id }}_east_side, {{
trigger.entity_id }}_west_side, {{ trigger.entity_id }}_zone_c,
{{ trigger.entity_id }}_zone_d
mode: parallel
Smart button
alias: Office Smart Button (Memory)
description: >-
Saves/Restores sub-switch states and verbally notifies office speaker at
current volume. Includes manual override.
triggers:
- trigger: state
entity_id: input_boolean.office_button
to: "off"
id: turned_off
- trigger: state
entity_id: input_boolean.office_button
to: "on"
id: turned_on
- trigger: device
domain: zha
device_id: your_zigbee_button_device_id
type: remote_button_long_press
subtype: remote_button_long_press
id: yellow_button
- trigger: state
entity_id:
- input_boolean.notify_office_front_door
- input_boolean.notify_office_driveway
- input_boolean.notify_office_east_side
- input_boolean.notify_office_west_side
- input_boolean.notify_office_zone_c
- input_boolean.notify_office_zone_d
to: "on"
id: manual_override
- trigger: time
at: "00:00:00"
id: Time
actions:
- choose:
- conditions:
- condition: trigger
id: yellow_button
sequence:
- action: input_boolean.toggle
target:
entity_id: input_boolean.office_button
- conditions:
- condition: trigger
id: turned_on
sequence:
- if:
- condition: template
value_template: >
{{ expand('input_boolean.notify_office_front_door',
'input_boolean.notify_office_driveway',
'input_boolean.notify_office_east_side',
'input_boolean.notify_office_west_side',
'input_boolean.notify_office_zone_c',
'input_boolean.notify_office_zone_d')
| selectattr('state', 'eq', 'on') | list | count == 0 }}
then:
- action: scene.turn_on
target:
entity_id: scene.office_saved_state
- choose:
- conditions:
- condition: not
conditions:
- condition: time
after: "06:00:00"
before: "21:00:00"
sequence:
- action: tts.speak
data:
cache: true
media_player_entity_id: media_player.office_speaker
message: Office alerts on
target:
device_id: your_media_player_device_id
- conditions:
- condition: not
conditions:
- condition: time
after: "06:00:00"
before: "21:00:00"
sequence:
- action: tts.speak
data:
cache: true
media_player_entity_id: media_player.office_speaker
message: Office alerts on
target:
device_id: your_media_player_device_id
- conditions:
- condition: trigger
id: turned_off
sequence:
- choose:
- conditions:
- condition: not
conditions:
- condition: time
after: "06:00:00"
before: "21:00:00"
sequence:
- action: tts.speak
target:
device_id: your_media_player_device_id
data:
cache: true
media_player_entity_id: media_player.office_speaker
message: Office alerts off
- action: scene.create
data:
scene_id: office_saved_state
snapshot_entities:
- input_boolean.notify_office_front_door
- input_boolean.notify_office_driveway
- input_boolean.notify_office_east_side
- input_boolean.notify_office_west_side
- input_boolean.notify_office_zone_c
- input_boolean.notify_office_zone_d
- action: input_boolean.turn_off
target:
entity_id:
- input_boolean.notify_office_front_door
- input_boolean.notify_office_driveway
- input_boolean.notify_office_east_side
- input_boolean.notify_office_west_side
- input_boolean.notify_office_zone_c
- input_boolean.notify_office_zone_d
- conditions:
- condition: trigger
id: manual_override
- condition: state
entity_id: input_boolean.office_button
state: "off"
sequence:
- action: input_boolean.turn_on
target:
entity_id: input_boolean.office_button
- conditions:
- condition: trigger
id:
- Time
sequence:
- action: input_boolean.turn_on
target:
entity_id: input_boolean.office_button
mode: restart
