###############################################################################
#   @author         :   Jeffrey Stone 
#   @date           :   03/13/2019
#   @package        :   Security
#   @description    :   Everything related to Disney in Anchorage House. 
###############################################################################

input_boolean:
  happy_ever_after_show:
    name: Happy Ever After Show
  boo_to_you_show:
    name: Boo To You 
  holiday_wishes:
    name: Holiday Wishes 
  spaceship_earth_ride:
    name: Spaceship Earth 
  boo_to_you:
    name: Boo To You 
  happy_ever_after:
    name: Happy Ever After
  mk_loop:
    name: MK Loop
  tiki_room_audio:
    name: Tiki Room
  illuminations:
    name: Illuminations
  move_shake_dance:
    name: Move It Shake It Dance It
  welcome_show:
    name: Welcome Show
  american_adventure:
    name: American Adventure
  disney_springs_xmas:
    name: Disney Springs XMas
  sleepy_hollow_audiobook:
    name: Sleepy Hollow ReadAlong
  pandora_area_loop:
    name: Pandora Area Loop
  resort_room_audio:
    name: WDW Resort Room Audio
  wishes_audio:
    name: Wishes
  mk_mainstreet_audio:
    name: MK Mainstreet Audio
  mk_fof_audio:
    name: MK Festival of Fantasy Audio
  mk_trolly_audio:
    name: MK Trolly Audio
  mk_tomorrowland_loop:
    name: MK Tomorrowland Loop
  mk_adventureland_loop:
    name: MK Adventureland Loop
  mk_frontierland_loop:
    name: MK Frontierland Loop
  mk_fantasyland_loop:
    name: MK Fantasyland Loop
  epcot_entrance_loop:
    name: Epcot Entrance Loop
  pixar_pier_loop:
    name: Pixar Pier Loop
  disney_random_area_loop:
    name: Disney Random Area Loop
  disneyland_christmas_loop:
    name: Disneyland Christmas Loop
  mainstreet_usa_christmas_loop:
    name: Mainstreet Christmas Loop
  disney_park_christmas_loop:
    name: Disney Park Christmas Loop
  christmas_around_disneyland:
    name: Christmas Around Disneyland
  worldshowcase_loop:
    name: World Showcase Loop
  toystoryland_loop:
    name: Toy Story Land
  aroundwdw:
    name: Around WDW
  arounddisneyland:
    name: Around Disneyland
  aroundmk:
    name: Around Magic Kingdom
  hauntedmansionloop:
    name: Haunted Mansion Loop
  christmas_background:
    name: Christmas Background

group:
  Disney Audio:
    entities:
      - input_boolean.happy_ever_after_show
      - input_boolean.haunted_mansion
      - input_boolean.boo_to_you_show
      - input_boolean.holiday_wishes
      - input_boolean.spaceship_earth_ride
      - input_boolean.boo_to_you
      - input_boolean.happy_ever_after
      - input_boolean.mk_loop
      - input_boolean.tiki_room_audio
      - input_boolean.illuminations
      - input_boolean.move_shake_dance
      - input_boolean.welcome_show
      - input_boolean.american_adventure
      - input_boolean.disney_springs_xmas
      - input_boolean.sleepy_hollow_audiobook
      - input_boolean.this_is_halloween
      - input_boolean.pandora_area_loop
      - input_boolean.resort_room_audio
      - input_boolean.wishes_audio
      - input_boolean.mk_mainstreet_audio
      - input_boolean.mk_fof_audio
      - input_boolean.mk_trolly_audio
      - input_boolean.mk_tomorrowland_loop
      - input_boolean.mk_adventureland_loop
      - input_boolean.mk_frontierland_loop
      - input_boolean.mk_fantasyland_loop
      - input_boolean.epcot_entrance_loop
      - input_boolean.pixar_pier_loop
      - input_boolean.disney_random_area_loop
      - input_boolnea.disneyland_christmas_loop
      - input_boolean.mainstreet_usa_christmas_loop
      - input_boolean.disney_park_christmas_loop
      - input_boolean.christmas_around_disneyland
      - input_boolean.hauntedmansionloop
      - input_boolean.aroundmk
      - input_boolean.arounddisneyland
      - input_boolean.aroundwdw
      - input_boolean.toystoryland_loop
      - input_boolean.worldshowcase_loop
      - input_boolean.christmas_background


automation:

# Turn off input booleans when audio is over:
  - id: e1cb172c-0423-11eb-adc1-0242ac120002
    alias: disney_audio_auto_off
    initial_state: true
    trigger:
    - platform: state
      entity_id: media_player.ha_blue
      to: 'idle'
      from: 'playing'
    - platform: state
      entity_id: media_player.ha_blue
      to: 'idle'
      from: 'paused'
    condition:
    - condition: state
      entity_id: group.disney_audio
      state: 'on'
    action:
    - service: homeassistant.turn_off 
      entity_id: group.disney_audio

# If Main audio is off, turn off input_booleans and notify via notifications. 
  - id: audio_is_disabled
    alias: Audio is Disabled 
    initial_state: true
    trigger:
    - platform: state
      entity_id: group.disney_audio
      to: 'on'
    condition:
      condition: or
      conditions:
      - condition: state 
        entity_id: input_boolean.audible_notifications
        state: 'off'
      - condition: state
        entity_id: group.family
        state: 'not_home'
    action:
    - service: homeassistant.turn_off 
      entity_id: group.disney_audio
    - service: persistent_notification.dismiss
      data:
        notification_id: "audioissue"
    - service: persistent_notification.create
      data_template:
        notification_id: "audioissue"
        message: "Disney audio functions are disabled because the audible notifications are off."
        title: "Audio Not Available"

  - id: e1cb210e-0423-11eb-adc1-0242ac120002
    alias: Around WDW
    trigger: 
    - platform: state
      entity_id: input_boolean.aroundwdw
      to: 'on'
      from: 'off'
      id: start 
    - platform: state
      entity_id: input_boolean.aroundwdw
      id: stop
      from: 'on'
      to: 'off'
    action:
    - choose:
      - conditions:
        - condition: trigger
          id: start
        sequence:
        - service: script.local_audio
          data:
            media: "/media/disney/aroundwdw.mp3"
            volume: .35
            speaker: 'media_player.ha_blue'
      - conditions:
        - condition: trigger
          id: stop
        sequence:
        - service: media_player.media_stop
          entity_id: media_player.ha_blue
        - service: script.turn_off
          entity_id: script.local_audio
      default: []
    initial_state: true
    mode: single

  - id: e1cb2050-0423-11eb-adc1-0242ac120002
    alias: Around Magic Kingdom
    trigger: 
    - platform: state
      entity_id: input_boolean.aroundmk
      to: 'on'
      from: 'off'
      id: start 
    - platform: state
      entity_id: input_boolean.aroundmk
      id: stop
      from: 'on'
      to: 'off'
    action:
    - choose:
      - conditions:
        - condition: trigger
          id: start
        sequence:
        - service: script.local_audio
          data:
            media: "/media/disney/aroundmk.mp3"
            volume: .35
            speaker: 'media_player.ha_blue'
      - conditions:
        - condition: trigger
          id: stop
        sequence:
        - service: media_player.media_stop
          entity_id: media_player.ha_blue
        - service: script.turn_off
          entity_id: script.local_audio
      default: []
    initial_state: true
    mode: single

  - id: e1cb1f7e-0423-11eb-adc1-0242ac120002
    alias: Around Disneyland
    trigger: 
    - platform: state
      entity_id: input_boolean.arounddisneyland
      to: 'on'
      from: 'off'
      id: start 
    - platform: state
      entity_id: input_boolean.arounddisneyland
      id: stop
      from: 'on'
      to: 'off'
    action:
    - choose:
      - conditions:
        - condition: trigger
          id: start
        sequence:
        - service: script.local_audio
          data:
            media: "/media/disney/arounddisneyland.mp3"
            volume: .35
            speaker: 'media_player.ha_blue'
      - conditions:
        - condition: trigger
          id: stop
        sequence:
        - service: media_player.media_stop
          entity_id: media_player.ha_blue
        - service: script.turn_off
          entity_id: script.local_audio
      default: []
    initial_state: true
    mode: single

  - id: e1cb1eb6-0423-11eb-adc1-0242ac120002
    alias: Haunted Mansion Loop
    trigger: 
    - platform: state
      entity_id: input_boolean.hauntedmansionloop
      to: 'on'
      from: 'off'
      id: start 
    - platform: state
      entity_id: input_boolean.hauntedmansionloop
      id: stop
      from: 'on'
      to: 'off'
    action:
    - choose:
      - conditions:
        - condition: trigger
          id: start
        sequence:
        - service: script.local_audio
          data:
            media: "/media/disney/haunted_mansion_loop.mp3"
            volume: .35
            speaker: 'media_player.ha_blue'
      - conditions:
        - condition: trigger
          id: stop
        sequence:
        - service: media_player.media_stop
          entity_id: media_player.ha_blue
        - service: script.turn_off
          entity_id: script.local_audio
      default: []
    initial_state: true
    mode: single

  - id: e1cb1d94-0423-11eb-adc1-0242ac120002
    alias: World Showcase Loop
    trigger: 
    - platform: state
      entity_id: input_boolean.worldshowcase_loop
      to: 'on'
      from: 'off'
      id: start 
    - platform: state
      entity_id: input_boolean.worldshowcase_loop
      id: stop
      from: 'on'
      to: 'off'
    action:
    - choose:
      - conditions:
        - condition: trigger
          id: start
        sequence:
        - service: script.local_audio
          data:
            media: "/media/disney/WorldShowcaseLoop.mp3"
            volume: .35
            speaker: 'media_player.ha_blue'
      - conditions:
        - condition: trigger
          id: stop
        sequence:
        - service: media_player.media_stop
          entity_id: media_player.ha_blue
        - service: script.turn_off
          entity_id: script.local_audio
      default: []
    initial_state: true
    mode: single

  - id: e1cb1cc2-0423-11eb-adc1-0242ac120002
    alias: Toystory Land Loop
    trigger: 
    - platform: state
      entity_id: input_boolean.toystoryland_loop
      to: 'on'
      from: 'off'
      id: start 
    - platform: state
      entity_id: input_boolean.toystoryland_loop
      id: stop
      from: 'on'
      to: 'off'
    action:
    - choose:
      - conditions:
        - condition: trigger
          id: start
        sequence:
        - service: script.local_audio
          data:
            media: "/media/disney/ToyStorylandLoop.mp3"
            volume: .35
            speaker: 'media_player.ha_blue'
      - conditions:
        - condition: trigger
          id: stop
        sequence:
        - service: media_player.media_stop
          entity_id: media_player.ha_blue
        - service: script.turn_off
          entity_id: script.local_audio
      default: []
    initial_state: true
    mode: single

# MK Mainstreet Audio
  - id: mk_loop_on
    alias: MK Loop On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.mk_mainstreet_audio
      to: 'on'
    action:
    - service: script.youtube_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/MK_MainStreet_Loop.mp3
        volume: .35
  - id: mk_loop_off
    alias: MK Loop Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.mk_mainstreet_audio
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

# Frontier Audio
  - id: frontier_loop_on
    alias: Frontier Loop On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.mk_frontierland_loop
      to: 'on'
    action:
    - service: script.youtube_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/frontierland_loop.mp3
        volume: .35
  - id: frontier_loop_off
    alias: Frontier Loop Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.mk_frontierland_loop
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

# Adventure Audio
  - id: adventureland_loop_on
    alias: Adventure Land Loop On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.mk_adventureland_loop
      to: 'on'
    action:
    - service: script.youtube_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/adventureland_loop.mp3
        volume: .35
  - id: adventure_loop_off
    alias: Adventure Loop Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.mk_adventureland_loop
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

# Epcot Entrance Audio
  - id: epcotentrance_loop_on
    alias: Epcot Entrance Loop On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.epcot_entrance_loop
      to: 'on'
    action:
    - service: script.youtube_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/epcot_entrance_loop.mp3
        volume: .35
  - id: epcotentrance_loop_off
    alias: Epcot Entrance Loop Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.epcot_entrance_loop
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio


# Pixar Pier Audio
  - id: pixar_pier_loop_on
    alias: Pixar Pier Loop On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.pixar_pier_loop
      to: 'on'
    action:
    - service: script.youtube_audio
      data_template:
        speaker: media_player.ha_blue
        media: "https://www.youtube.com/watch?v=19-ooWL5R8w"
        volume: .35
  - id: pixar_pier_loop_off
    alias: Pixar Pier Loop Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.pixar_pier_loop
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

# Tiki Room
  - id: tiki_room_on
    alias: Tiki Room On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.tiki_room_audio
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/tiki_room_audio.mp3
        volume: .5
  - id: tiki_room_off
    alias: Tiki Room Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.tiki_room_audio
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

# Illuminations
  - id: illuminations_on
    alias: Illuminations On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.illuminations
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/illuminations.mp3
        volume: .5
  - id: illuminations_off
    alias: Illuminations Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.illuminations
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio
  

# Happily Ever After
  - id: happy_ever_after_show_on
    alias: Happy Ever After Show On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.happy_ever_after_show
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/Happily_Ever_After_Audio.mp3
        volume: .5
  - id: happy_ever_after_show_off
    alias: Happy Ever After Show Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.happy_ever_after_show
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

# Holiday Wishes 
  - id: holiday_wishes_show_on
    alias: Holiday Wishes Show On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.holiday_wishes
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/holidaywishes.mp3
        volume: .5

  - id: holiday_wishes_show_off
    alias: Holiday Wishes Show Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.holiday_wishes
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio
    - service: script.turn_off
      entity_id: script.holiday_wishes
    - service: script.turn_off 
      entity_id: script.wishes_lights_on
    - service: script.turn_off
      entity_id: script.wishes_lights_all
  
# Holiday Wishes Preshow Trigger
  # - id: wishes_preshow_trigger
  #   alias: Wishes Preshow Trigger 
  #   initial_state: true
  #   trigger:
  #   - platform: state
  #     entity_id: input_boolean.holiday_wishes
  #     to: 'on'
  #   action:
  #   - service: script.youtube_audio
  #     data_template:
  #       media: "http://192.168.7.40/audio/holidaywishes.mp3"
  #       volume: .5

# Holiday Wishes Light Show Trigger  
  - id: wishes_show_trigger
    alias: Wishes show Trigger 
    initial_state: true
    trigger:
    - platform: state
      entity_id: media_player.ha_blue
      to: 'playing'
    condition:
    - condition: state 
      entity_id: input_boolean.holiday_wishes
      state: 'on'
    action:
    - service: script.turn_on 
      entity_id: script.wishes_lights_on
    - service: script.turn_on
      entity_id: script.wishes_lights_all

# Spaceship Earth Ride Audio    
  - id: spaceship_earth_on
    alias: Spaceship Earth On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.spaceship_earth_ride
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/spaceship_earth_ride.mp3
        volume: .4
  - id: spaceship_earth_off
    alias: Spaceship Earth Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.spaceship_earth_ride
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.local_audio
  
# Boo to You Parade  
  - id: boo_to_you_show_on
    alias: Boo To You Show On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.boo_to_you_show
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/boo_to_you_audio.mp3
        volume: .5
  - id: boo_to_you_show_off
    alias: Boo To You Show Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.boo_to_you_show
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.local_audio

# Holiday Wishes  
  - id: holiday_wishes_on
    alias: Holiday Wishes On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.holiday_wishes
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/holidaywishes.mp3
        volume: .5

  - id: holiday_wishes_off
    alias: Holiday Wishes Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.holiday_wishes
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.local_audio
  
# Magic Kingdom Welcome Show
  - id: welcome_show_on
    alias: Welcome Show On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.welcome_show
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/ML_Welcome_Show.mp3
        volume: .35
    - delay:
        minutes: 8
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio
    - service: input_boolean.turn_off
      entity_id: input_boolean.welcome_show
  # - id: welcome_show_off
  #   alias: Welcome Show Off
  #   initial_state: true
  #   trigger:
  #   - platform: state
  #     entity_id: input_boolean.welcome_show
  #     to: 'off'
  #   action:
  #   - service: media_player.media_stop
  #     entity_id: media_player.ha_blue
  #   - service: script.turn_off
  #     entity_id: script.youtube_audio

# MK Trolly Show
  - id: trolly_audio_show_on
    alias: Trolly Audio Show On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.mk_trolly_audio
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/music/Voctave_Trolly_Song.mp3
        volume: .35
  - id: trolly_audio_show_off
    alias: Trolly Audio Show Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.mk_trolly_audio
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.local_audio

# Pandora Ambient Audio
  - id: pandora_audio_on
    alias: Pandora Audio On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.pandora_area_loop
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/Pandora_Area_Loop.mp3
        volume: .35
  - id: pandora_audio_off
    alias: Pandora Audio Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.pandora_area_loop
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio


# Resort Room Audio
  - id: resort_room_audio_on
    alias: Resort Room Audio On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.resort_room_audio
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/WDW_Resort_TV.mp3
        volume: .35
  - id: resort_room_audio_off
    alias: Resort Room Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.resort_room_audio
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio


# American Adventure
  - id: american_adventure_on
    alias: American Adventure On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.american_adventure
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/The_American_Adventure.mp3
        volume: .35
  - id: american_adventure_off
    alias: American Adventure Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.american_adventure
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

# Sleepy Hollow Story Readalong
  - id: sleepy_hollow_readalong_on
    alias: Sleepy Hollow Readalong On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.sleepy_hollow_audiobook
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/thelegendofsleepyhallow-readalong.mp3
        volume: .4
  - id: sleepy_hollow_readalong_off
    alias: Sleepy Hollow Readalong Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.sleepy_hollow_audiobook
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

# Move It Shake It
  - id: move_dance_on
    alias: Move It Shake It On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.move_shake_dance
      to: 'on'
    action:
    - service: script.local_audio
      data_template:
        speaker: media_player.ha_blue
        media: /media/disney/move_it_shake_dance_audio.mp3
        volume: .35
  - id: move_dance_off
    alias: Move It Shake It Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.move_shake_dance
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

# Random Disney Area Loop
  - id: random_disney_area_on
    alias: Random Disney Area On
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.disney_random_area_loop
      to: 'on'
    action:
    - service: script.disney_park_audio
  - id: random_disney_area_off
    alias: Random Disney Area Off
    initial_state: true
    trigger:
    - platform: state
      entity_id: input_boolean.disney_random_area_loop
      to: 'off'
    action:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio

script:
  # kill_hurry_back:
  #   sequence:
  #   - service: shell_command.alarm_off
  hurry_back_short:
    sequence:
    - condition: state
      entity_id: input_boolean.audible_notifications
      state: 'on'
    - condition: state
      entity_id: group.family
      state: 'home'
    - service: shell_command.haunted_mansion_hurry_back_short
  hurry_back_full:
    sequence:
    - condition: state
      entity_id: input_boolean.audible_notifications
      state: 'on'
    - condition: state
      entity_id: group.family
      state: 'home'
    - service: shell_command.haunted_mansion_hurry_back_full
  haunted_lights_on:
    sequence:
    - delay: 00:02:25
    - service: scene.turn_on
      data:
        entity_id: scene.haunted_preshow
  
  haunted_lights_out:
    sequence:
    - delay: 00:02:15
    - service: scene.turn_on
      data:
        entity_id: scene.haunted_lights_out
  haunted_preshow:
    sequence:
    - delay: 00:01:15
    - service: scene.turn_on
      data:
        entity_id: scene.haunted_preshow
  
  kill_haunted_mansion:
    sequence:
    - service: shell_command.alarm_off
    - service: script.turn_off
      data:
        entity_id: script.haunted_preshow
    - service: script.turn_off
      data:
        entity_id: script.haunted_lights_out
    - service: script.turn_off
      data:
        entity_id: script.haunted_lights_on
    - service: scene.turn_on
      data:
        entity_id: scene.normal_livingroom_lighting
  haunted_ride:
    sequence:
    - condition: state
      entity_id: input_boolean.audible_notifications
      state: 'on'
    - condition: state
      entity_id: group.family
      state: 'home'
    - service: shell_command.haunted_mansion_ride

# Big Kill show script - This is my E-Stop
  kill_this_ride:
    sequence:
    - service: media_player.media_stop
      entity_id: media_player.ha_blue
    - service: script.turn_off
      entity_id: script.youtube_audio
    - service: script.turn_off
      entity_id: script.youtube_audio
    - service: homeassistant.turn_off 
      entity_id: group.disney_audio

  
  
  holiday_wishes_preshow:
    sequence:
    - condition: state
      entity_id: input_boolean.audible_notifications
      state: 'on'
    - condition: state
      entity_id: group.family
      state: 'home'
    - service: media_player.turn_on
      entity_id: media_player.ha_blue
    - service: media_player.play_media
      entity_id: media_player.ha_blue
      data:
        media_content_id: /media/disney/wishes_5_min.mp3
        media_content_type: "music"
    - delay: 00:03:00
    - service: scene.turn_on
      entity_id: scene.wishes_preshow
  
  
  wishes_lights_on:
    sequence:
    - delay:
        seconds: 10
    - service: scene.turn_on
      entity_id: scene.wishes_show

  wishes_lights_all:
    sequence:
    - delay:
        seconds: 110
    - service: scene.turn_on
      entity_id: scene.table_lamp_blue
    - delay:
        seconds: 2
    - service: scene.turn_on
      entity_id: scene.front_lamp_green
    - delay:
        seconds: 2
    - service: scene.turn_on
      entity_id: scene.tower_lamp_red

  
  
  illuminations_lights_out:
    sequence:
    - delay: 00:00:57
    - service: scene.turn_on
      data:
        entity_id: scene.haunted_lights_out
  illuminations_single_light:
    sequence:
    - delay: 00:01:03
    - service: scene.turn_on
      data:
        entity_id: scene.dimished_livingroom_lighting
  illuminations_dual_light:
    sequence:
    - delay: 00:01:08
    - service: scene.turn_on
      data:
        entity_id: scene.illuminations_livingroom_lighting_two
  illuminations_triple_light:
    sequence:
    - delay: 00:01:11
    - service: scene.turn_on
      data:
        entity_id: scene.illuminations_livingroom_lighting_three
  illuminations_show:
    sequence:
    - delay: 00:01:19
    - service: scene.turn_on
      data:
        entity_id: scene.normal_livingroom_lighting
  illuminations_preshow:
    sequence:
    - service: scene.turn_on
      data:
        entity_id: scene.normal_livingroom_lighting
  
# Welcome Foolish Mortals to the Haunted Mansion
  haunted_guest_welcome:
    sequence:
    - condition: state
      entity_id: input_boolean.audible_notifications
      state: 'on'
    - condition: state
      entity_id: group.family
      state: 'home'
    - service: media_player.turn_on
      entity_id: media_player.ha_blue
    - service: script.local_audio
      data_template:
        media: /media/disney/haunted_guest_welcome.mp3
        volume: .5

# Random Disney Park Music
  disney_park_audio:
    sequence:
    - service: script.youtube_audio
      data_template:
        speaker: media_player.ha_blue
        volume: .4
        media: >
         {{- ["http://192.168.7.40/Liberty_square_audio.mp3",
            "http://192.168.7.40/adventureland_loop.mp3",
            "http://192.168.7.40/be_our_guest.mp3",
            "http://192.168.7.40/epcot_entrance_loop.mp3",
            "http://192.168.7.40/frontierland_loop.mp3",
            "http://192.168.7.40/tomorrowland_loop.mp3",
            "https://www.youtube.com/watch?v=IyWlxq2kOvw",
            "https://www.youtube.com/watch?v=ngRdzcvr0rg",
            "https://youtu.be/UW9WKIvF9y4",
            "https://www.youtube.com/watch?v=31YJPz7gZ4c",
            "https://www.youtube.com/watch?v=EPO3S649TNs",
            "https://www.youtube.com/watch?v=jOfcg9WYkGw",
            "https://www.youtube.com/watch?v=tBm73YjJB0o",
            "https://www.youtube.com/watch?v=Jmyspnk8DZ8",
            "https://www.youtube.com/watch?v=joOLgTNMuVU",
            "https://www.youtube.com/watch?v=19-ooWL5R8w"] | random -}}

# Dapper Dan Music
  dapper_dan_audio:
    sequence:
    - service: script.youtube_audio
      data_template:
        speaker: media_player.ha_blue
        volume: .4
        media: >
         {{- [
            "https://www.youtube.com/watch?v=ELjBO21QaI0",
            "https://www.youtube.com/watch?v=sQqz_6dkwKE",
            "https://www.youtube.com/watch?v=4uqapvdZLlc",
            "https://www.youtube.com/watch?v=NgWemGSpQDc",
            "https://www.youtube.com/watch?v=bCyCWP311pE"
            ] | random -}}