You know you want to help me with this Halloween zombie automation

Wow, this is hard to explain. I’m working on a Halloween automation that has two major parts:

  1. Turn on switches for my awesome animatronic zombies
  2. Rotate colors of porch lights through loop of spooky colors

A motion sensor will trigger the main driver script, which sets off several tasks in order. Script pseudo code:

  • Turn off all outside lights
  • Delay 1 second (while passers by are like - WTF just happened?)
  • Turn on zombies (now people are like - O-M-G!!)
  • Launch another script that loops light color changes (same people are no like - Yikes, the lights are changing too!?)
  • Delay 25 seconds (ooohing and awwing)
  • Turn off zombies (oh snap, the dead zombies are dead again)
  • Return lights to normal (standing ovation)
  • Dump buckets of fake blood on everyone (JK. Just wanted to see if you were paying attention)

What I want is for the zombies and light loop to start at the same time, and then both stop after 25 seconds. What seems to be happening is that when it gets to the light loop script, the driver script just sits and waits for the (endless) loop to finish. Is there a way to start and stop both concurrently? Please help!

1 Like

As I am re-reading my own post, I am thinking that maybe the answer is to have not just one but two separate automations that fire when the sensor detects motion. One automation would handle the zombie script and the other would handle the lighting. I guess I could accomplish it that way, but I’d really prefer to have one single automation that can easily handle the step by step timing of each piece.

Looking forward to some good feedback from all of you smarty farties who are way smarter than me!

So basically do an automation like this:

  • Set the automation mode to single
  • Use a state trigger that happens when your motion sensor goes to motion detected
  • Make a light group of all outside lights
  • Use light.turn_off
  • Use - delay: '00:00:01'
  • Turn on the switch that does the zombies
  • And then loop the lights for 15 seconds
  • Then turn off the light
  • And use light.turn_on to normal

So what part are you having trouble with again?

Expecting many trick or treaters?
I’m not and I’m quite sad about it…
My favorite lighting holiday.
At least my few cul-de-sac neighbors will see as they speed by.

Ooh! Drive by spookings to get them to slow down!
Get some liar and zombies to launch into the road.
Definitely won’t get sued.

No joke - We literally get 1000 kids at our door every year. This year will be different, of course. In fact, I’m thinking about shutting everything down on Halloween. I don’t want to be exposed to that many snot nosed kids during a pandemic. But I definitely still want to decorate for the month of October!

1 Like

Maybe it is easier if I just post my scripts. The main script is zombie_attack, and zombie_attack_porch_lights is the script that loops the lights. I added a repeat of 20 to the loop, just to let it keep running. I assumed that the main script would sort of kick off zombie_attack_porch_lights in a separate process and then keep doing its thing while the other script ran. But instead it starts zombie_attack_porch_lights and then sits and waits for it to finish. Maybe I need to give up on the idea of doing exactly 25 seconds, and instead let the loops iterate like 4 or 5 times.

zombie_attack:
  sequence:

   # Turn off Halloween lights
    - service: switch.turn_off
      entity_id: switch.holiday_lights

    # Turn the porch lights off
    - service: light.turn_off
      entity_id:
        - light.front_porch
        - light.front_porch_ceiling_lights

    - delay: '00:00:01'

    # Turn on zombies
    - service: switch.turn_on
      entity_id: switch.zombies

    # Turn on the crazy porch lights loop
    - service: script.zombie_attack_porch_lights

    - delay: '00:00:25'  # Let the zombies scare people for 25 seconds

    # Turn off zombies
    - service: input_boolean.turn_off
      entity_id: input_boolean.halloween_zombies_boolean

    # Turn on the crazy porch lights loop
    - service: script.turn_off
      entity_id: script.zombie_attack_porch_lights

    # Turn Halloween lights back on
    - service: switch.turn_on
      entity_id: switch.holiday_lights

    # Turn the porch lights back on
    - service: script.porch_lights_evening


zombie_attack_porch_lights:
  sequence:
    repeat:
      count: 20
      sequence:
        - service: light.turn_on
          data:
            entity_id: light.left_front_porch_light
            brightness: 255
            rgb_color:  # Purple
                - 147
                - 19
                - 255
                
        - service: light.turn_on
          data:
            entity_id: light.right_front_porch_light
            brightness: 255
            rgb_color: # Green
              - 0
              - 255
              - 65
    
        - service: light.turn_on
          data:
            entity_id: light.left_front_porch_ceiling
            brightness: 255
            rgb_color: # Green
              - 0
              - 255
              - 65
                
        - service: light.turn_on
          data:
            entity_id: light.right_front_porch_ceiling
            brightness: 255
            rgb_color:  # Purple
              - 147
              - 19
              - 255
    
    
        - delay: '00:00:01' 
    
        
        - service: light.turn_on
          data:
            entity_id: light.left_front_porch_light
            brightness: 255
            rgb_color: # Green
              - 0
              - 255
              - 65
                
        - service: light.turn_on
          data:
            entity_id: light.right_front_porch_light
            brightness: 255
            rgb_color:  # Purple
              - 147
              - 19
              - 255
    
        - service: light.turn_on
          data:
            entity_id: light.left_front_porch_ceiling
            brightness: 255
            rgb_color:  # Purple
              - 147
              - 19
              - 255
                
        - service: light.turn_on
          data:
            entity_id: light.right_front_porch_ceiling
            brightness: 255
            rgb_color: # Green
              - 0
              - 255
              - 65
    
        - delay: '00:00:01' 
    
        - service: light.turn_on
          data:
            entity_id:
              - light.front_porch
              - light.front_porch_ceiling_lights
            brightness: 255
            rgb_color: # Red
              - 255
              - 43
              - 0

        - delay: '00:00:01' 

1 Like

If you have a chromecast audio or google home attached on your speaker, you can dump all the mp3 scary sounds on /config/www (mine is at /config/www/sounds/halloween) and randomize whatever will play. The sensor is just to automatically know how many files are on the folder.

script:
  cast_garage_halloween:
    sequence:
      - service: media_player.volume_set
        data_template:
          entity_id: media_player.audiocast_garage
          volume_level: 0.9
      - service: media_player.play_media
        data_template:
           entity_id: media_player.audiocast_garage
           media_content_id: >
             {%- set plists = states.sensor.halloween.attributes.file_list-%}
             {% set pindex =  (range(0, (plists | length - 1 ) )|random) -%}
             {{plists[pindex]|replace('/config/www','http://<HASSIO URL>/local')}}
           media_content_type: 'audio/mp3'
sensor:
  - platform: folder
    folder: /config/www/sounds/halloween
    scan_interval: 28800
1 Like

You should be looping the second script’s stuff 25 / 3 times ~= 8 times.

I don’t have either, but thanks for sharing! What I do have is an Anker Nebula projector and some AtmosFearFX videos. I am working on randomly selecting one of those videos and playing on Plex on the projector!

Yep, you nailed it. I was working too hard on trying to get two different scripts to work simultaneously during a timed period, when it is much simpler and makes way more sense to just control the time period in the light loop script. Here is the final script, in case anyone is interested.

zombie_attack:
  sequence:

    # Turn off Halloween lights
    - service: switch.turn_off
      entity_id: switch.holiday_lights

    # Turn the porch lights off
    - service: light.turn_off
      entity_id:
        - light.front_porch
        - light.front_porch_ceiling_lights

    - delay: '00:00:01'

    # Turn on zombies
    - service: switch.turn_on
      entity_id: switch.zombies

    # Turn on the creepy porch lights loop - Lasts approximately 24 seconds
    - service: script.zombie_attack_porch_lights

    # Turn off zombies
    - service: switch.turn_off
      entity_id: switch.zombies

    # Turn Halloween lights back on
    - service: switch.turn_on
      entity_id: switch.holiday_lights

    # Set the porch lights back to their normal settings
    - service: script.porch_lights_evening



zombie_attack_porch_lights:
  sequence:
    repeat:
      count: 6
      sequence:

        # Left front and right ceiling light - Purple
        - service: light.turn_on
          data:
            entity_id:
              - light.left_front_porch_light
              - light.right_front_porch_ceiling
            brightness: 255
            rgb_color:  # Purple
                - 147
                - 19
                - 255
                
        # Right front and left ceiling light - Green
        - service: light.turn_on
          data:
            entity_id:
              - light.right_front_porch_light
              - light.left_front_porch_ceiling
            brightness: 255
            rgb_color: # Green
              - 0
              - 255
              - 65
  
              
        - delay: '00:00:01' 
    
        
        # Left front and right ceiling light - Green
        - service: light.turn_on
          data:
            entity_id:
              - light.left_front_porch_light
              - light.right_front_porch_ceiling
            brightness: 255
            rgb_color: # Green
              - 0
              - 255
              - 65
                
        # Right front and left ceiling light - Purple
        - service: light.turn_on
          data:
            entity_id:
              - light.right_front_porch_light
              - light.left_front_porch_ceiling
            brightness: 255
            rgb_color:  # Purple
              - 147
              - 19
              - 255


        - delay: '00:00:01' 
    
        
        # All red
        - service: light.turn_on
          data:
            entity_id:
              - light.front_porch
              - light.front_porch_ceiling_lights
            brightness: 255
            rgb_color: # Red
              - 255
              - 43
              - 0

        - delay: '00:00:01' 

I also just learned this…

WAITING FOR SCRIPT TO COMPLETE

When calling a script “directly” (e.g., script.NAME ) the calling script will wait for the called script to finish. If any errors occur that cause the called script to abort, the calling script will be aborted as well.

When calling a script (or multiple scripts) via the script.turn_on service the calling script does not wait. It starts the scripts, in the order listed, and continues as soon as the last script is started. Any errors that occur in the called scripts that cause them to abort will not affect the calling script.

1 Like