Automate Lights Off When No One Is Home

Automate your smart lights to turn off when no one is home and save energy.

Posted by Jared Stone on April 17, 2025 · 5 mins read

Automate Lights Off When No One Is Home

Introduction

Imagine coming home after a long day only to find that you forgot to turn off the lights. Not only is this a waste of energy, but it can also be a hassle. Wouldn’t it be nice if your smart home could handle this automatically? With the right setup, you can easily automate your lights to turn off when no one is home. In this post, we’ll guide you through a simple process using Node-RED and Alexa to ensure your lights are off when you leave the house—a small step that has a big impact on your energy consumption!

Step-by-step Setup Guide

Step 1: Gather Your Equipment

Before diving in, make sure you have the following:

  • A compatible smart light or smart plug.
  • An Amazon Echo device with Alexa enabled.
  • A running instance of Node-RED.
  • The necessary Node-RED modules, particularly the node red contrib alexa home skill.

Step 2: Install Node-RED

If you haven’t already installed Node-RED, go to the Node-RED documentation for a step-by-step guide. Make sure your instance is up and running as this will be your central hub for automation.

Step 3: Set Up Alexa Integration

  1. Install the Alexa Skill: In your Node-RED dashboard, navigate to the “Manage Palette” section to find the node red contrib alexa home skill. Install it for easy integration with your Alexa devices.

  2. Configure the Skill: After installation, you’ll need to configure the Alexa skill:

    • Drag the Alexa node onto your workspace and double-click it to configure.
    • Set the command for turning off your lights. This could be as simple as saying, “Alexa, turn off the lights.”

Step 4: Create a Presence Detection Flow

Using Node-RED, you’ll need to create a presence detection flow:

  1. Add an MQTT Node: This will help in determining whether you’re home or away. You can use devices like smart door sensors or motion detectors.
    • Drag an MQTT out node into your workspace.
    • Configure it to send a message when your presence is detected.
  2. Add a Function Node: This node will differentiate between home and away status. Here’s a simple script you can use:

    if (msg.payload === "away") { return {payload: "off"}; } return null;

  3. Create the Flow: Connect the nodes accordingly; the MQTT node to the function node and then to the Alexa node.

  4. Test the Flow: Trigger your MQTT message to see if the flow correctly sends the command to turn off the lights when you are away.

Step 5: Deploy Your Flow

Once everything is connected and tested, hit the “Deploy” button on the upper right corner of your Node-RED dashboard.

Helpful Tip Block

Tips for Effective Automation:

  • Schedule Check: Incorporate a time-based check (for example, every 15 minutes) to verify if lights should be off, even if no presence is detected.
  • Combine with Other Automations: If you’re already using Node-RED for other smart home tasks, combine them! You can set your lights to turn off when your thermostat is set to away mode or when your door locks.
  • Voice Control: Use Alexa routines to arm your home automation setup. You can verbally activate the same flow when you leave home.

Common Issues & Troubleshooting

  • Lights Fail to Turn Off:
    • Ensure all nodes are properly connected in your flow.
    • Check that the Alexa skill is correctly linked to your smart lights.
  • Presence Detection Incorrect:
    • Double-check your MQTT configuration to ensure it accurately reflects your home’s status.
    • Test the presence sensor independently to confirm it’s functioning correctly.
  • Node-RED Installation Issues:

Final Thoughts

Automating your lights to turn off when no one is home is not just a cool feature; it’s a practical step towards energy savings and smarter living. With the combination of Node-RED, Alexa, and the right smart devices, you can create a seamless automation experience that fits your lifestyle. Plus, you get the added satisfaction of knowing you are reducing energy waste while enjoying the benefits of home automation. Happy automating!