Setting up simple GET request and storing value as numeric logic object

Usecase: I want to retrieve from weatherunderground the precipitation (neerslag) for the coming 5 days. And store the 5 day values in the below created variables in Logic.

Pre-requisites:
1.Better Logic App
2. HTTP Request App
3. Weatherunderground Api Key (for free)

I took these steps:

  1. Create Numeric tags in Better Logic

  2. Create the API call via weatherunderground:

  • Selected Geocode API, followed the instructions here:
  • Selected format JSON
  • Selected units M (metric)
  • Selected language (nl-NL)
  • Inserted secret API Key from my profile

That resulted in this API request:
https://api.weather.com/v3/wx/forecast/daily/5day?geocode=52.03,5.16&format=json&units=m&language=nl-NL&apiKey=xxxxxxx

  1. Fetch the JSON file (via browser)
    That resulted in this JSON output:
{"calendarDayTemperatureMax":[16,14,17,14,13,15],"calendarDayTemperatureMin":[4,2,3,4,5,4],"dayOfWeek":["Dinsdag","Woensdag","Donderdag","Vrijdag","Zaterdag","Zondag"],"expirationTimeUtc":[1650988944,1650988944,1650988944,1650988944,1650988944,1650988944],"moonPhase":["Asgrauwe maan","Asgrauwe maan","Asgrauwe maan","Asgrauwe maan","Nieuwe maan","Nieuwe maan"],"moonPhaseCode":["WNC","WNC","WNC","WNC","N","N"],"moonPhaseDay":[25,26,27,28,29,0],"moonriseTimeLocal":["2022-04-26T05:23:16+0200","2022-04-27T05:37:40+0200","2022-04-28T05:50:18+0200","2022-04-29T06:02:22+0200","2022-04-30T06:15:06+0200","2022-05-01T06:29:45+0200"],"moonriseTimeUtc":[1650943396,1651030660,1651117818,1651204942,1651292106,1651379385],"moonsetTimeLocal":["2022-04-26T15:40:50+0200","2022-04-27T16:59:14+0200","2022-04-28T18:15:30+0200","2022-04-29T19:31:19+0200","2022-04-30T20:45:57+0200","2022-05-01T22:00:55+0200"],"moonsetTimeUtc":[1650980450,1651071554,1651162530,1651253479,1651344357,1651435255],"narrative":["Regenbuien vroeg. Minimaal 2C.","Gedeeltelijk bewolkt. Maximaal 13 tot 15C en minimaal 2 tot 4C.","Gedeeltelijk bewolkt. Maximaal 16 tot 18C en minimaal 3 tot 5C.","Bewolkt. Maximaal 13 tot 15C en minimaal 4 tot 6C.","Ochtendbuien. Maximaal 13 tot 15C en minimaal 3 tot 5C.","Gedeeltelijk bewolkt. Maximaal 14 tot 16C en minimaal 3 tot 5C."],"qpf":[0.03,0.0,0.0,0.0,0.5,0.0],"qpfSnow":[0.0,0.0,0.0,0.0,0.0,0.0],"sunriseTimeLocal":["2022-04-26T06:19:29+0200","2022-04-27T06:17:29+0200","2022-04-28T06:15:30+0200","2022-04-29T06:13:32+0200","2022-04-30T06:11:36+0200","2022-05-01T06:09:42+0200"],"sunriseTimeUtc":[1650946769,1651033049,1651119330,1651205612,1651291896,1651378182],"sunsetTimeLocal":["2022-04-26T20:55:53+0200","2022-04-27T20:57:36+0200","2022-04-28T20:59:19+0200","2022-04-29T21:01:02+0200","2022-04-30T21:02:44+0200","2022-05-01T21:04:26+0200"],"sunsetTimeUtc":[1650999353,1651085856,1651172359,1651258862,1651345364,1651431866],"temperatureMax":[null,14,17,14,14,15],"temperatureMin":[2,3,4,5,4,4],"validTimeLocal":["2022-04-26T07:00:00+0200","2022-04-27T07:00:00+0200","2022-04-28T07:00:00+0200","2022-04-29T07:00:00+0200","2022-04-30T07:00:00+0200","2022-05-01T07:00:00+0200"],"validTimeUtc":[1650949200,1651035600,1651122000,1651208400,1651294800,1651381200],"daypart":[{"cloudCover":[null,19,54,21,30,66,90,58,70,51,61,36],"dayOrNight":[null,"N","D","N","D","N","D","N","D","N","D","N"],"daypartName":[null,"Vanavond","Morgen","Morgenavond","Donderdag","Donderdagnacht","Vrijdag","Vrijdagnacht","Zaterdag","Zaterdagnacht","Zondag","Zondagnacht"],"iconCode":[null,45,30,29,30,27,26,29,39,29,30,29],"iconCodeExtend":[null,6100,3000,2900,3000,2700,2600,2900,6103,2900,3000,2900],"narrative":[null,"Regenbuien vroeg. Minimaal 2C. Wind uit het N van 10 tot 15 km/u. Kans op regen 30%.","Gedeeltelijk bewolkt. Maximaal 14C. Wind uit het N van 10 tot 15 km/u.","Gedeeltelijk bewolkt. Minimaal 3C. Wind uit het N van 10 tot 15 km/u.","Gedeeltelijk bewolkt. Warmer. Maximaal 17C. Wind uit het NO van 10 tot 15 km/u.","Overwegend bewolkt. Minimaal 4C. Wind uit het NNO van 10 tot 15 km/u.","Bewolkt. Maximaal 14C. Wind uit het NNO van 15 tot 25 km/u.","Gedeeltelijk bewolkt. Minimaal 5C. Wind uit het NNO van 15 tot 25 km/u.","Ochtendbuien. Maximaal 14C. Wind uit het NNO van 15 tot 25 km/u. Kans op regen 40%.","Gedeeltelijk bewolkt. Minimaal 4C. Wind uit het N van 15 tot 25 km/u.","Gedeeltelijk bewolkt. Maximaal 15C. Wind uit het NNO van 10 tot 15 km/u.","Gedeeltelijk bewolkt. Minimaal 4C. Wind uit het N van 10 tot 15 km/u."],"precipChance":[null,33,22,15,14,10,10,21,36,12,19,12],"precipType":[null,"rain","rain","precip","rain","precip","rain","rain","rain","precip","rain","precip"],"qpf":[null,0.03,0.0,0.0,0.0,0.0,0.0,0.0,0.5,0.0,0.0,0.0],"qpfSnow":[null,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"qualifierCode":[null,null,null,null,"Q630",null,null,null,null,null,null,null],"qualifierPhrase":[null,null,null,null,"Warmer.",null,null,null,null,null,null,null],"relativeHumidity":[null,75,63,80,62,71,61,73,63,76,60,76],"snowRange":[null,"","","","","","","","","","",""],"temperature":[null,2,14,3,17,4,14,5,14,4,15,4],"temperatureHeatIndex":[null,13,14,13,16,15,14,12,13,12,15,14],"temperatureWindChill":[null,3,4,2,2,2,2,3,4,3,4,4],"thunderCategory":[null,null,null,null,null,null,null,null,null,null,null,null],"thunderIndex":[null,0,0,0,0,0,0,0,0,0,0,0],"uvDescription":[null,"Laag","Gemiddeld","Laag","Gemiddeld","Laag","Laag","Laag","Gemiddeld","Laag","Gemiddeld","Laag"],"uvIndex":[null,0,4,0,5,0,2,0,3,0,4,0],"windDirection":[null,349,353,10,34,30,33,18,14,6,13,0],"windDirectionCardinal":[null,"N","N","N","NO","NNO","NNO","NNO","NNO","N","NNO","N"],"windPhrase":[null,"Wind uit het N van 10 tot 15 km/u.","Wind uit het N van 10 tot 15 km/u.","Wind uit het N van 10 tot 15 km/u.","Wind uit het NO van 10 tot 15 km/u.","Wind uit het NNO van 10 tot 15 km/u.","Wind uit het NNO van 15 tot 25 km/u.","Wind uit het NNO van 15 tot 25 km/u.","Wind uit het NNO van 15 tot 25 km/u.","Wind uit het N van 15 tot 25 km/u.","Wind uit het NNO van 10 tot 15 km/u.","Wind uit het N van 10 tot 15 km/u."],"windSpeed":[null,16,11,13,14,16,19,20,18,18,16,16],"wxPhraseLong":[null,"Buien vroeg","Gedeeltelijk bewolkt","Gedeeltelijk bewolkt","Gedeeltelijk bewolkt","Overwegend bewolkt","Bewolkt","Gedeeltelijk bewolkt","Ochtendbuien","Gedeeltelijk bewolkt","Gedeeltelijk bewolkt","Gedeeltelijk bewolkt"],"wxPhraseShort":[null,"","","","","","","","","","",""]}]}

Screenshot:

  1. Copy paste Json txt in https://jsonpath.com to extract Jsonpath

Copy paste the Json file in Inputs, find the data you need, in my case qpf and play with the path, when you execute it correct you see the value you want to fetch and store

You can also use https://jsonpathfinder.com and clean up the code, you get something like this in return:

  1. Set up the flow in Homey via Get

  • If statement: After 04 o clock the Underground API seems to be updated therefore 04:15
  • Select the “Get Jasonpath Better Logic” card
  • Copy Paste the url from weatherUnderground
  • Copy Paste the Jsonpath
  • Select BetterLogic tag you want to write it to

Thanks @robertklep ? :slight_smile: for the last nudge, now it works…

3 Likes