Help with transforming google maps distance matrix API data

Will test it out for you this weekend…

Thanks a lot!

@watou

As soon as a place in your new binding JAR file, I deleted the original 1.7 version, and re-activate my item where the URL has spaces in then I start getting this error in my logs. I did also make the change to the openhab.cfg file as suggested.

2016-07-02 11:51:30.980 [ERROR] [.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.UnknownFormatConversionException: Conversion = ‘R’
at java.util.Formatter$FormatSpecifier.conversion(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter$FormatSpecifier.(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.parse(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_60]
at java.lang.String.format(Unknown Source) ~[na:1.8.0_60]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:150) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]

Once I disable the item then the error stops.

Looking at my HttpBinding.java, line 150, it looks like you may not have

http:format=false

in your openhab.cfg file. Could you verify that your active openhab.cfg file has that line? Tbanks.

John

This is what I have in my openhab.cfg file…

> ############################### HTTP Binding ##########################################
> #
> # timeout in milliseconds for the http requests (optional, defaults to 5000)
> #http:timeout=
> http:format=false

> # the interval in milliseconds when to find new refresh candidates
> # (optional, defaults to 1000)
> #http:granularity=

> # configuration of the first cache item
> # http:<id1>.url=
> # http:<id1>.updateInterval=

> # configuration of the second cache item  
> # http:<id2>.url=
> # http:<id2>.updateInterval=

Has anyone done this with the google directions api? I essentially want to get the duration of the route going two different ways to work (choosing the shortest of course). To do this I need to use the directions api to enter a waypoint to force the calculation of the other route. I have everything working except for the transform file. Can anyone help with the transform for the total duration?

{
   "geocoded_waypoints" : [
      {
         "geocoder_status" : "OK",
         "place_id" : "ChIJEZc1t0e1sGoR4KiOYlQ2AwU",
         "types" : [ "locality", "political" ]
      },
      {
         "geocoder_status" : "OK",
         "place_id" : "EioyMzMgVGhlIFBhcmFkZSwgTm9yd29vZCBTQSA1MDY3LCBBdXN0cmFsaWE",
         "types" : [ "street_address" ]
      },
      {
         "geocoder_status" : "OK",
         "place_id" : "ChIJP7Mmxcc1t2oRQMaOYlQ2AwQ",
         "types" : [ "colloquial_area", "locality", "political" ]
      }
   ],
   "routes" : [
      {
         "bounds" : {
            "northeast" : {
               "lat" : -34.8697985,
               "lng" : 138.7028416
            },
            "southwest" : {
               "lat" : -34.9285019,
               "lng" : 138.6006484
            }
         },
         "copyrights" : "Map data ©2017 Google",
         "legs" : [
            {
               "distance" : {
                  "text" : "10.3 km",
                  "value" : 10329
               },
               "duration" : {
                  "text" : "17 mins",
                  "value" : 994
               },
               "end_address" : "233 The Parade, Norwood SA 5067, Australia",
               "end_location" : {
                  "lat" : -34.9210311,
                  "lng" : 138.6391782
               },
               "start_address" : "Athelstone SA 5076, Australia",
               "start_location" : {
                  "lat" : -34.8697985,
                  "lng" : 138.7028416
               },
               "steps" : [
                  {
                     "distance" : {
                        "text" : "1.4 km",
                        "value" : 1375
                     },
                     "duration" : {
                        "text" : "2 mins",
                        "value" : 107
                     },
                     "end_location" : {
                        "lat" : -34.8775505,
                        "lng" : 138.6914369
                     },
                     "html_instructions" : "Head \u003cb\u003esouth-west\u003c/b\u003e on \u003cb\u003eGorge Rd\u003c/b\u003e/\u003cb\u003eB31\u003c/b\u003e towards \u003cb\u003eFox Ave\u003c/b\u003e",
                     "polyline" : {
                        "points" : "foysEwkqmYZ|@Vl@@Bz@lBN\\FNVh@\\l@^f@zAjBt@z@dAnAf@l@bCzCdC~CvAhBRVn@z@rCpDh@r@j@t@d@n@d@l@hCfDJBT\\NVNVNX@@JTJXJXLb@HXF\\FVFl@Dd@B`@@L@TDZDZDZ"
                     },
                     "start_location" : {
                        "lat" : -34.8697985,
                        "lng" : 138.7028416
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "1.0 km",
                        "value" : 989
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 85
                     },
                     "end_location" : {
                        "lat" : -34.8863886,
                        "lng" : 138.6920489
                     },
                     "html_instructions" : "At the roundabout, take the \u003cb\u003e1st\u003c/b\u003e exit onto \u003cb\u003eStradbroke Rd\u003c/b\u003e",
                     "maneuver" : "roundabout-left",
                     "polyline" : {
                        "points" : "t_{sEodomY@@@@@??@@@@??@PDNBD?H@RBvHUnAC|CMvBGpCKhCIzEOv@CbBGfBIvAE@?dBEHEBAn@S"
                     },
                     "start_location" : {
                        "lat" : -34.8775505,
                        "lng" : 138.6914369
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "3.3 km",
                        "value" : 3313
                     },
                     "duration" : {
                        "text" : "6 mins",
                        "value" : 332
                     },
                     "end_location" : {
                        "lat" : -34.8895111,
                        "lng" : 138.6565514
                     },
                     "html_instructions" : "At the roundabout, take the \u003cb\u003e3rd\u003c/b\u003e exit onto \u003cb\u003eMontacute Rd\u003c/b\u003e",
                     "maneuver" : "roundabout-left",
                     "polyline" : {
                        "points" : "|v|sEihomY@A?A@?@A?A@?@A@?@?@AB?@?@?@?@?@@@?@@@?@@@@@@@@?@@@?@@@?@?@@@?@?@?D?@?@?@?@?@A@?@A@?@A@?@A@A@?h@?N?F?D@XB^DXFb@?BBNBDLj@\\~@FLf@fAx@vAP^JV@@L^V~@@DHb@Jv@Bj@FrB@vABvA@f@NfIDpBRfLDfCVnL@`@BpADjB@l@?JDzA?RD`ADtCBzA@l@Bx@BvA@v@@t@BjAB|A@j@BpAHlD?HBrABpAHnDHtD@z@@dAHlDBt@JlGHvDDdC?T@NJtG@l@@f@N`HB|@BtAFzC@v@?TJlF?|@DhB@t@"
                     },
                     "start_location" : {
                        "lat" : -34.8863886,
                        "lng" : 138.6920489
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "1.7 km",
                        "value" : 1745
                     },
                     "duration" : {
                        "text" : "3 mins",
                        "value" : 171
                     },
                     "end_location" : {
                        "lat" : -34.8964383,
                        "lng" : 138.6393935
                     },
                     "html_instructions" : "Continue onto \u003cb\u003ePayneham Rd\u003c/b\u003e/\u003cb\u003eA11\u003c/b\u003e",
                     "polyline" : {
                        "points" : "lj}sEmjhmYBPFXDT@?HXl@nBh@jBHVj@pB\\jAZdAX|@x@pCPl@\\jATt@JZh@fBb@vAb@|Aj@jBd@|ARr@X`Af@bBpAjE~@`Dd@~A@DTv@f@xAl@vBn@xBv@lCX|@FRf@bBl@vBRp@^rAr@xBDPXr@Xj@Zn@"
                     },
                     "start_location" : {
                        "lat" : -34.8895111,
                        "lng" : 138.6565514
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "92 m",
                        "value" : 92
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 11
                     },
                     "end_location" : {
                        "lat" : -34.8972464,
                        "lng" : 138.6392774
                     },
                     "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eNational Highway A17\u003c/b\u003e",
                     "maneuver" : "turn-left",
                     "polyline" : {
                        "points" : "vu~sEe_emYH@TJLDL@d@F~@G"
                     },
                     "start_location" : {
                        "lat" : -34.8964383,
                        "lng" : 138.6393935
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "2.6 km",
                        "value" : 2639
                     },
                     "duration" : {
                        "text" : "4 mins",
                        "value" : 239
                     },
                     "end_location" : {
                        "lat" : -34.92093759999999,
                        "lng" : 138.6410374
                     },
                     "html_instructions" : "Continue straight to stay on \u003cb\u003eNational Highway A17\u003c/b\u003e",
                     "maneuver" : "straight",
                     "polyline" : {
                        "points" : "xz~sEo~dmYjDKj@CvAEzCIhAI~@EH?rAC\\Ar@AD?dCKj@Az@CbAC`CIdBGbAENAlAEv@C^?bBGh@A`BEB?|AGrBGNApCIxAE~AGhAE^Al@A`DK|DOxBG|DMbBG|EQbEKp@CfDKr@C`BGl@CL?xCKpCIpAE~AGpAGl@E"
                     },
                     "start_location" : {
                        "lat" : -34.8972464,
                        "lng" : 138.6392774
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 km",
                        "value" : 176
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 49
                     },
                     "end_location" : {
                        "lat" : -34.9210311,
                        "lng" : 138.6391782
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eThe Parade\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "znctEoiemYH?CT?`BBv@@x@DhC"
                     },
                     "start_location" : {
                        "lat" : -34.92093759999999,
                        "lng" : 138.6410374
                     },
                     "travel_mode" : "DRIVING"
                  }
               ],
               "traffic_speed_entry" : [],
               "via_waypoint" : []
            },
            {
               "distance" : {
                  "text" : "4.0 km",
                  "value" : 3989
               },
               "duration" : {
                  "text" : "11 mins",
                  "value" : 673
               },
               "end_address" : "Adelaide SA, Australia",
               "end_location" : {
                  "lat" : -34.9285019,
                  "lng" : 138.6007045
               },
               "start_address" : "233 The Parade, Norwood SA 5067, Australia",
               "start_location" : {
                  "lat" : -34.9210311,
                  "lng" : 138.6391782
               },
               "steps" : [
                  {
                     "distance" : {
                        "text" : "1.5 km",
                        "value" : 1474
                     },
                     "duration" : {
                        "text" : "4 mins",
                        "value" : 236
                     },
                     "end_location" : {
                        "lat" : -34.9218295,
                        "lng" : 138.6230431
                     },
                     "html_instructions" : "Head \u003cb\u003ewest\u003c/b\u003e on \u003cb\u003eThe Parade\u003c/b\u003e towards \u003cb\u003eQueen St\u003c/b\u003e",
                     "polyline" : {
                        "points" : "loctE{}dmY@n@@^JxEBh@HnDRjL@TFnEDjBDpB@d@BpBDrBHtEFlD@b@FpCBvAPjIBjBB`ABjADnBFzD?V"
                     },
                     "start_location" : {
                        "lat" : -34.9210311,
                        "lng" : 138.6391782
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.5 km",
                        "value" : 499
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 72
                     },
                     "end_location" : {
                        "lat" : -34.9250593,
                        "lng" : 138.6192947
                     },
                     "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eFlinders St\u003c/b\u003e",
                     "maneuver" : "turn-left",
                     "polyline" : {
                        "points" : "ltctE_yamYNXFJ@BRRrAvAxJfKj@n@TXRVJRFLBHDH?@DNFVFL"
                     },
                     "start_location" : {
                        "lat" : -34.9218295,
                        "lng" : 138.6230431
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.6 km",
                        "value" : 588
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 68
                     },
                     "end_location" : {
                        "lat" : -34.9251206,
                        "lng" : 138.6128595
                     },
                     "html_instructions" : "Continue onto \u003cb\u003eBartels Rd\u003c/b\u003e",
                     "polyline" : {
                        "points" : "rhdtEqaamYJd@Dr@?H@\\?f@?`CAdB?pL?@?bAAvDA~@?BAh@?`@?r@"
                     },
                     "start_location" : {
                        "lat" : -34.9250593,
                        "lng" : 138.6192947
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "88 m",
                        "value" : 88
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 22
                     },
                     "end_location" : {
                        "lat" : -34.9251701,
                        "lng" : 138.6118969
                     },
                     "html_instructions" : "Continue onto \u003cb\u003eEast Terrace\u003c/b\u003e",
                     "polyline" : {
                        "points" : "~hdtEky_mY?L@h@?HBf@?TB~@"
                     },
                     "start_location" : {
                        "lat" : -34.9251206,
                        "lng" : 138.6128595
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 km",
                        "value" : 154
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 25
                     },
                     "end_location" : {
                        "lat" : -34.92655209999999,
                        "lng" : 138.6119493
                     },
                     "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eHutt St\u003c/b\u003e",
                     "maneuver" : "turn-left",
                     "polyline" : {
                        "points" : "hidtEks_mYTA^?n@Ab@?|@?f@Ab@C"
                     },
                     "start_location" : {
                        "lat" : -34.9251701,
                        "lng" : 138.6118969
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "1.0 km",
                        "value" : 1032
                     },
                     "duration" : {
                        "text" : "3 mins",
                        "value" : 208
                     },
                     "end_location" : {
                        "lat" : -34.9271185,
                        "lng" : 138.6006484
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eFlinders St\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "|qdtEus_mY@TBdBF~B?\\Bt@L~GDxBDrBBvADfB@fABxAF~BDrBBfA@fADpABdBDvA@nAFbC@z@?ND~A"
                     },
                     "start_location" : {
                        "lat" : -34.92655209999999,
                        "lng" : 138.6119493
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 km",
                        "value" : 154
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 42
                     },
                     "end_location" : {
                        "lat" : -34.9285019,
                        "lng" : 138.6007045
                     },
                     "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eVictoria Square\u003c/b\u003e",
                     "maneuver" : "turn-left",
                     "polyline" : {
                        "points" : "nudtEam}lYd@Al@C@?d@ARAXAP@RDXAh@C"
                     },
                     "start_location" : {
                        "lat" : -34.9271185,
                        "lng" : 138.6006484
                     },
                     "travel_mode" : "DRIVING"
                  }
               ],
               "traffic_speed_entry" : [],
               "via_waypoint" : []
            }
         ],
         "overview_polyline" : {
            "points" : "foysEwkqmYr@jB|@pBVl@t@vAzBrCzBjChKrMbOtRJBT\\^n@h@jAX|@Pv@NdAHfANzAH^DBf@J\\DfKYpPk@~Me@xAEdBEHEr@U@A@ANGLBHFDNARGL?`AJxAN|@Lj@\\~@n@tAjAvBLXd@~AJh@NbBHjEZxPr@`_@JvF^bRhA~l@zAh|@F~CJj@~@~C|B`I`CbIbGdSdHdV|DxMvBlHlBpGr@~AZn@H@b@Pr@HjFSbCInHYjDGpHUzHYvNa@vx@gCvVw@hFUCT?`BDpBTrLb@zSp@|`@p@b]FrEVd@bNvN`AhA^j@Pb@`@zAFzAA`UC|HAbCDhBBtAt@AxDCb@C@TJdFVlNf@pW\\vRD~Ad@An@Cx@Cj@?RDXAh@C"
         },
         "summary" : "Montacute Rd and National Highway A17",
         "warnings" : [],
         "waypoint_order" : [ 0 ]
      }
   ],
   "status" : "OK"