Location Aware Notification Lights with Node-Red and IFTTT

Home AssistantNode-RedSmart Home

Written by:

I am in the habit of going on cooking sprees while listening to music… loudly. I only share one wall with a neighbor here in the loft, and that neighbor is very tolerant. On a Sunday afternoon, with multiple dishes going at a time, my most used smart home feature is “Alexa, set a meatball timer for 25 minutes”. Having Alexa keep track of all my timers is really helpful when my hands are full. The problem is that I rarely hear the timer, and have burned a few things not paying attention.

Using IFTTT, Node-Red, and Home Assistant I can blink the lights in the room when the Alexa timer goes off – even if I wander off to a different room.

First, some tunes

Let’s say you were attempting to make meatballs, a sauce, some pasta, and roast some carrots all while taking notes on a blog post and blasting the above Fugazi album. You might not hear your timer go off. And especially if you are me, you might wander off to do something else for a minute and forget about the timer entirely.

THE SOLUTION

I want the lights to blink 3 times, in whatever room I am in, every time an Alexa timer goes off.

Home Assistant controls the lights and keeps track of what room I was last in (using my useful Motion Last Seen sensor).

Alexa Timers can be used as an IFTTT trigger.

Node-Red can bridge the two, accepting a web request from IFTTT and then telling Home Assistant which lights to blink.


NODE-RED

First, I’m going to make a flow that will blink the lights in the closest room. If no lights are on, it looks to see if I’m watching a movie and pauses that instead.

Blink Lights in Closest Room

Blink Lights in Closest Room

If the lights are on, check the Motion Last Seen sensor. A function evaluates that output, and passes along which light to blink as a data override. The looptimer toggles the light so that it blinks 3 times. The JSON for this flow is available here. The function node for choosing the light looks like this:

newmsg = {}
entity_id = "";
if (msg.payload == "Office Motion") {
 entity_id = "light.office_pendant"
} 
else if (msg.payload == "Bathroom Motion") {
 entity_id = "switch.bathroom_light"
} 
else if (msg.payload == "Kitchen Motion" || msg.payload == "Dining Motion") {
 entity_id = "switch.edison_pendants"
}
else if (msg.payload == "Living Room Motion") {
 entity_id = "light.middle_pendant"
}
else if (msg.payload == "Closet Motion") {
 entity_id = "light.closet"
}
else {
 newmsg = "NONE"
 return newmsg;
}
 
newmsg.payload = { data: {'entity_id': entity_id } } 
return newmsg;

Once this is working as expected, select the flow and click the hamburger menu and select “Subflows -> Create Subflow”.

RELATED >>  The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic

This will package the flow as our own custom node that can be dropped in anywhere easily. Now, if I need to add a room or change which light blinks I can just edit the one subflow instead of multiple function nodes in multiple places.

Sub-Flow

Now let’s create a very simple flow that takes a web request from IFTTT, and triggers our new subflow.

In the http endpoint node, we give it a name and a request type:

http node settings

http node settings

IFTTT

Make a new applet, using the Alexa Timer as the trigger. Then we want IFTTT to make a web request to Node-Red. For the URL, use the endpoint we created above.

IFTTT Settings

IFTTT Settings

Save the applet and test it out, if everything triggers successfully the lights will now blink in whatever room you find yourself in when the timer concludes.

6 Replies to “Location Aware Notification Lights with Node-Red and IFTTT”

  1. Vu Nguyen says:

    what if you have multiple people in the house and the motion detectors detect motion everywhere 🙂 how would you know which one was you? I certainly don’t want other room lights flashing for other people in there… I’ve been curious about a best way to do this but haven’t found any.

  2. Alan says:

    If you’re pointing right to port 1880 it seems like you must have this exposed publicly with no authentication. Have I missed something regarding security with node red?

    • brad says:

      You haven’t, I could not figure out how to get IFTTT to authenticate over HTTP, it seems it is not possible. If anyone has gotten this working with a user/pass on the HTTP endpoint, please comment!

      The password for the Node-Red application itself is separate from the authentication used for the HTTP node. So I have disabled the auth for HTTP endpoints. I use a less obvious endpoint name (random string) and have a firewall rule on my router to only allow WAN requests to 1880 from the IFTTT servers.

      So I would definitely recommend firewalling it, but worst case all someone would have access to is the endpoint.

  3. Aly Chiman says:

    Hello there,

    My name is Aly and I would like to know if you would have any interest to have your website here at diyfuturism.com promoted as a resource on our blog alychidesign.com ?

    We are in the midst of updating our broken link resources to include current and up to date resources for our readers. Our resource links are manually approved allowing us to mark a link as a do-follow link as well
    .
    If you may be interested please in being included as a resource on our blog, please let me know.

    Thanks,
    Aly

  4. Hans says:

    Brad,

    I would like to send a depart message via Node-Red and MQTT when someone leaves the home.

    I have it set to do that when the front door opens. But the issue is, what happens when someone comes home? HA/Node-Red does not know which direction the door was opened.

    Reading your above post has given the solution. If the Motion Sensor at the main entrance then the door opens -> send the Depart message.

    Could you suggest how to do this?

Leave a Reply

Your email address will not be published. Required fields are marked *