@sdetweil In the netherlands, we do have that!
Fortunately, otherwise I would not have been able to write this MagicMirror module ;-)
Read the statement by Michael Teeuw here.
Posts
-
RE: MMM-MyHomeWizard
-
MMM-MyHomeWizard
MMM-MyHomeWizard is a MagicMirror module that shows the information from the HomeWizard P1 meter and/or the HomeWizard WaterMeter.
The HomeWizard P1 Meter gives you detailed insight into your gas consumption, electricity consumption and solar surplus.
The HomeWizard Watermeter gives you live insight into your water consumption.Homepage: MMM-MyHomeWizard
-
RE: Switch URL based on value
@sdetweil
Meanwhile I was doing this, and I found the error (stupid me)start: function () { Log.info("Starting module: " + this.name); requiresVersion: "2.9.0"; // Set locales if (this.config.P1_IP != null) { this.urlP1 = "http://" + this.config.P1_IP + "/api/v1/data/"; } else { this.urlP1 = "https://dummyjson.com/c/7e24-36ab-48e0-a96d"; } if (this.config.WM_IP != null) { this.urlWM = "http://" + this.config.WM_IP + "/api/v1/data/"; } else { this.urlWM = "https://dummyjson.com/c/704a-9a96-4845-bc72"; } // this.urlP1 = "http://" + this.config.P1_IP + "/api/v1/data/"; // this.urlWM = "http://" + this.config.WM_IP + "/api/v1/data/"; this.MHW_P1 = []; // <-- Create empty MHW_P1 array this.MHW_WM = []; // <-- Create empty MHW_WM array this.scheduleUpdate(); // <-- When the module updates (see below) },
The line with "requiresVersion: “2.9.0”; " was ending with an “,” instead of “;”
without the “if” statement, I don’t get a failure with a “,”
So changed it now into “;” and everythins seems to work.
I continue testing.@MMRIZE Thanks for the alternative way. I’m going to look into it.
So with the “promise” statement, it looks like I can eleminate the node_helper.js -
RE: Switch URL based on value
@sdetweil
In the console - sources it says:Uncaught SyntaxError: Unexpected token 'if'
-
RE: Switch URL based on value
// Default values defaults: { P1_IP: null, // IP Address P1 Meter WM_IP: null, // IP Address Water Meter maxWidth: "500px", // Max width wrapper extraInfo: false, // Show extra information showFooter: false, // Show footer (name Power Meter) currentPower: true, // Show current power usage initialLoadDelay: 1000, updateInterval: 10000 // Every 10 seconds },
-
Switch URL based on value
In the script it will assume you have 2 different IP addresses to query an URL.
1 IP for the HomeWizard P1 meter
1 IP for the HomeWizard Water Meter
This is because I like to show the information of both in 1 script. Everything works fine if both are used, but when someone only has the P1 meter, the IP for the Water Meter is not used and results in a console fetch error (normal behavior)[ERROR] Error: TypeError: fetch failed at node:internal/deps/undici/undici:13178:13 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { [cause]: Error: getaddrinfo ENOTFOUND null at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'null' } }
Is there a way to switch URL in case one of both URL are NULL? I’ve tried, but it doesn’t work with if-else
start: function () { Log.info("Starting module: " + this.name); requiresVersion: "2.9.0", // Set locales if (this.config.P1_IP != null) { this.urlP1 = "http://" + this.config.P1_IP + "/api/v1/data/"; } else { this.urlP1 = "https://dummyjson.com/c/7e24-36ab-48e0-a96d"; } if (this.config.WM_IP != null) { this.urlWM = "http://" + this.config.WM_IP + "/api/v1/data/"; } else { this.urlWM = "https://dummyjson.com/c/704a-9a96-4845-bc72"; } this.MHW_P1 = []; // <-- Create empty MHW_P1 array this.MHW_WM = []; // <-- Create empty MHW_WM array this.scheduleUpdate(); // <-- When the module updates (see below) },
-
RE: Multiple URL Querys to fill JSON
@sdetweil Thnx, you helped me a lot!!
-
RE: Multiple URL Querys to fill JSON
@sdetweil Wow, it works!
Just checking, it has to be done in node_helper and the MMM-Module? -
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); } },