Trigger a Routine Based on Phone Location

Automate your smart home tasks easily based on your phone's location.

Posted by Erica Lane on April 28, 2025 · 5 mins read

Trigger a Routine Based on Phone Location

Do you ever wish your smart home could automate tasks based on where you are? Imagine pulling into the driveway, and your favorite music starts playing, the thermostat adjusts to your ideal temperature, and your security system updates. With tools like Amazon Alexa and Node-RED, this dream can become a reality! In this post, we’ll walk through how to set up a routine triggered by your phone’s location, allowing for a seamless integration with your smart home.

Step-by-Step Setup Guide

Prerequisites

Before we jump into the setup, make sure you have the following:

  1. Amazon Alexa Device: This guide will work with any Alexa-enabled device.
  2. Node-RED Installed: If you haven’t already, head over to Node-RED and get it running on your system.
  3. Node-RED Alexa Integration: You’ll want to ensure you have the right Node-RED nodes installed. The Node-RED Alexa integration is recommended for this task.

Step 1: Set Up Your Phone’s Location

To start, you’ll need to set up location tracking on your smartphone. If you’re using an Android device, follow these steps:

  1. Open the Google Maps app.
  2. Tap on your profile picture in the top right corner.
  3. Select Location Sharing and choose who can see your location (this could be your own second account, for instance).

For iPhone users, you can enable location sharing in the Find My app.

Step 2: Create Your Node-RED Flow

  1. Open Node-RED in your browser (usually at http://localhost:1880).
  2. Drag a “http in” node onto the workspace. This node will receive location updates.
  3. Connect it to a “function” node. In the function node, set conditions to determine when you are in or out of a specific location (like your home). You might use something like:

    if (msg.payload.latitude > [your_latitude] && msg.payload.longitude > [your_longitude]) { msg.payload.status = "home"; } else { msg.payload.status = "away"; } return msg;

  4. Connect this function node to a “call service” node to trigger Alexa routines or announcements. You can also use the node-red flow examples as inspiration for other actions to take when you arrive home.
  1. Open the Alexa app on your phone.
  2. Tap on the Routines tab and create a new routine.
  3. For the trigger, select When I say something or consider configuring it through a smart home device integrated via Node-RED.
  4. Choose the action that you want to happen, such as playing music or turning on lights.

Step 4: Test Your Setup

Once everything is set up, take your phone for a test drive! Drive home and see if Node-RED successfully detects your arrival through the configured flow. Make sure your Alexa routine triggers the desired actions.

Helpful Tip Block

  • Linux Users: Ensure you have the correct permissions set for Node-RED. Sometimes without them, the flows won’t run as expected.
  • Webhooks: You might opt to use services like IFTTT to send location data as webhooks to Node-RED seamlessly.
  • Geofencing Apps: Consider using third-party apps designed for geofencing, as they can offer more options for locations and triggers.

Common Issues & Troubleshooting

  • Location Not Updating: Ensure that location services are turned on for your phone and that the background app refresh is allowed.
  • Node-RED Not Responding: Check if your Node-RED server is correctly running and has access to the internet for external calls.
  • Alexa Not Reacting: Make sure your routines are correctly linked in the Alexa app and that you have followed the necessary steps for the integration.

Final Thoughts

Setting up a routine that triggers based on your phone’s location can be incredibly beneficial for a smart home user. Whether you’re arriving home, leaving for work, or just want to automate daily tasks, this guide breaks it down step-by-step. With tools like Node-RED and your trusty Amazon Alexa, you can customize your home environment just the way you like it.

Start experimenting with your own unique triggers, and remember, the possibilities with smart home automation are as vast as your imagination. Happy automating!