@sdetweil Thanks, that works!
Now I can really see what I’m doing.
Read the statement by Michael Teeuw here.
Posts made by htilburgs
-
RE: Get the correct JSON data
-
RE: Get the correct JSON data
@sdetweil said in Get the correct JSON data:
let foovar = payload.liveweer[0]
Is there a simple way to check what is in foovar?
-
RE: Get the correct JSON data
@sdetweil said in Get the correct JSON data:
coverts directly into js with the same structure
I will try tonight. I’m at work (yeh right ;-) right now.
-
RE: Get the correct JSON data
@sdetweil
As I told you I have to figure out how. I always have problems with understanding how JSON works. But no problem, it keeps me of the streets.
I haven’t been active for the last 3 years, but now I’ve found time and trying to complete / change some modules.
But thanks for you help. -
RE: Get the correct JSON data
@sdetweil
One calll, here you can see (demo data)
https://weerlive.nl/api/weerlive_api_v2.php?key=demo&locatie=Amsterdam -
RE: Get the correct JSON data
@sdetweil
First of all, thank you for looking it to it (again).
The thing is, with the API 1.0 everything was returned in 1 “array”.
Now with the API 2.0 they have split everyting and returned multiple “arrays”.object {4} liveweer [1] 0 {29} plaats : Amsterdam timestamp : 1731476283 time : 13-11-2024 06:38:03 temp : 5.4 gtemp : 5.4 samenv : Zwaar bewolkt lv : 98 windr : NNW windrgr : 327.7 windms : 0.7 windbft : 1 windknp : 1.4 windkmh : 2.5 luchtd : 1033.49 ldmmhg : 775 dauwp : 5.2 zicht : 3720 gr : 0 verw : Overwegend droog, vanochtend plaatselijk (dichte) mist sup : 07:57 sunder : 16:52 image : wolkennacht alarm : 0 lkop : In het oosten vanochtend plaatselijk dichte mist ltekst : In de provincies Overijssel en Gelderland komt plaatselijk dichte mist voor. In de loop van de ochtend lost de mist op.Hiervan kunnen verkeer en buitenactiviteiten hinder ondervinden.Wat kan ik verwachten en wat kan ik doen?Meer detailsIn de mist komen plaatselijk zichten voor van minder dan 200 meter. De kans op dichte mist kan zich de komende uren uitbreiden naar het zuiden. In de tweede helft van de ochtend lost de mist op. wrschklr : groen wrsch_g : - wrsch_gts : 0 wrsch_gc : - wk_verw [5] 0 {12} dag : 13-11-2024 image : bewolkt max_temp : 12 min_temp : 7 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 294 windr : W neersl_perc_dag : 0 zond_perc_dag : 12 1 {12} dag : 14-11-2024 image : halfbewolkt max_temp : 12 min_temp : 10 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 317 windr : NW neersl_perc_dag : 0 zond_perc_dag : 28 2 {12} dag : 15-11-2024 image : halfbewolkt max_temp : 13 min_temp : 8 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 306 windr : NW neersl_perc_dag : 0 zond_perc_dag : 24 3 {12} dag : 16-11-2024 image : halfbewolkt max_temp : 12 min_temp : 7 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 287 windr : W neersl_perc_dag : 0 zond_perc_dag : 24 4 {12} dag : 17-11-2024 image : bewolkt max_temp : 9 min_temp : 8 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 269 windr : W neersl_perc_dag : 0 zond_perc_dag : 7 uur_verw [24] 0 {12} uur : 13-11-2024 07:00 timestamp : 1731477600 image : bewolkt temp : 8 windbft : 2 windkmh : 7 windknp : 4 windms : 2 windrgr : 312 windr : NW neersl : 0 gr : 0 1 {12} uur : 13-11-2024 08:00 timestamp : 1731481200 image : halfbewolkt temp : 9 windbft : 2 windkmh : 7 windknp : 4 windms : 2 windrgr : 289 windr : W neersl : 0 gr : 11 2 {12} uur : 13-11-2024 09:00 timestamp : 1731484800 image : halfbewolkt temp : 10 windbft : 2 windkmh : 7 windknp : 4 windms : 2 windrgr : 268 windr : W neersl : 0 gr : 64 3 {12} uur : 13-11-2024 10:00 timestamp : 1731488400 image : bewolkt temp : 11 windbft : 2 windkmh : 7 windknp : 4 windms : 2 windrgr : 276 windr : W neersl : 0 gr : 64 4 {12} uur : 13-11-2024 11:00 timestamp : 1731492000 image : halfbewolkt temp : 12 windbft : 2 windkmh : 7 windknp : 4 windms : 2 windrgr : 318 windr : NW neersl : 0 gr : 125 5 {12} uur : 13-11-2024 12:00 timestamp : 1731495600 image : bewolkt temp : 12 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 340 windr : NW neersl : 0 gr : 227 6 {12} uur : 13-11-2024 13:00 timestamp : 1731499200 image : halfbewolkt temp : 12 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 339 windr : NW neersl : 0 gr : 86 7 {12} uur : 13-11-2024 14:00 timestamp : 1731502800 image : bewolkt temp : 12 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 336 windr : NW neersl : 0 gr : 28 8 {12} uur : 13-11-2024 15:00 timestamp : 1731506400 image : bewolkt temp : 12 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 335 windr : NW neersl : 0 gr : 14 9 {12} uur : 13-11-2024 16:00 timestamp : 1731510000 image : bewolkt temp : 12 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 327 windr : NW neersl : 0 gr : 3 10 {12} uur : 13-11-2024 17:00 timestamp : 1731513600 image : bewolkt temp : 12 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 324 windr : NW neersl : 0 gr : 0 11 {12} uur : 13-11-2024 18:00 timestamp : 1731517200 image : bewolkt temp : 12 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 331 windr : NW neersl : 0 gr : 0 12 {12} uur : 13-11-2024 19:00 timestamp : 1731520800 image : bewolkt temp : 12 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 320 windr : NW neersl : 0 gr : 0 13 {12} uur : 13-11-2024 20:00 timestamp : 1731524400 image : bewolkt temp : 12 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 316 windr : NW neersl : 0 gr : 0 14 {12} uur : 13-11-2024 21:00 timestamp : 1731528000 image : bewolkt temp : 12 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 319 windr : NW neersl : 0 gr : 0 15 {12} uur : 13-11-2024 22:00 timestamp : 1731531600 image : bewolkt temp : 12 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 319 windr : NW neersl : 0 gr : 0 16 {12} uur : 13-11-2024 23:00 timestamp : 1731535200 image : nachtbewolkt temp : 12 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 318 windr : NW neersl : 0.1 gr : 0 17 {12} uur : 14-11-2024 00:00 timestamp : 1731538800 image : nachtbewolkt temp : 12 windbft : 2 windkmh : 10 windknp : 6 windms : 3 windrgr : 318 windr : NW neersl : 0 gr : 0 18 {12} uur : 14-11-2024 01:00 timestamp : 1731542400 image : regen temp : 12 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 338 windr : NW neersl : 0.5 gr : 0 19 {12} uur : 14-11-2024 02:00 timestamp : 1731546000 image : regen temp : 12 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 351 windr : N neersl : 0.2 gr : 0 20 {12} uur : 14-11-2024 03:00 timestamp : 1731549600 image : bewolkt temp : 12 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 337 windr : NW neersl : 0 gr : 0 21 {12} uur : 14-11-2024 04:00 timestamp : 1731553200 image : nachtbewolkt temp : 12 windbft : 3 windkmh : 18 windknp : 10 windms : 5 windrgr : 350 windr : N neersl : 0 gr : 0 22 {12} uur : 14-11-2024 05:00 timestamp : 1731556800 image : nachtbewolkt temp : 12 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 1 windr : N neersl : 0 gr : 0 23 {12} uur : 14-11-2024 06:00 timestamp : 1731560400 image : nachtbewolkt temp : 11 windbft : 3 windkmh : 14 windknp : 8 windms : 4 windrgr : 349 windr : N neersl : 0 gr : 0 api [1] 0 {3} bron : Bron: Weerdata KNMI/NOAA via Weerlive.nl max_verz : 300 rest_verz : 0
Current weather in “liveweer [0]”, hourly weather in “uur_verw [0-24]” and weekly weather in “wk_verw [0-5]”
So I think I have to make severay arrays and fill this with the data.
From node_helper.js -> MWB and than put everything in three seperates arrays, something like this:var MWB = this.MWB;
var WL = this.MWB.liveweer;
var WH = this.MWB.uur_verw;
var WW = this.MWB.wk_verw;
var API = this.MWB.api;This I’ve to figure out in the next days, weeks, … ;-)
-
RE: Get the correct JSON data
@sdetweil
Hi Sam, in the meantime I was looking further than the length of my nose and I saw when I leave the .liveweer[‘0’] from the result than I get everything.
But because I had been changing a lot, it took me a while before I got the correct results..then(result => { // Process the retrieved user data console.log(result); // Remove trailing slashes to display data in Console for testing this.sendSocketNotification('MWB_RESULT', result); })
I didn’t even have to use the JSON.stringify
Next time I play around for 1/2 hour more, before I place my message. But thanks anyway ;-) -
Get the correct JSON data
In my v1.0 version of MMM-MyDutchWeather there I was using the v1.0 API.
I executed this URL Weerlive API 1.0 and got the next results:{ "liveweer": [ { "plaats": "Amsterdam", "timestamp": "1731422596", "time": "12-11-2024 15:43", "temp": "9.7", "gtemp": "6.8", "samenv": "Licht bewolkt", "lv": "76", "windr": "NO", "windrgr": "44", "windms": "6", "winds": "4", "windk": "11.7", "windkmh": "21.6", "luchtd": "1033.9", "ldmmhg": "775", "dauwp": "6", "zicht": "16", "verw": "Hier en daar zon en overwegend droog", "sup": "07:55", "sunder": "16:54", "image": "lichtbewolkt", "d0weer": "bewolkt", "d0tmax": "11", "d0tmin": "7", "d0windk": "2", "d0windknp": "6", "d0windms": "3", "d0windkmh": "11", "d0windr": "NO", "d0windrgr": "44", "d0neerslag": "0", "d0zon": "10", "d1weer": "bewolkt", "d1tmax": "12", "d1tmin": "4", "d1windk": "2", "d1windknp": "4", "d1windms": "2", "d1windkmh": "7", "d1windr": "NW", "d1windrgr": "315", "d1neerslag": "30", "d1zon": "10", "d2weer": "bewolkt", "d2tmax": "12", "d2tmin": "6", "d2windk": "2", "d2windknp": "6", "d2windms": "3", "d2windkmh": "11", "d2windr": "N", "d2windrgr": "0", "d2neerslag": "20", "d2zon": "10", "alarm": "0" } ] }
In the node_helper.js I used
getMWB: function(url) { // Make a GET request using the Fetch API fetch(url) .then(response => { if (!response.ok) { console.error('MMM-MyDutchWeather: Network response was not ok'); } return response.json(); }) .then(result => { // Process the retrieved user data console.log(result.liveweer['0']); // Remove trailing slashes to display data in Console for testing // console.log(result.wk_verw['0']); this.sendSocketNotification('MWB_RESULT', result.liveweer['0']); }) .catch(error => { console.error('Error:', error); }); },
With the new v2.0 API Weerlive API 2.0 I become the next results
{ "liveweer": [ { "plaats": "Amsterdam", "timestamp": 1731423484, "time": "12-11-2024 15:58:04", "temp": 9.6, "gtemp": 7.3, "samenv": "Licht bewolkt", "lv": 79, "windr": "ONO", "windrgr": 44.5, "windms": 4.33, "windbft": 3, "windknp": 8.4, "windkmh": 15.6, "luchtd": 1033.89, "ldmmhg": 775, "dauwp": 6.2, "zicht": 19400, "gr": 97, "verw": "Hier en daar zon en overwegend droog", "sup": "07:55", "sunder": "16:54", "image": "lichtbewolkt", "alarm": 0, "lkop": "Er zijn geen waarschuwingen", "ltekst": " Er zijn momenteel geen waarschuwingen van kracht.", "wrschklr": "groen", "wrsch_g": "-", "wrsch_gts": 0, "wrsch_gc": "-" } ], "wk_verw": [ { "dag": "12-11-2024", "image": "halfbewolkt", "max_temp": 11, "min_temp": 7, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 48, "windr": "NO", "neersl_perc_dag": 0, "zond_perc_dag": 27 }, { "dag": "13-11-2024", "image": "bewolkt", "max_temp": 12, "min_temp": 7, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 205, "windr": "Z", "neersl_perc_dag": 0, "zond_perc_dag": 12 }, { "dag": "14-11-2024", "image": "halfbewolkt", "max_temp": 12, "min_temp": 10, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 258, "windr": "W", "neersl_perc_dag": 0, "zond_perc_dag": 28 }, { "dag": "15-11-2024", "image": "halfbewolkt", "max_temp": 13, "min_temp": 8, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 265, "windr": "W", "neersl_perc_dag": 0, "zond_perc_dag": 24 }, { "dag": "16-11-2024", "image": "halfbewolkt", "max_temp": 12, "min_temp": 7, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 257, "windr": "ZW", "neersl_perc_dag": 0, "zond_perc_dag": 24 } ], "uur_verw": [ { "uur": "12-11-2024 16:00", "timestamp": 1731423600, "image": "zonnig", "temp": 10, "windbft": 3, "windkmh": 14, "windknp": 8, "windms": 4, "windrgr": 50, "windr": "NO", "neersl": 0, "gr": 28 }, { "uur": "12-11-2024 17:00", "timestamp": 1731427200, "image": "nachtbewolkt", "temp": 10, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 36, "windr": "NO", "neersl": 0, "gr": 0 }, { "uur": "12-11-2024 18:00", "timestamp": 1731430800, "image": "bewolkt", "temp": 9, "windbft": 3, "windkmh": 14, "windknp": 8, "windms": 4, "windrgr": 37, "windr": "NO", "neersl": 0, "gr": 0 }, { "uur": "12-11-2024 19:00", "timestamp": 1731434400, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 35, "windr": "NO", "neersl": 0, "gr": 0 }, { "uur": "12-11-2024 20:00", "timestamp": 1731438000, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 33, "windr": "NO", "neersl": 0, "gr": 0 }, { "uur": "12-11-2024 21:00", "timestamp": 1731441600, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 40, "windr": "NO", "neersl": 0, "gr": 0 }, { "uur": "12-11-2024 22:00", "timestamp": 1731445200, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 43, "windr": "NO", "neersl": 0, "gr": 0 }, { "uur": "12-11-2024 23:00", "timestamp": 1731448800, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 37, "windr": "NO", "neersl": 0, "gr": 0 }, { "uur": "13-11-2024 00:00", "timestamp": 1731452400, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 355, "windr": "N", "neersl": 0, "gr": 0 }, { "uur": "13-11-2024 01:00", "timestamp": 1731456000, "image": "bewolkt", "temp": 9, "windbft": 1, "windkmh": 3, "windknp": 2, "windms": 1, "windrgr": 347, "windr": "NW", "neersl": 0, "gr": 0 }, { "uur": "13-11-2024 02:00", "timestamp": 1731459600, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 24, "windr": "NO", "neersl": 0, "gr": 0 }, { "uur": "13-11-2024 03:00", "timestamp": 1731463200, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 354, "windr": "N", "neersl": 0, "gr": 0 }, { "uur": "13-11-2024 04:00", "timestamp": 1731466800, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 346, "windr": "NW", "neersl": 0, "gr": 0 }, { "uur": "13-11-2024 05:00", "timestamp": 1731470400, "image": "bewolkt", "temp": 9, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 4, "windr": "N", "neersl": 0, "gr": 0 }, { "uur": "13-11-2024 06:00", "timestamp": 1731474000, "image": "bewolkt", "temp": 10, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 349, "windr": "N", "neersl": 0, "gr": 0 }, { "uur": "13-11-2024 07:00", "timestamp": 1731477600, "image": "bewolkt", "temp": 10, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 323, "windr": "NW", "neersl": 0, "gr": 0 }, { "uur": "13-11-2024 08:00", "timestamp": 1731481200, "image": "bewolkt", "temp": 10, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 294, "windr": "W", "neersl": 0, "gr": 19 }, { "uur": "13-11-2024 09:00", "timestamp": 1731484800, "image": "bewolkt", "temp": 11, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 311, "windr": "NW", "neersl": 0, "gr": 69 }, { "uur": "13-11-2024 10:00", "timestamp": 1731488400, "image": "bewolkt", "temp": 11, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 16, "windr": "NO", "neersl": 0, "gr": 61 }, { "uur": "13-11-2024 11:00", "timestamp": 1731492000, "image": "halfbewolkt", "temp": 12, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 41, "windr": "NO", "neersl": 0, "gr": 208 }, { "uur": "13-11-2024 12:00", "timestamp": 1731495600, "image": "halfbewolkt", "temp": 13, "windbft": 2, "windkmh": 7, "windknp": 4, "windms": 2, "windrgr": 330, "windr": "NW", "neersl": 0, "gr": 299 }, { "uur": "13-11-2024 13:00", "timestamp": 1731499200, "image": "bewolkt", "temp": 13, "windbft": 3, "windkmh": 14, "windknp": 8, "windms": 4, "windrgr": 347, "windr": "NW", "neersl": 0, "gr": 175 }, { "uur": "13-11-2024 14:00", "timestamp": 1731502800, "image": "bewolkt", "temp": 13, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 343, "windr": "NW", "neersl": 0, "gr": 108 }, { "uur": "13-11-2024 15:00", "timestamp": 1731506400, "image": "bewolkt", "temp": 13, "windbft": 2, "windkmh": 10, "windknp": 6, "windms": 3, "windrgr": 347, "windr": "NW", "neersl": 0, "gr": 25 } ], "api": [ { "bron": "Bron: Weerdata KNMI/NOAA via Weerlive.nl", "max_verz": 300, "rest_verz": 0 } ] }
Now I’m wondering how do I get this in my Array to use?
I’ve been trying but I don’t have any results. Can someone help me?
I’m doing this for a hobby ;-) -
RE: MMM-Pir
@gonzonia Are you using X11 or Wayland?
Because now you’re using mode 2 and that’s for X11