Latest from YouTube Channel

Halloween Automations using Home Assistant

October 26th, 2024
YouTube video

Home automation is great fun at Halloween. You can go all out with super expensive lights and special sound systems, or you can do what I’ve done and link together things you might already have for very little cost and I’m going to show you how I put together my little spooky automation for the trick or treaters this year.

Automation Kit List

I’m assuming you already have Home Assistant up and running somewhere, so I’m not including that hardware in the following list. So before I get started on talking about the automation, have a look at these components listed here which are the additional devices I used as part of my Halloween automation.

One of the core components of my automation is a smart doorbell. I’m using the Reolink Wired WiFi Doorbell because it really easily integrates with Home Assistant, providing me with both motion alerts and doorbell press notifications. If you have an existing powered doorbell then this doorbell can use your existing wiring and is really easy to swap over. Reolink also sell a PoE version of this doorbell if you would prefer to run a single network cable to it, and a fully wireless battery version is due out later this year. If you end up going for the battery version, make sure to get the Reolink Home Hub too – this bridges your battery-powered Reolink devices with Home Assistant and is necessary for this link to work. It has the added bonus of storing all of your surveillance footage locally and centrally on microSD cards, instead of having to put microSD cards into each camera individually. I think the Home Hub is worthwhile for that feature alone even if you have fully wired cameras!

Of course you don’t need to use a Reolink doorbell. If you have another brand of smart doorbell that can connect to Home Assistant then you can use that, or you can use a smart button and a smart motion sensor. Ikea sell great value Zigbee-compatible smart buttons and motions sensors if you are after something cheap – don’t forget you’ll need a Zigbee controller to use those ones though.

Okay so now that we have some devices that will trigger our automation, we need some devices to actually automate! Let’s start with the lighting. I’ve used two cheap WiFi-connected ‘Energizer’ branded smart bulbs which only cost Β£5 each from B&M. These bulbs are Tuya Smart Life compatible and integrate really easily with Home Assistant. One of these bulbs I’ve placed in a special holder in the window of my study, and the second has been placed in an outdoor light in my porch.

Neither of these bulbs are very fancy though – they will simply display a chosen colour at a particular brightness on command, they don’t support any preset special effects. In order to make the house look a bit more interesting I’ve used an RGB LED controller from SMLight called the A1-SLWF-03. This is connected to an addressable RGB LED strip which means I can display different colours on the strip at the same time in different places. The LED Controller supports the WLED firmware which enables the creation of almost unlimited combinations of special effects. I’ve used the ‘Dancing Shadows’ effect with orange and purple colours to make my living room window look alive. I’ve also created a ‘Red Breathe’ effect which pulses red light like a heart-beat, and a ‘Red Strobe’ effect which pulses a bright red light extremely quickly. These effects can be initiated from Home Assistant by calling them by name from an ‘input’ service command.

Finally let me hear you make some noise! I really want to scare the s*** out of the trick or treaters this year so I’ve taken my old Sonos One speaker from my conservatory and hidden it right behind my garage door. Sonos speakers work great with Home Assistant because you can simply point them at the URL of an MP3 file and they’ll play it instantly. Home Assistant can act as a web server for those MP3 files which makes things very convenient (just upload the files to the www folder in your base config directory using something like the File Editor add-on).

The Automation’s Actions

Now let’s talk about what this automation will do.

  1. When the Halloween Mode is ‘enabled’ (I’ll talk more about how that works later), it will disable the doorbell’s built-in ringer sound. This is because I don’t want that “bing bong” sound to be played, I have a special treat for my visitors instead… it will then turn on my SMLight LED controller and start the ‘dancing shadows’ preset that I had prepared, and my porch/window light will slowly cycle between orange and purple colours. The porch/window light cycling is managed by a script in Home Assistant that is executed by the automation.
  2. If motion is detected by the doorbell AND Halloween Mode is on, the SMLight LED controller will change the preset to ‘Red Breathe’ and run another script to ‘flicker’ the porch/window lights. This flicker script will just set the bulbs to red and randomly adjust the brightness to produce the flickering effect.
  3. If motion has stopped for a minute, then the lights will revert back to their default Halloween state of dancing shadows or purple/orange cycling.
  4. If the doorbell is pressed then immediately an MP3 file of a scream followed by evil laughter is played at near-full-volume from the Sonos speaker. This is accompanied by the LED controller running a ‘Red Strobe’ preset, and another script being executed to flash the porch/window lights red for a few seconds. When that’s over, the lights will all go back to the default Halloween cycling mode.
  5. Lastly, if Halloween Mode is turned off then we need to set everything back to normal. This involves setting the lights back to their normal colours, turning them off, stopping the various scripts that might be running, and ensuring that the doorbell ringer is re-enabled.

Automation Pre-Requisites

Before we create the automation, we need to create a few other components. The first component is a ‘Toggle’ helper, also known as an input boolean. I’ve called my Toggle Helper “Halloween Mode”. This is presented as a switch by Home Assistant that I can turn on or off.

Secondly I need to create a number of scripts to run the light effects that I require, and also play the MP3 file on the Sonos speaker. My scripts are all listed below for you to copy and paste – you will probably need to change the entity names involved to match your own.

All of the components involved: the scripts, the automation, the Halloween Mode toggle, the motion / doorbell entities, etc., I then placed on a Halloween Dashboard so as I can easily keep an eye on what is happening at various times.

If you’d like to say thank you, please consider donating to help support the site and YouTube channel. All donations are really appreciated, but of course totally optional!

Buy Me A Coffee
alias: "Alert: Play Sound on Sonos"
sequence:
  - condition: time
    after: input_datetime.quiet_time_end
    before: input_datetime.quiet_time_start
  - data_template:
      entity_id: "{{ sonos_entity }}"
    action: sonos.snapshot
  - data_template:
      entity_id: "{{ sonos_entity }}"
    action: media_player.unjoin
  - data_template:
      entity_id: "{{ sonos_entity }}"
      volume_level: "{{ volume }}"
    action: media_player.volume_set
  - data_template:
      entity_id: "{{ sonos_entity }}"
      media_content_id: "{{ soundfile_url }}"
      media_content_type: music
    action: media_player.play_media
  - delay: "{{ delay }}"
  - data_template:
      entity_id: "{{ sonos_entity }}"
    action: sonos.restore
mode: single
alias: Halloween - Cycle Porch Light
sequence:
  - repeat:
      sequence:
        - action: light.turn_on
          metadata: {}
          data:
            rgb_color:
              - 255
              - 80
              - 0
            brightness_pct: 100
          target:
            entity_id:
              - light.porch_light
              - light.test_rgb_bulb
        - delay:
            hours: 0
            minutes: 0
            seconds: 5
            milliseconds: 0
        - action: light.turn_on
          metadata: {}
          data:
            rgb_color:
              - 255
              - 0
              - 195
            brightness_pct: 100
          target:
            entity_id:
              - light.porch_light
              - light.test_rgb_bulb
        - delay:
            hours: 0
            minutes: 0
            seconds: 5
            milliseconds: 0
      while:
        - condition: template
          value_template: "{{ true }}"
description: ""
alias: "Halloween: Porch Light Red Flicker"
sequence:
  - repeat:
      sequence:
        - delay:
            hours: 0
            minutes: 0
            seconds: 0
            milliseconds: 500
        - action: light.turn_on
          metadata: {}
          data:
            rgb_color:
              - 255
              - 0
              - 0
            brightness_pct: "{{ range(20, 90) | random }}"
          target:
            entity_id:
              - light.porch_light
              - light.test_rgb_bulb
      while:
        - condition: template
          value_template: "{{ true }}"
description: ""
alias: Halloween - Flash Red
sequence:
  - repeat:
      count: 20
      sequence:
        - action: light.turn_on
          metadata: {}
          data:
            rgb_color:
              - 255
              - 38
              - 0
            brightness_pct: 100
          target:
            entity_id:
              - light.porch_light
              - light.test_rgb_bulb
        - delay:
            hours: 0
            minutes: 0
            seconds: 0
            milliseconds: 100
        - action: light.turn_off
          metadata: {}
          data: {}
          target:
            entity_id:
              - light.porch_light
              - light.test_rgb_bulb
        - delay:
            hours: 0
            minutes: 0
            seconds: 0
            milliseconds: 100
description: ""

The Automation

And finally this is all brought together into one automation! Please remember, this is just an example and is showing what I have done. Don’t copy and paste this thinking it will work straight away out of the box because it won’t. Use this as inspiration for your own automation and to see how I’ve implemented different components of the automation. For example, you should see how I’ve passed in parameters to the script which plays an MP3 on the Sonos, and you can see the logic involved in stopping and starting the various light effect scripts. Most of all, have fun creating your little bit of Halloween magic this year πŸ™‚

alias: Halloween Mode Run Control
description: ""
triggers:
  - entity_id:
      - input_boolean.halloween_mode
    to: "on"
    id: halloween_on
    trigger: state
  - entity_id:
      - input_boolean.halloween_mode
    to: "off"
    id: halloween_off
    trigger: state
  - entity_id:
      - binary_sensor.reolink_video_doorbell_wifi_w_person
    to: "on"
    id: halloween_motiondetected
    trigger: state
    alias: When motion is detected
  - entity_id:
      - binary_sensor.reolink_video_doorbell_wifi_w_person
    to: "off"
    for:
      hours: 0
      minutes: 1
      seconds: 0
    id: halloween_on
    trigger: state
    alias: When motion has stopped for 1 minute
  - alias: When doorbell has been pressed
    entity_id:
      - binary_sensor.reolink_video_doorbell_wifi_w_visitor
    id: doorbell_ring
    to: "on"
    trigger: state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - halloween_on
          - condition: state
            entity_id: input_boolean.halloween_mode
            state: "on"
        sequence:
          - action: script.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: script.halloween_cycle_porch_light
          - action: select.select_option
            metadata: {}
            data:
              option: Dancing Shadows
            target:
              entity_id: select.slwf_03_preset
          - action: switch.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: switch.reolink_video_doorbell_wifi_w_doorbell_button_sound
            alias: Turn off the doorbell ringer
        alias: "Halloween On: Start the scripts!"
      - conditions:
          - condition: trigger
            id:
              - halloween_off
        sequence:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.reolink_video_doorbell_wifi_w_doorbell_button_sound
            alias: Turn on the doorbell ringer
          - action: script.turn_off
            metadata: {}
            data: {}
            target:
              entity_id:
                - script.halloween_cycle_porch_light
                - script.halloween_porch_light_red_flicker
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: light.slwf_03
          - delay:
              hours: 0
              minutes: 0
              seconds: 2
              milliseconds: 0
          - action: light.turn_on
            metadata: {}
            data:
              brightness_pct: 100
              rgb_color:
                - 255
                - 228
                - 206
            target:
              entity_id: light.porch_light
          - delay:
              hours: 0
              minutes: 0
              seconds: 2
              milliseconds: 0
          - action: light.turn_off
            target:
              entity_id:
                - light.porch_light
                - light.test_rgb_bulb
            data: {}
        alias: "Halloween Off: Stop scripts and put things back to normal"
      - conditions:
          - condition: trigger
            id:
              - halloween_motiondetected
          - condition: state
            entity_id: input_boolean.halloween_mode
            state: "on"
        sequence:
          - action: script.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: script.halloween_cycle_porch_light
          - delay:
              hours: 0
              minutes: 0
              seconds: 1
              milliseconds: 0
          - action: script.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: script.halloween_porch_light_red_flicker
          - action: select.select_option
            metadata: {}
            data:
              option: Red Breathe
            target:
              entity_id: select.slwf_03_preset
        alias: "Halloween: Motion Detected"
      - conditions:
          - condition: trigger
            id:
              - doorbell_ring
          - condition: state
            entity_id: input_boolean.halloween_mode
            state: "on"
        sequence:
          - action: script.turn_on
            metadata: {}
            data:
              variables:
                sonos_entity: media_player.conservatory
                soundfile_url: http://192.168.1.12:8123/local/halloween1.mp3
                volume: 0.4
                delay: "00:00:05"
            target:
              entity_id: script.play_sound_on_sonos
          - action: select.select_option
            metadata: {}
            data:
              option: Red Strobe
            target:
              entity_id: select.slwf_03_preset
          - action: script.turn_off
            metadata: {}
            data: {}
            target:
              entity_id:
                - script.halloween_cycle_porch_light
                - script.halloween_porch_light_red_flicker
            alias: Stop running scripts
          - delay:
              hours: 0
              minutes: 0
              seconds: 1
              milliseconds: 0
          - action: script.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: script.halloween_flash_red
          - delay:
              hours: 0
              minutes: 0
              seconds: 5
              milliseconds: 0
          - action: script.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: script.halloween_cycle_porch_light
          - action: select.select_option
            metadata: {}
            data:
              option: Dancing Shadows
            target:
              entity_id: select.slwf_03_preset
        alias: "Halloween: Doorbell has been pressed"
mode: single

  • As an Amazon Associate I earn from qualifying purchases.