Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95414

Create a template from a https request and json answer

$
0
0

@penright wrote:

Not sure if this can be done. I would like to query google and get time and distance. Today I am doing it with code running in AppDaemon. When a switch is flipped on, then an AppDaemon would hit the api, build a message that the notify platform would then text. I was seeing if I could move it into HA automation yaml. That is all I am using AppDaemon for now.

Here is my https call:

https://maps.googleapis.com/maps/api/distancematrix/json?origins=35.xxxxx,-97.xxxxx&destinations=35.xxxx,-97.xxxxx&mode=driving&language=en-EN&sensor=false&key=xxxx

It then responds with something like:

{
   "destination_addresses" : [ "xxx Antler Ridge, xxx, OK xxxxx, USA" ],
   "origin_addresses" : [ "xxx NE 63rd St, Oklahoma City, OK 73121, USA" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "48.3 km",
                  "value" : 48317
               },
               "duration" : {
                  "text" : "36 mins",
                  "value" : 2133
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

Is there a way to call a https and template the response?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95414

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>