Guest User

Untitled

a guest
Nov 14th, 2020
203
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Notify for ALL doors we care about.
  2. - alias: "Door announce"
  3.   # Allow each door to run their own instance of this.
  4.   mode: parallel
  5.   max: 5
  6.   # Define the variables here. For each door (binary sensor), define the
  7.   # message, tts targets and alexa targets.
  8.   # Makes it super easy to add more doors
  9.   variables:
  10.    # How often to repeat the messages
  11.     message_repeat_time: "00:00:06"
  12.     # Each door can have its own properties. Store them here.
  13.     doors:
  14.       top_stairs_open_closed:
  15.         message: "Basement Door Open"
  16.         tts_targets: media_player.kitchen_display, media_player.basement_speaker
  17.         alexa_targets: martin_s_echo_dot
  18.         open_time: "00:00:05"
  19.       main_entry:
  20.         message: "Main Entry Open"
  21.         tts_targets: media_player.kitched_display
  22.         alexa_targets: martin_s_echo_dot
  23.         open_time: "00:00:30"
  24.   trigger:
  25.  # Sadly, until 0.118, we can't have state triggers with templates. So will
  26.   # have to duplicate them here...for now.
  27.   - platform: state
  28.     entity_id:
  29.       - binary_sensor.top_stairs_open_closed
  30.       - binary_sensor.main_entry
  31.     from: 'off'
  32.     to: 'on'
  33.     # Look up the open time based on the sensor
  34.     for: "{{ doors[states.object_id].open_time }}"
  35.   condition:
  36.    # Can also set separate condition times for each door in the variables if interested
  37.     - condition: time
  38.       after: 07:00:00
  39.       before: '19:00:00'
  40.   action:
  41.    # Main loop. Repeat until the door is closed.
  42.     # Use a repeat/until so it always runs at least once.
  43.     - repeat:
  44.         sequence:
  45.           - service: tts.google_translate_say
  46.             data:
  47.               entity_id: "{{ doors[trigger.to_state.object_id].tts_targets }}"
  48.               message: "{{ doors[trigger.to_state.object_id].message }}"
  49.           - service: notify.alexa_media
  50.             data:
  51.               target: " {{ doors[trigger.to_state.object_id].alexa_targets }}"
  52.               message: "{{ doors[trigger.to_state.object_id].message }}"
  53.               data:
  54.                 type: announce
  55.           - delay: "{{message_repeat_time}}"
  56.         until:
  57.          # Entity id cant be a template, so use template condition
  58.           - condition: template
  59.             # Will run until this door is closed.
  60.             value_template: "{{ is_state(trigger.to_state.entity_id, 'off') "
RAW Paste Data