Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 96121

A little help with automation of a script

$
0
0

@skutter wrote:

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

Posts: 7

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 96121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>