MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. htilburgs
    3. Posts
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    Offline
    • Profile
    • Following 0
    • Followers 2
    • Topics 17
    • Posts 162
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: Multiple URL Querys to fill JSON

      @sdetweil I’ve changed it into this, but still only result from the WaterMeter and not the P1 meter

      	socketNotificationReceived: function(notification, payload) { 
      		if (notification === "MHWP1_RESULT") {
      		// this notification doesn't come back on error..
      		this.processMHW_P1(payload);
      		this.updateDom(this.config.initialLoadDelay); 
      		}
      		else if (notification === "MHWWM_RESULT") {
      		// this notification doesn't come back on error..
      		this.processMHW_WM(payload);
      		this.updateDom(this.config.initialLoadDelay);
      		}
      	},
      
      posted in Troubleshooting
      htilburgsH
      htilburgs
    • Multiple URL Querys to fill JSON

      I hope I describe it correct and you understand what I mean.
      I’m writing a new module which has to display the information from 2 different URL’s.
      When I query them seperate than everythink works OK.
      But I want to do query from URL-1 to JSON (MHW-P1) and URL-2 to JSON (MHW-WM).

      Is this possible and how?
      This is what I’ve came up with, but it doesn’t work.

      node_helper.js

      // P1 Meter section
      //
      getMHW_P1: function(urlP1) {
              // Make a GET request using the Fetch API for the P1 Meter
              fetch(urlP1)
                .then(response_P1 => {
                  if (!response_P1.ok) {
                    console.error('MMM-MyHomeWizard: Network response was not ok');
                  }
                  return response_P1.json();
                })
      
                .then(result_P1 => {
                  // Process the retrieved user data
                  console.log(result_P1); // Remove trailing slashes to display data in Console for testing
                  this.sendSocketNotification('MHWP1_RESULT', result_P1);
                })
      
                .catch(error => {
                  console.error('Error:', error);
                });
        },
      
        socketNotificationReceived: function(notification, payload_P1) {
                  if (notification === 'GET_MHWP1') {
                  this.getMHW_P1(payload_P1);
                  }
        },
        
        // Water Meter Section
        //
        getMHW_WM: function(urlWM) {
              // Make a GET request using the Fetch API for the Water Meter
              fetch(urlWM)
                .then(response_WM => {
                  if (!response_WM.ok) {
                    console.error('MMM-MyHomeWizard: Network response was not ok');
                  }
                  return response_WM.json();
                })
      
                .then(result_WM => {
                  // Process the retrieved user data
                  console.log(result_WM); // Remove trailing slashes to display data in Console for testing
                  this.sendSocketNotification('MHWWM_RESULT', result_WM);
                })
      
                .catch(error => {
                  console.error('Error:', error);
                });
        },
      
        socketNotificationReceived: function(notification, payload_WM) {
                  if (notification === 'GET_MHWWM') {
                  this.getMHW_WM(payload_WM);
                  }
        },
      

      MMM-MyModules.js

      // <-- P1 Meter Section -->
      	
      	// This processes your data P1 Meter
      	processMHW_P1: function(data_P1) { 
      		this.MHW_P1 = data_P1; 
      		console.log(JSON.stringify(this.MHW_P1)); // uncomment to see if you're getting data (in dev console)
      		this.loaded = true;
      	},
      
      	// this tells module when to update
      	scheduleUpdate: function() { 
      		setInterval(() => {
      		    	this.getMHW_P1();
      			this.getMHW_WM();
      		}, this.config.updateInterval);
      		this.getMHW_P1();
      		this.getMHW_WM();
      		var self = this;
      	},
      	  
      	// this asks node_helper for data
      	getMHW_P1: function() { 
      		this.sendSocketNotification('GET_MHWP1', this.urlP1);
      	},
      
      	// this gets data from node_helper
      	socketNotificationReceived: function(notification_P1, payload_P1) { 
      		if (notification_P1 === "MHWP1_RESULT") {
      		// this notification doesn't come back on error..
      		this.processMHW_P1(payload_P1);
      		this.updateDom(this.config.initialLoadDelay); 
      		}
      	},
      	
      //<-- Water Meter Section -->
      	
      	// This processes your data Water Meter
      	processMHW_WM: function(data_WM) { 
      		this.MHW_WM = data_WM; 
      		console.log(JSON.stringify(this.MHW_WM)); // uncomment to see if you're getting data (in dev console)
      		this.loaded = true;
      	},
      
      /*	// this tells module when to update
      	scheduleUpdate: function() { 
      		setInterval(() => {
      		    	this.getMHW_WM();
      		}, this.config.updateInterval);
      		this.getMHW_WM();
      		var self = this;
      	},
      */	  
      	// this asks node_helper for data
      	getMHW_WM: function() { 
      		this.sendSocketNotification('GET_MHWWM', this.urlWM);
      	},
      
      	// this gets data from node_helper
      	socketNotificationReceived: function(notification_WM, payload_WM) { 
      		if (notification_WM === "MHWWM_RESULT") {
      		// this notification doesn't come back on error..
      		this.processMHW_WM(payload_WM);
      		this.updateDom(this.config.initialLoadDelay);
      		}
      	},
      
      I hope somebody can help me with this.
      I'm not a programmer, but I try to do my best ;-)
      
      posted in Troubleshooting
      htilburgsH
      htilburgs
    • RE: Homewizard P1 meter

      @htilburgs
      Currently I’ve installed it with a work-around.

      posted in Requests
      htilburgsH
      htilburgs
    • RE: Homewizard P1 meter

      I try to install with

      git pull https://github.com/Hoaxr/MMM-HomeWizard.git
      

      This failes. i got errors

      remote: Counting objects: 100% (24/24), done.
      remote: Compressing objects: 100% (22/22), done.
      remote: Total 24 (delta 6), reused 12 (delta 0), pack-reused 0 (from 0)
      Unpacking objects: 100% (24/24), 7.95 KiB | 232.00 KiB/s, done.
      From https://github.com/Hoaxr/MMM-HomeWizard
       * branch            HEAD       -> FETCH_HEAD
      hint: You have divergent branches and need to specify how to reconcile them.
      hint: You can do so by running one of the following commands sometime before
      hint: your next pull:
      hint: 
      hint:   git config pull.rebase false  # merge
      hint:   git config pull.rebase true   # rebase
      hint:   git config pull.ff only       # fast-forward only
      hint: 
      hint: You can replace "git config" with "git config --global" to set a default
      hint: preference for all repositories. You can also pass --rebase, --no-rebase,
      hint: or --ff-only on the command line to override the configured default per
      hint: invocation.
      fatal: Need to specify how to reconcile divergent branches.
      
      posted in Requests
      htilburgsH
      htilburgs
    • RE: Get the correct JSON data

      @sdetweil Thanks, that works!
      Now I can really see what I’m doing.

      posted in Development
      htilburgsH
      htilburgs
    • 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?

      posted in Development
      htilburgsH
      htilburgs
    • 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.

      posted in Development
      htilburgsH
      htilburgs
    • 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.

      posted in Development
      htilburgsH
      htilburgs
    • 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

      posted in Development
      htilburgsH
      htilburgs
    • 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, … ;-)

      posted in Development
      htilburgsH
      htilburgs
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 16
    • 17
    • 4 / 17