I have an automation that plays an audio file of a barking dog when Frigate detects someone on my back deck. I’d like to extend this automation so that it also turns on the bedroom light three seconds after the audio file plays. The automation needs to be written so that it can play over and over in case the person stays on the back deck, but the light only turns on once.
Here is the code that I want to revise:
description: ""
mode: single
trigger:
- platform: mqtt
topic: frigate/events
condition:
- condition: and
conditions:
- condition: template
value_template: "{{ trigger.payload_json['after']['label'] == 'person' }}"
- condition: template
value_template: "{{ 'rear_deck' in trigger.payload_json['after']['entered_zones'] }}"
- condition: template
value_template: "{{ 'rear_deck' in trigger.payload_json['after']['current_zones'] }}"
- condition: state
entity_id: input_boolean.switch_arm_security_system
state: "on"
- condition: state
entity_id: input_boolean.switch_sonos_plays_dog_barking
state: "on"
action:
- service: media_player.volume_set
data:
volume_level: 1
target:
entity_id: media_player.master_bedroom
- service: media_player.play_media
data:
media_content_type: music
media_content_id: /media/local/guard_dog_barking.mp3
enqueue: false
target:
entity_id: media_player.master_bedroom
- delay:
hours: 0
minutes: 1
seconds: 8
milliseconds: 0
- service: media_player.clear_playlist
entity_id: media_player.master_bedroom
max_exceeded: silent
Any advice would be greatly appreciated.