• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Get the correct JSON data

Scheduled Pinned Locked Moved Development
15 Posts 2 Posters 675 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Away
    sdetweil @htilburgs
    last edited by Nov 12, 2024, 4:42 PM

    @htilburgs cool… glad you got it

    the stringify was just to confirm the data…

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    1 Reply Last reply Reply Quote 0
    • S Away
      sdetweil @htilburgs
      last edited by Nov 12, 2024, 11:54 PM

      @htilburgs i looked at this again and its the value of the thing in quotes

      liveweer[‘0’]

      you want the first element in the array, [0]
      the quotes make it a text character, not a number
      that element 30hex, 48 decimal, does not exist in the array

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      H 1 Reply Last reply Nov 13, 2024, 6:00 AM Reply Quote 0
      • H Offline
        htilburgs @sdetweil
        last edited by Nov 13, 2024, 6:00 AM

        @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, … ;-)

        (still trying to learn JS, but not afraid to ask) ☺

        S 1 Reply Last reply Nov 13, 2024, 11:39 AM Reply Quote 0
        • S Away
          sdetweil @htilburgs
          last edited by Nov 13, 2024, 11:39 AM

          @htilburgs is it separate api calls to get each different data collection?

          or still one call?

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          H 1 Reply Last reply Nov 13, 2024, 12:21 PM Reply Quote 0
          • H Offline
            htilburgs @sdetweil
            last edited by Nov 13, 2024, 12:21 PM

            @sdetweil
            One calll, here you can see (demo data)
            https://weerlive.nl/api/weerlive_api_v2.php?key=demo&locatie=Amsterdam

            (still trying to learn JS, but not afraid to ask) ☺

            S 1 Reply Last reply Nov 13, 2024, 12:45 PM Reply Quote 0
            • S Away
              sdetweil @htilburgs
              last edited by Nov 13, 2024, 12:45 PM

              @htilburgs you can set a variable to the array locations and not move the data. of course the data element names may have changed , but that is an editor find/replace function

              send the whole response up to the module

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              H 1 Reply Last reply Nov 13, 2024, 12:59 PM Reply Quote 0
              • H Offline
                htilburgs @sdetweil
                last edited by Nov 13, 2024, 12:59 PM

                @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.

                (still trying to learn JS, but not afraid to ask) ☺

                S 1 Reply Last reply Nov 13, 2024, 1:05 PM Reply Quote 0
                • S Away
                  sdetweil @htilburgs
                  last edited by Nov 13, 2024, 1:05 PM

                  @htilburgs

                  let foovar = payload.liveweer[0]

                  then you can use foovar to reference the data

                  json is just a text description of an object
                  it coverts directly into js with the same structure

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  H 2 Replies Last reply Nov 13, 2024, 1:27 PM Reply Quote 0
                  • H Offline
                    htilburgs @sdetweil
                    last edited by Nov 13, 2024, 1:27 PM

                    @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.

                    (still trying to learn JS, but not afraid to ask) ☺

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      htilburgs @sdetweil
                      last edited by Nov 13, 2024, 2:11 PM

                      @sdetweil said in Get the correct JSON data:

                      let foovar = payload.liveweer[0]

                      Is there a simple way to check what is in foovar?

                      (still trying to learn JS, but not afraid to ask) ☺

                      S 1 Reply Last reply Nov 13, 2024, 2:18 PM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        8/15
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy