A little help with automation of a script

Here is what I am trying to do.
When a door is opened a verbal warning is given and alerts are sent to their respective destinations.
That bit is fine and set in a separate automation as below;

- id: '1541766423802'
  alias: Study door alarm
  trigger:
  - platform: state
    entity_id: binary_sensor.study_single_door
    to: 'on'
  action:
  - service: notify.pushbullet
    data:
      title: Alert
      message: Someone has entered your study
  - service: notify.mycroft
    data:
      message: You are not john so you had best get out you have 10 seconds to comply.
  - service: mqtt.publish
    data:
      topic: 'homeassistant/tts/android_johns_phone_tts/tts'
      payload: 'Someone has opened your study door'
  - service: mqtt.publish
    data:
      topic: 'homeassistant/tts/android_nexus_9_tts/tts'
      payload: 'Someone has opened your study door'

I’ve set a timer

timer:
  siren:
    duration: '00:03:00'

What I am trying to do is after that occurs and if my siren automation is turned on, get an 11 second delay before the siren (120DB) fires in that room. The siren works fine by the switch. (currently it is a sonoffS20 with a fan attached. No point in being deaf as well a daft).

So I have a second automation that is;

- id: '1551277334508'
  alias: set siren
  initial_state: 'off'
  trigger:
  - platform: state
    entity_id: binary_sensor.study_single_door
    to: 'on'
  condition: []
  action:
  - service: script.start_siren
    entity_id: start.siren
  - service: notify.pushbullet
    data:
      title: Alert
      message: The alarm is sounding
  - service: mqtt.publish
    data:
      topic: 'homeassistant/tts/android_johns_phone_tts/tts'
      payload: 'The alarm is sounding'
  - service: mqtt.publish
    data:
      topic: 'homeassistant/tts/android_nexus_9_tts/tts'
      payload: 'The alarm is sounding'
  hide_entity: false

My script is;

start_siren:
  alias: Start siren
  sequence:
  - delay: 00:00:11
  - service: timer.start
    entity_id: timer.siren
  - service: switch.turn_on
    entity_id: switch.coffee_machine_2
pause_siren:
  alias: Pause siren
  sequence:
  - service: timer.pause
    entity_id: timer.siren
cancel_siren:
  alias: Cancel siren
  sequence:
  - service: timer.cancel
    entity_id: timer.siren
  - service: switch.turn_off
    entity_id:
    - switch.coffee_machine_2
finish_siren:
  alias: Finish siren
  sequence:
  - service: timer.finish
    entity_id: timer.siren
  - service: switch.turn_off
    entity_id:
    - switch.coffee_machine_2

But the script doesn’t fire even if I call it from the developer tools service tab?

The end result of what I am trying to achieve it to issue the 10 second warning and then if the door is not closed within that fire the siren for three minutes until it is.

There may be an addition to rinse and repeat if a motion sensor is triggered. Just in case they shut the door without leaving ( the sensor is done and trivial TBH).

If there is a better way of doing it I am all for the learning. I went the scripting route as I want to reuse it for several other doors. And an outside siren.

I did a similar one for the mancave where if I was away and the door was opened, the camera went into record and one second later 120DB fired in a ten foot by ten foot space.
Some of the footage was epic!

I don’t live in a bad neighborhood. I just have some extended family that are lets say, light fingered.

So if a good soul would help me understand first where I’ve messed up; and then and if, there is a better way of achieving the results that I am looking for then I am all ears. Pointers, examples, links to docs I missed all are welcome. I’d rather learn by example than expect another to do it for me!
John

Couple things:

What you have in your script code block is four scripts, not one. script.start_siren, script.pause_siren, etc.

Also this:

  - service: script.start_siren
    entity_id: start.siren

is not a valid service call. Should just be

  - service: script.start_siren

or

  - service: script.turn_on
    entity_id: script.start_siren

Thanks,

I’ve made the adjustment to the automation as suggested;

 - service: script.start_siren

Instead of:

  - service: script.start_siren
    entity_id: start.siren

While the automation fires the script still does not.

So the delay does not occur and my notifications from my second automation override the first. there is no 11 second delay and the siren does not trigger. So it also does not run for 3 minutes.

The bit that seems to be failing is script.start_siren because it doesn’t. Nor does it delay for 11 seconds before running.

Based on what I see, there is maybe an indentation issue, here is what I think should be correct for the first script …

start_siren:
  alias: Start siren
  sequence:
    - delay: 00:00:11
    - service: timer.start
      entity_id: timer.siren
    - service: switch.turn_on
      entity_id: switch.coffee_machine_2

Granted that it was different. I have changed it but the results are the same.
The delay does not activate,
and the switch doe snot turn on.

mentioned before on the issues I believe, I read that since one of the most recent updates scripts wont run beginning with a delay? please take out the delay for testing purposes and see if the timer starts?

secondly, and this is supposed to be impossible, and undocumented, but Ive experienced (in the past, and a few fellow members here) that delay can cause issues every once in a while used with this notation. I therefore have ever since used the following:

- delay:
    seconds: 11

and never have had another issue .

might not be true, but couldn’t harm to try could it?
let us know your findings.

Yup I’ve taken out the delay as a matter of my own troubleshooting prior to posting here.
The start script still does not run. Even called from Developer tools/services.

In short I could simply add;

- id: '154176642334509'
  alias: Back door alarm
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: binary_sensor.back_door
    to: 'on'
  action:
  - service: notify.pushbullet
    data:
      title: Alarm
      message: Someone has opened the back door
  - service: notify.mycroft
    data:
      message: Someone has opened the back door
  - service: mqtt.publish
    data:
      topic: 'homeassistant/tts/android_johns_phone_tts/tts'
      payload: 'Someone has opened the back door'
  - service: mqtt.publish
    data:
      topic: 'homeassistant/tts/android_nexus_9_tts/tts'
      payload: 'Someone has opened the back door

It works well but has to be written individually for each automation. I’m looking to make a script that I can reuse to cover several doors or widows. While providing the same results. Noise and notification to various devices.

something like,

If this happens:
A secure area is entered by opening a door or window.
A warning is provided with a time limit, and unless you rectify it within the time limit (IE shut the door) call this script that screams like a banshee, after three minutes reset. Unless motion is detected. then scream some more.

As yet I’m stumped at the first hurdle!

And it was a schoolboy error!

All working with the delay in the script. I had selected the wrong entity_id.
I do have a lot of coffee now though.

a yes, we’ve all seen that before… the devil is in the details :wink:
cool you got it working now.