# Travel Notifications

**URL:** <https://discourse.nodered.org/t/travel-notifications/12345>\
**Category:** General\
**Created:** [17 June 2019 21:24 UTC](https://discourse.nodered.org/t/travel-notifications/12345 "2019-06-17T21:24:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![monsieurlatte](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/monsieurlatte/32/9465_2.png) [@monsieurlatte](https://discourse.nodered.org/u/monsieurlatte)\
**Post date:** [17 June 2019 21:24 UTC](https://discourse.nodered.org/t/travel-notifications/12345/1 "2019-06-17T21:24:04Z")

</div>

So I would like to setup notifications in node red for my wife and myself cars/phones. I have it in HA when I added in some zones and stuff but I would really like to do it in HA. I found someone who did exactly what I want but they are not sharing their flow just images which doesnt help me with all the pulling friendly names and all that (I am still a bit of a noob at NR but I'm getting better). Can anyone share their code for a flow if they have one? Thanks.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [17 June 2019 21:43 UTC](https://discourse.nodered.org/t/travel-notifications/12345/2 "2019-06-17T21:43:00Z")

</div>

Not sure from your description how you intend that to work... but I have something similar....

 ![traffic](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/17d0b7ff68815c69b4588f634bb4beb4ca7e3f89.jpeg)

5 minutes before leaving home \> work & work \> home, the flow calls the google maps api, to query the travel time between the 2 locations.  
This is formatted to an email which warns about increased travel times.

I can't share the full flow because the google api key is hard coded, but the contents of the function node is;

```auto
msg.to = "recipient1@gmail.com";
msg.cc = "recipient2@gmail.com";
msg.topic = "Travel Update";
var route = msg.payload.routes[0].summary;
var durationValue = msg.payload.routes[0].legs[0].duration.value;
var duration = msg.payload.routes[0].legs[0].duration.text;
if (durationValue > 2100) {
    var text2 = "<br> This journey is taking longer than normal!! Check <a href=\https://www.google.co.uk/maps/dir/1+The+Road,+Barnby+Dun,+Doncaster+DN3+1PP,+UK/Moorhead+Way,+Bramley,+Rotherham/@53.4977107,-1.2899287,11z/data=!4m13!412!1m5!1m1!1s0x487917da09c95:0x294e90cde4583477!2m2!1d-1.0656456!2d53.5728961!1m5!1m1!1s0x4879751c65ef3f63:0xb9c2c3fbc77!2m2!1d-1.2656!2d53.422668\">Google Maps</a> to see what the problem is and select a better route.";
    msg.topic = " **TRAVEL ALERT**";
    
} else {
    var text2 = "<br> Drive Safely!!";
    }
var text3 = ("<br><br>Route updated at "+msg.mytime+" on "+msg.mydate);
msg.payload = ("Your route to work via <b>"+route+"</b> will take <b>"+duration+"</b>"+text2+text3);

return msg;

```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![monsieurlatte](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/monsieurlatte/32/9465_2.png) [@monsieurlatte](https://discourse.nodered.org/u/monsieurlatte)\
**Post date:** [17 June 2019 22:07 UTC](https://discourse.nodered.org/t/travel-notifications/12345/3 "2019-06-17T22:07:02Z")

</div>

Thanks Paul, this is more what I was looking at doing.

> **[HELP : How to Mimic HA Zone Triggers in Node-Red](https://community.home-assistant.io/t/help-how-to-mimic-ha-zone-triggers-in-node-red/40345/3?u=monsieurlatte)**
>
> I use HA as my state machine and currently let it handle zones because circles work fine for me. Also, note that not everything needs to be in node-RED. Things that are easier in HA I keep in HA. Using the HA zones, what you have in YAML is really...

It just pushes all zone changes to a device using notify, which is exactly what I want. It looks a lot simpler to me (at least).

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [17 June 2019 22:09 UTC](https://discourse.nodered.org/t/travel-notifications/12345/4 "2019-06-17T22:09:35Z")

</div>

I don't use HA, so can't help further. Good luck!

---

<div class="post-metadata">

**Author:** ![monsieurlatte](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/monsieurlatte/32/9465_2.png) [@monsieurlatte](https://discourse.nodered.org/u/monsieurlatte)\
**Post date:** [17 June 2019 22:42 UTC](https://discourse.nodered.org/t/travel-notifications/12345/5 "2019-06-17T22:42:35Z")

</div>

Oh it’s a node red flow but yes inside of HA which I use.
