I have an automation that notifies me with a script when a sensor is triggered (door opened), then makes a siren (Aeotec Siren 6) play it’s tones, and then runs the sonos_says script to make an announcement. Once the door closes, it runs another simple automation to stop the siren. All three below.
When the door is opened, it sends the notification and plays the tone, but it plays nothing through my sonos office speaker.
You will notice a delay at the end. Seems the Aeotec goes to sleep and won’t accept commands for 30 seconds after triggering, it was causing issues if it was opened and closed again during this period, so I put in a delay.
AUTOMATION TO START PROCESS
alias: Alarm and Siren On HF CF Front Door Open
description: Alarm and Siren HF CF Front Door Open by calling script
trigger:
- platform: state
entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_3
from: "off"
to: "on"
condition: []
action:
- service: script.turn_on
target:
entity_id:
- script.script_to_notify_front_door_open_cf
- script.script_to_notify_front_door_open_hf
data: {}
- service: siren.turn_on
data:
tone: "30"
volume_level: 0.7
target:
entity_id: siren.indoor_siren_6_3
- service: script.turn_on
target:
entity_id: script.sonos_says
data:
variables:
player: media_player.office
message_to_say: The Front Door is Open
volumelevel: 0.9
- delay:
hours: 0
minutes: 0
seconds: 45
mode: single
SERVICE CALLED FROM THE AUTOMATION
alias: Sonos_says
sequence:
- service: sonos.snapshot
data_template:
entity_id: "{{ player }}"
- service: media_player.media_stop
data_template:
entity_id: "{{ player }}"
- delay:
seconds: 1
- service: media_player.volume_set
data_template:
entity_id: "{{ player }}"
data:
volume_level: "{{ volumelevel }}"
- service: tts.google_say
data_template:
entity_id: "{{ player }}"
message: "{{ message_to_say }}"
- delay:
seconds: 1
- delay: >-
{% set duration = state_attr(player, 'media_duration') %} {% if duration >
0 %}
{% set duration = duration - 1 %}
{% endif %} {% set seconds = duration % 60 %} {% set minutes = (duration /
60)|int % 60 %} {% set hours = (duration / 3600)|int %} {{ [hours,
minutes, seconds]|join(':') }}
- delay:
milliseconds: 500
- service: sonos.restore
data_template:
entity_id: "{{ player }}"
mode: single
AUTOMATION ONCE DOOR IS CLOSED TO TURN OFF SIREN
alias: Alarm and Chime Off HF CF Front Door closed
description: Alarm and Chime Off HF CF Front Door closed
trigger:
- platform: state
entity_id:
- binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_3
from: "on"
to: "off"
condition: []
action:
- service: siren.turn_off
data: {}
target:
entity_id:
- siren.indoor_siren_6_3
- service: siren.turn_off
data: {}
target:
device_id: ef9fd809872118c7964c45e54bdb7479
entity_id: siren.indoor_siren_6_3
mode: single