Daily Commute Traffic in Lights!


Here’s one I implemented for my wife to help her gauge her commute time in the morning. The piston checks the traffic using the Google Maps Distance Matrix and displays green, orange, or red depending on the delay. It will also send a text message at a given time if there is a delay and she should get going.

You do have to have a valid Google Maps API key that you can get here: https://developers.google.com/maps/documentation/distance-matrix/get-api-key

External URL for tile?

Absolutely love this - thanks for sharing :+1:


Ha! Love this. Something like this was what I needed. I tweaked it a lot for something else I wanted to do. I set a simple virtual switch to be a trigger to make the google maps api call. Then bundle the text together and text my wife that I am coming home + (pad time+time). Finally I added the virtual switch to an alexa routine. Now when I leave the office I can say ‘alexa, heading home’ and it will text her. Cool.

It was the api call I needed! Cheers.

In case anyone wants what I did:


Replying to my own post! Yep, that’s me.

You know I was thinking about this piston more. You know, it does not even make use of any devices. Other than the ST hub and a cell phone and in my case Alexa, nothing else is needed. No real switches or lights or anything else.

Really shows the flexibility of the Internet of Things in 2018. Google supplies the API and data (free), ST the platform (one time purchase) and the wonderfully powerful, yet fairly easy to use WebCore (free - highly recommend a donation!) for the automation.

Limited use case, but also very low cost assuming you have a phone and a smart speaker already. Really cool!

Take a step back and appreciate, thinking of where this stuff was back in 2000 with X10, etc. :slight_smile:

PS: I am eventually going to attempt to update this piston to use the Origin_Address to be my phone’s current location rather than hard coded office. I think it will be easy, I just need time to play with it. See if location gives me something the Google Maps API will accept as Origin.


@Equis your phone number shows up in the screen shot, I would remove… lol


If you used the webcore presense sensor, and the start location was one of your defined places, maybe you could put that info into the starting_destination variable?


Replying to my own post as well. Webcore presence sensor does include current lat/long. I testing just putting origin address as lat, long, and it worked just fine. So I think you could do this pretty easy. Working on it now.


So, this should work if you want to know how long your commute will be from where you are to Home, like for the one listed above.

Change Origin Address to:
Keep it a string Variable and set the value to
{[WebcorePresenceSensor :latitude]} ", " {[WebcorePresenceSensor :longitude]}


Thanks again for this awesome idea. I used yours as a foundation for this one.
This will send me a text message if my commute will be heavy. For me I set the time to 30 minutes before I usually leave work. Then I can make sure to bring up waze for my commute home.
I also added one more restriction of a long commute time (2 hours)to cover if I was obviously out of the area. But forgot to turn off the text messages. Would be funny to see your commute will be 8 hours and 45 minutes. :slight_smile:


Nice work, guys. I work from home so I don’t have a commute, but using your current location is a great idea. My wife leaves work to come home at the same time every day, so having a warning doesn’t really help/matter. She’s at the mercy of traffic at that time no matter what. She just follows whatever route Waze takes her. (Don’t think you know better than the GPS with live traffic!) At least in the morning she can leave a bit earlier if she needs to.

If you can poll your current location, I’ve thought it would be handy to trigger other stuff on your way home, too. Like, if my distance to home has been reduced by ‘n’ miles in ‘x’ minutes, it probably means I’m heading toward home and the piston should start warming or cooling the house. When my wife and I are out in the evening, we always forget to hit the “Warm up the house” button when we’re on our way and it only starts warming up once we’re inside the ST home radius.


There is a state for Distance to home in the webcore presence sensor. I believe that if you are moving faster than a specific speed, it updates every 5 minutes. I’m basing that by looking at my smartthings history. If you’re not moving it does not update. I’m sure the distance is as the crow flies but could still be used to do what you’re talking about.

{[Presence - (Webcore) : distance]}


This is awesome. Gonna give it a try and see what happens tomorrow morning.


Only issue I’ve had is that my light does not turn on. I have Hue bulbs. What kind of RGB bulbs do you use? I just went ahead and added a step to turn it on before setting to 100%.


I’m using Osram Lightify RGBW strips under my cabinets.


How many API calls does this make a second (or in your start-stop defined range?)
Google gives you 40,000 element calls per month for free, then you pay a fee.


It only makes a call every 10 minutes for about an hour and a half per weekday.


Your phone number and API is in your piston.


If you are on Android you can use tasker to launch Waze when this piston is true.


If you are on an Android device you can tap into @webCoRE Tasker solution.


Guys, I’m trying to use this to get the time to home minutes but it is always returning Zero and SMS notification also not working. Push notification work with same time as zero.

What did I do wrong. My API not working?