So in the last 2 weeks I have been put to the test of patience and road rage.

Last week there was a guy that decided to take his dog for a walk on the over pass and decided to stop and contemplate jumping. This closed down a 3 lane highway and the 2 joining lanes completely in morning rush hour. Diverted traffic was diverted to a 1 lane exit. I sat in traffic for 3.5 hours!!!! At that point I called the office and said “i’m working from home, it will take me hours to get there and 30 minutes to get home.”

That was pretty rough.

This past week was obviously not as bad. But 4 out of 5 days this week my normally 45-50 minute commute was 90 minutes.

So normally I spend 4hrs 10min on the road commuting in the morning and roughly 5 hours in the evenings (traffic gets worse)

But this week was almost 7 hours in the morning and 5 in the evening.

12 hours……

I don’t think you heard…. 12 HOURS!!!!! Just driving!!! It’s stupid.

Man I could get a lot of work done driving a tesla!

So I had this dream this week, very strange I know, and some of the details I am omitting here because well… some of it was quite sexy…. but that’s not the part I am hiding. There was another device in my dream that I have thought about making before and in my dream I had it done. But it had a new feature…. it told me if my drive to work was going to be longer than usual……

I know I know. “Just watch the news you jackass!” I can hear you all saying that. However I cut the cable many many many moons ago. I don’t get the news. Two. Well, my past brain problems have led me to a life where I don’t watch the news often because the news is generally bad and I find myself a much happier well adjusted member of society if I don’t watch the news in the morning. But I got side tracked.

So after the wife telling me



I decided to look into this thing that my brain was hinting at. So I spent some time looking for mapping/navigation api’s. I found out that TomTom has one. Pretty good to, you can tell it what kind of vehicle you have, and if you want traffic to be taken in to account and all kinds of stuff. So I got an api key and started coding against it. Pretty neat.

But then I found this. This turned out to be pretty interesting by itself since I currently use a dashing dashboard for a few things internally.

I set it up for myself in dashing and it works nicely. So we are close, but not quite what I am looking for.

So I decided to keep working, and thinking, and eating chips.

Wait. No chips. Just working and thinking.

I decided what I needed was 2 fold.

Traffic time must be in my Home Automation system so I can create rules based on the time. The times must be stored somewhere so I can get a new idea of “average” drive time.

I got it. Create an item in Openhab. Update said item periodically. I already have openhab mysql persistance enabled. This will work. I will be able to run data reports based on time of day (aka MORNING during the week) and see what the average/no accident drive time is and over time even see how much time an accident add’s to my trip on average.

So now in my openhab I have the following ITEM configured in my home.items file.

Number WorkDriveTime "Drive Time [%s minutes]"

and in my home.sitemap file

Text item=WorkDriveTime

I have a cronjob that runs every 5 minutes that just fires off a php file to get the tomtom info, convert seconds to minutes, round it off and update openhab.

My simple php file is here.

<?php $string = file_get_contents("https://api.tomtom.com/routing/1/calculateRoute/28.3852,-81.5639:33.8121,-117.9190/json?routeType=fastest&traffic=true&travelMode=car&key=YOURAPIKEY"); $json = json_decode($string, true); $DriveTime = round($json["routes"][0]["summary"]["travelTimeInSeconds"]/60); if ($DriveTime != 0) { sendOpenHabUpdate("WorkDriveTime",$DriveTime); } function sendOpenHabUpdate($item, $data) { $openhabserver = "http://192.168.2.90:8080/rest/items/" . $item; $options = array( 'http' => array( 'header' => "Content-type: text/plain\r

", 'method' => 'POST', 'content' => (string)$data, ), ); $context = stream_context_create($options); $result = file_get_contents($openhabserver, false, $context); return $result; }

So with this now running in my crontab I have my database slowly updating with drive times.

Oh. If you want to get a key for TomTom yourself just go to http://developer.tomtom.com/

So what do I have in store for this. Well, there is another value that comes back in this specifically related to “delay from traffic” so I may add this in as another number item to track. But the plan is to know before I leave the house if I should take a regular coffee or a giant coffee to get me through the morning commute.