Unusual error - loading node credentials

I have a weather process that gets http information and parses it for me. This process has and does work perfectly (for some time) getting the link for my home area (from a government weather page).

So I decided to copy the function changing only the web page source to "get" data for the area where my cottage is located. The links are identical except a number in the link changes to determine the area for which information is supplied. I made certain no context variables were duplicated across the 2 flows.

If I feed this new http get node only to a debug it works perfectly, fetching the data I would expect to see. I've sent the output to a file to go over it with a fine tooth comb. All looks fine. But every time I connect the http get to the function node that parses it, I get this error ....

Loading Node Credentials ....

... and Node Red locks up. I can stop NR and restart it but then I get a "port is in use" error and NR stops. I must reboot the computer (pi3) to repair the issue.

Any ideas?

This indicates node-red has crashed or is not responsive

and this clarifies the above - Node-RED is unresponsive.


Potentially, something you are doing (runaway loop in function?) is hogging the stack & making NR unresponsive.

Does your function node have outputs? Where do they go?

I think we need to see at least a screen capture of your flow and an export of your function node.

Also disconnect any outputs connected to the function node, to make sure that it is not something later that is causing the problem. If it still does it, then as jbudd says, select the function node and export it here, or paste the contents of the node here.

Here are the nodes without the function node output connections. Clicking "Simcoe" works fine.

When the inject of 'Watford' is clicked, the get http node should just flash requesting and then clear the node status, as occurs with "Simcoe" ... and it does but only when just a debug is connected to the get http output (not the function node). There is never any lock up in this case.

When the function node is connected to the http output and Watford clicked, the node.status of the get http node stays stuck on requesting and then the "Loading Node Credentials" eventually pops up and NR is locked up. Incidentally the 'port' that seems to be locked out (as I recall) is local host:1880.

Here are the nodes and code:

[{"id":"a6278fd5ae65c9e3","type":"function","z":"33029ff0c3176c55","name":"Weather Forfecast {WF}","func":"\n// Code compatible with:     https://weather.gc.ca/rss/city/on-161_e.xml\n\n//  --------------------------------------   function getNumber()   ------------------------------------------- \nfunction getNumber(string) {  // extracts numbers from a string\n    // Using match with regEx\n    let matches = string.match(/\\d+/g);\n    if (matches && typeof(matches[1]) === 'undefined') return(matches[0])\n    else if (matches) return(matches[0] +'.'+ matches[1])\n    else return(string) ;  }\n\n// Set variable for process monitor.\ncontext.global.activity_tab = \"Weather: \";\ncontext.global.activity_node = \"Get latest forecast\";\ncontext.global.activity = context.global.activity_tab + context.global.activity_node;\n\n// =======================================   CONFIRM GOOD DATA   ==============================================\nif (msg.payload.indexOf(\"ENOTFOUND\") > -1 || msg.payload.indexOf(\"Error 404\") > -1) {\n    node.warn(\"{WF 19} HTTP Error: Failed to get weather alert info at https://weather.gc.ca/rss/city/on-161_e.xml\" );\n    return;  }\nif (msg.payload.indexOf( \"- Weather - Environment Canada</title>\" ) === -1) {\n    node.status({fill: 'grey', shape: 'ring', text: 'Web fail, using previous info'  });\n    node.warn('{WF 23} Weather data retrieve failure from XML site.');\n    var forecast = context.previous_data;\n} else {\n    forecast = msg.payload;\n    context.previous_data = forecast;\n}\nif (msg.payload === 'undefined') { node.warn(\"{WF 29} ERROR: No weather data to use\");  return; }\n\nvar logTime = context.global.ampm_timestamp();\nvar x = 0, tag1 = 0, tag2 = 0, direction, word = 0, string, logMsg = null; \nvar now = new Date();\n\n// -------------------------------------------    GET LOCATION INFO   -----------------------------------------\nvar tag  = '<title>';\ntag1 = msg.payload.indexOf(tag) + tag.length;\ntag2 = msg.payload.indexOf(' - Weather - Environment Canada');\n     tag = msg.payload.substring(tag1, tag2);       // IE: 'Simcoe - Delhi - Norfolk'  or 'Annapolis County'\nif (tag.indexOf(\" - \") > -1) var location = tag.substring(0, tag.indexOf(\" - \"))\nelse location = tag;           // IE: 'Simcoe' or 'Annapolis County'\n//node.warn('{WF 42} ' + location);\n\n// =======================================   WARNINGS & WATCHES CHECK   =======================================\ntag1 = forecast.indexOf('term=\"Warnings and Watches\"/>') + 53;\ntag2 = forecast.indexOf('</summary>', tag1);\nvar warning = forecast.substring(tag1, tag2);\nif (warning != \"No watches or warnings in effect.\")      {\n    node.warn(\"{WF 49} \" + warning);\n//    logMsg = {payload: logTime + \"{WF 50} \" + warning}; \n}\nif (warning.length > 30 ) warning = \"Weather warning. \";\nnode.status({fill: 'grey', shape: 'ring', text: location + \": Weather data read\"  });\n\n// =======================================   EXTRACT RELEVANT TECHNICAL DATA   ================================\nconst techheaders = [\"<b>Temperature:</b>\", \"<b>Pressure / Tendency:</b>\", \"<b>Humidity:</b>\", \"<b>Wind:</b>\", \n                    \"<b>Air Quality Health Index:</b>\"];   \nconst winds = [\" N \", 'north', \" E \", 'east', \" W \", 'west', \" S \", 'south',\n              \" NE \", 'northeast', \" NW \", 'northwest', \" SE \", 'southeast', \" SW \", 'southwest',\n              \" WSW \", 'west, southwest', \" ESE \", 'east, southeast', \" WNW \", 'west, northwest', \" ENE \", 'east, northeast',\n              \" SSW \", 'south, southwest', \" NNW \", 'north, northwest', \" SSE \", 'south, southeast', \" NNE \", 'north, northeast']\nvar techdata = [];\n\n// Extract strings based on techheaders IE:  <b>Temperature:</b> 4.3&deg;C\nwhile (x < techheaders.length) {\n    if (forecast.indexOf(techheaders[x]) > -1) {\n        tag1 = forecast.indexOf(techheaders[x]);\n        tag2 = forecast.indexOf('<br/>', tag1);\n        techdata[x] = forecast.substring(tag1, tag2);\n        ++x;     }             }\n\n// Is it below zero degrees out?\nif (techdata[0].indexOf(\"-\") > -1) var minus = 'minus '\nelse minus = '';\n\n// Fix wording IE: make 'NNW' into 'north, northwest' and also extract number value from string\nvar value = [], direction; x = 0;\nwhile (x < techdata.length) {\n    word = 0;\n    if (techdata[x].indexOf(\" calm km/h\") > -1) techdata[x] = \" calm \";\n    while (word < winds.length) { if (techdata[x].indexOf(winds[word]) > -1) direction = winds[word + 1]; word = word + 2; }\n    value[x] = getNumber(techdata[x]);   // extract number from string using function above (regEx)\n    ++x;                    }\n                 \n// =======================================   EXTRACT RELEVANT DAILY DATA  ===================================== \nconst period = [\"Sunday:\", \"Sunday night:\", \"Monday:\", \"Monday night:\", \"Tuesday:\", \"Tuesday night:\", \n               \"Wednesday:\", \"Wednesday night:\", \"Thursday:\", \"Thursday night:\", \n               \"Friday:\", \"Friday night:\", \"Saturday:\", \"Saturday night:\" ];\nvar start = [0, 2, 4, 6, 8, 10, 12 ];\nvar report = [];\n\nx = 0, tag1 = 0, tag2 = 0; \nvar dow   = now.getDay(),   // Sun:0, Mon:1 ....  Sat:6\n    day   = start[dow],     // need to start the report[x] array at today, not Sunday, so days are in proper order\n    today = start[dow];     // 'day' gets incremented, need this to do 'today' and 'tomorrow' replacements\n\nwhile ( x < 13  )   {\n    if (forecast.indexOf(period[day]) > -1) { \n        tag1 = forecast.indexOf(period[day]);\n        tag2 = forecast.indexOf('</title>', tag1)  }\n    report[x] = forecast.substring(tag1, tag2);\n    if (report[x].indexOf(period[today]) > -1) report[x] = report[x].replace(period[today], \"Today.\");\n    if (report[x].indexOf(period[today+1]) > -1) report[x] = report[x].replace(period[today+1], \"Tonight.\");\n    if (report[x].indexOf(period[today+2]) > -1) report[x] = report[x].replace(period[today+2], \"Tomorrow.\");\n    if (report[x].indexOf(period[today+3]) > -1) report[x] = report[x].replace(period[today+3], \"Tomorrow night.\");    \n    while (report[x].indexOf(\":\") > -1) { report[x] = report[x].replace(\":\", \", \"); }    \n    ++day;\n    if (day === 14) day = 0; // go now to 'Sunday:'   \n    //node.warn(report[x]);\n    ++x;                       }    \n\n// ----------------------------------------------  CLEAN UP UNUSABLE TEXT  -------------------------------------\nconst fixes = [\"POP\", 'Possibility of precipitation,'];\n\nx = 0;\nwhile (x < report.length)  { \n    word = 0;\n    while (report[x].indexOf(fixes[word]) > -1 ) { report[x] = report[x].replace(fixes[word], fixes[word + 1]); word = word + 2;}\n    if (report[x].charAt(report[x].length - 1) === '%') report[x] = report[x] + '. ';\n    ++x;                   }\n\n// ----------------------------------------------    BUILD THE FORECASTS   --------------------------------------\nvar greeting = 'Good morning everyone. ';\nif (now.getHours() >= 12 && now.getHours() < 18) greeting = 'Good afternoon folks. ';\nif (now.getHours() >= 18 && now.getHours() < 23) greeting = 'Good evening all. ';\n\n// this next bit is just for the forecast given at the exact time a user has set\nvar meridiem = now.getHours() >= 12 ? \" P M\" : \" A M\";\nvar hour     = now.getHours() > 12  ? now.getHours() - 12 : now.getHours();\nif ( context.flow.trigger ===  \"timed_forecast\")   greeting = greeting + 'Here is your ' + hour + meridiem \nelse greeting = greeting + 'Here is the latest ' + location;\n\n// Build the temperature report\nif (value[3] === ' calm ') var temp_string = \"The current temperature in \" + global.get(\"home_town\") + \" is \" + minus + Math.round(value[0]) + \" degrees. \" +\n    \"The humidity is \" + value[2] + \" percent. Currently winds are calm \";\nelse temp_string = \"The current temperature in \" + global.get(\"home_town\") + \" is \" + minus + Math.round(value[0]) + \" degrees. \" +\n    \"The humidity is \" + value[2] + \" percent. and currently \" +\n    \"winds are from the \" + direction + \" at \" + value[3] + \" kilometers per hour \";\n\n// Creative multiple report endings\nvar end1 = \" And that's the current weather story\";    \nvar end2 = \" And that's how it's looking\";\nvar end3 = \" \";\n\n// Build the short range forecast\nvar forecast1 = greeting + \" short range weather forecast. \" + report[0] + \" \" + report[1] + \" \" + report[2] + \" \" + report[3] +\n \" And that's how it looks\";\n\n// Build the long range forcast\nx = 0;\nvar forecast2 = greeting + ' long range weather forecast. ';\nwhile (x < report.length) {\n    forecast2  = forecast2 + \" \" + report[x];\n    if (x > 3) x = x + 2\n    else ++x;             }\n\n\nforecast2 = forecast2 + \" And that's the whole weather story\";\n\n// =============================================   SET UP SPEECH MESSAGE   ======================================\nvar voiceMsg = { speak: \"\", amptime: 10, voice: 'Callie', applause: false, bing: true, node: \"Weather {WX}\" };\n\nif (flow.get(\"r_type\") === 'short') var output = forecast1\nelse output = forecast2; \n\nif ( context.flow.trigger === \"Temperature\" )      voiceMsg.speak = temp_string;  // set in 'Selector' node\nif ( context.flow.trigger ===  \"Forecast\" )        voiceMsg.speak = output;\nif ( context.flow.trigger ===  \"timed_forecast\")   voiceMsg.speak = output;\nif ( context.flow.trigger ===  \"motion_mainfloor\") voiceMsg.speak = output;\n\n// The following RegEx will 1. clear carriage return => space 2. replace multiple spaces by a single one\n// 3. to clear leading and trailing spaces (same as jQuery trim())\nvoiceMsg.speak = voiceMsg.speak.replace(/[\\n\\r]+/g, ' ').replace(/\\s{2,}/g,' ').replace(/^\\s+|\\s+$/,'') ;\nvar toast = {payload: voiceMsg.speak };\nlogMsg = {payload: logTime + '{WF 165} ' +  voiceMsg.speak + \"\\n\\n\"};\nreturn [toast, voiceMsg, logMsg ];\n\n/*\n// Fix words that \"swift\" synthesizer sometimes seems to stumble with.\nwhile (content.indexOf(\"high minus\") > -1) {content = content.replace(\"high minus\", \"high of minus\")}\nwhile (content.indexOf(\"High minus\") > -1) {content = content.replace(\"High minus\", \"High of minus\")}\n*/","outputs":3,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":250,"wires":[[],["efaed0c32255a661"],[]],"outputLabels":["Toast","voiceMsg","logMsg"]},{"id":"cd8ee1cb630163a7","type":"http request","z":"33029ff0c3176c55","name":"Get http XML","method":"GET","ret":"txt","paytoqs":"ignore","url":"{{{link}}}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":430,"y":250,"wires":[["a6278fd5ae65c9e3","fb3d203aca16abc8"]],"info":"Simcoe\r\nhttps://weather.gc.ca/rss/city/on-161_e.xml\r\n\r\nLambton Shores\r\nhttps://weather.gc.ca/rss/city/on-46_e.xml\r\n\r\nPEI\r\nhttps://weather.gc.ca/rss/city/on-27_e.xml\r\n"},{"id":"efaed0c32255a661","type":"debug","z":"33029ff0c3176c55","name":"debug 59","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"speak","targetType":"msg","statusVal":"","statusType":"auto","x":835,"y":270,"wires":[],"l":false},{"id":"345c7ad32ca85bc4","type":"link out","z":"33029ff0c3176c55","name":"Voice to Amp","mode":"link","links":["4ca5302f500ae9c6"],"x":885,"y":230,"wires":[],"l":true},{"id":"251e5416ad975786","type":"ui_toast","z":"33029ff0c3176c55","position":"top right","displayTime":"15","highlight":"red","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":true,"className":"","topic":"Weather Message:","name":"Weather Toast","x":895,"y":190,"wires":[]},{"id":"d91975108ecfd5b3","type":"comment","z":"33029ff0c3176c55","name":"This is the short / long range weather forecast process","info":"","x":515,"y":195,"wires":[]},{"id":"2e4ba7f42c4f29c2","type":"inject","z":"33029ff0c3176c55","name":"Simcoe","props":[{"p":"link","v":"https://weather.gc.ca/rss/city/on-161_e.xml","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":250,"wires":[["eb2d9707390dbe78"]]},{"id":"eb2d9707390dbe78","type":"function","z":"33029ff0c3176c55","name":"Set call type","func":"context.flow.trigger = \"Forecast\";\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":285,"y":250,"wires":[["cd8ee1cb630163a7"]]},{"id":"b345454ef6502bc5","type":"inject","z":"33029ff0c3176c55","name":"Watford","props":[{"p":"link","v":"https://weather.gc.ca/rss/city/on-46_e.xml","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":135,"y":300,"wires":[["eb2d9707390dbe78"]]},{"id":"fb3d203aca16abc8","type":"debug","z":"33029ff0c3176c55","name":"http data","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":595,"y":315,"wires":[]}]

You have 10 while loops in your code (some of them are even nested - yuk).
My money is one of these are a runaway.

A first proof would be to disconnect the highlighted wire - I suspect you will have no issue.

2nd, add some "absolute max" guards in EVERY while loop to see where it goes wrong e.g.

let loop1 = 0
while (something) {
   loop1++
   if (loop1 > 100) { throw new Error('loop 1 is a runaway') }
   // ...
   // ...
   let loop2 = 0
   while (somethingElse) {
      loop2++
      if (loop2 > 100) { throw new Error('loop 2 is a runaway') }
      // ...
      // ...
   }
}

while (x < techheaders.length) {
    if (forecast.indexOf(techheaders[x]) > -1) {
        tag1 = forecast.indexOf(techheaders[x]);
        tag2 = forecast.indexOf('<br/>', tag1);
        techdata[x] = forecast.substring(tag1, tag2);
        ++x;
    }
}

If the if test ever fails that will stick in an infinite loop

You guys are so SMART! Truly appreciate your experience and assistance. I'm still learning how to code js well.

I know there are a lot of while loops in there (and I've had my tribulations with these guys before) but it seemed the simplest and most reliable method to deal with uncertain arrangement of text when parsing. I wrote loop controls (as suggested) and it was loop1 as you suspected Colin.

Thanks so much guys.

Can you explain this code?

context.global.activity_tab = "Weather: ";
context.global.activity_node = "Get latest forecast";
context.global.activity = context.global.activity_tab + context.global.activity_node;

This is not the recommended way to handle context variables, and in my test neither global.something nor context.something get set.

The usual syntax would be eg global.set('activity_tab', 'weather') or for a variable scoped to the node only, context.set('activity_tab', 'weather')

If you look at context data in the right hand column, what global or node scope variables do you see?

I understand your concern and agree. But these are simply to create eye candy, are of no import and exist for seconds only.

I have a "Process Monitor" on my dashboard that shows what my NR app is doing at any given time. These lines are in each node and feed the PM. Here's an example:

Process Monitor

I am wondering why you are not passing the http request return through an xml node to create an object. Surely this would help in using the data returned and simplify the function node considerably.

Output from xml node

{
    "feed": {
        "_": "\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n",
        "$": {
            "xmlns": "http://www.w3.org/2005/Atom",
            "xml:lang": "en-ca"
        },
        "title": [
            "Simcoe - Weather - Environment Canada"
        ],
        "link": [
            {
                "$": {
                    "rel": "related",
                    "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html",
                    "type": "text/html"
                }
            },
            {
                "$": {
                    "rel": "self",
                    "href": "https://weather.gc.ca/rss/city/on-161_e.xml",
                    "type": "application/atom+xml"
                }
            },
            {
                "$": {
                    "rel": "alternate",
                    "hreflang": "fr-ca",
                    "href": "https://meteo.gc.ca/rss/city/on-161_f.xml",
                    "type": "application/atom+xml"
                }
            }
        ],
        "author": [
            {
                "_": "\\n  \\n  \\n",
                "name": [
                    "Environment Canada"
                ],
                "uri": [
                    "https://weather.gc.ca"
                ]
            }
        ],
        "updated": [
            "2024-04-22T16:07:05Z"
        ],
        "id": [
            "tag:weather.gc.ca,2013-04-16:20240422160705"
        ],
        "logo": [
            "https://weather.gc.ca/cacheable/images/img/wmms-alt.png"
        ],
        "icon": [
            "https://weather.gc.ca/template/gcweb/v13.4.0/GCWeb/assets/favicon.ico"
        ],
        "rights": [
            "Copyright 2024, Environment Canada"
        ],
        "entry": [
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "No watches or warnings in effect, Simcoe"
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/index_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-13T10:01:05Z"
                ],
                "published": [
                    "2024-04-13T10:01:05Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Warnings and Watches"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "No watches or warnings in effect.",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_w1:20240413100105"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Current Conditions:  10.7°C"
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T16:00:00Z"
                ],
                "published": [
                    "2024-04-22T16:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Current Conditions"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "\\n    <b>Observed at:</b> Delhi 12:00 PM EDT Monday 22 April 2024<br/> <b>Temperature:</b> 10.7&deg;C<br/> <b>Pressure / Tendency:</b> 102.1 kPa falling<br/> <b>Humidity:</b> 30 %<br/> <b>Dewpoint:</b> -6.4&deg;C<br/> <b>Wind:</b> SW 7 km/h<br/> <b>Air Quality Health Index:</b> n/a<br/>\\n  ",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_cc:20240422160000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Monday: Sunny. High 12."
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Sunny. Wind southwest 20 km/h. High 12. UV index 5 or moderate. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc0:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Monday night: Clear. Low 6."
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Clear. Wind southwest 20 km/h. Low 6. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc1:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Tuesday: Chance of showers. High 13. POP 60%"
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Increasing cloudiness early in the morning. 60 percent chance of showers late in the morning and in the afternoon. Wind southwest 30 km/h gusting to 60. High 13. UV index 4 or moderate. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc2:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Tuesday night: Showers. Low plus 5."
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Showers. Low plus 5. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc3:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Wednesday: Sunny. High 11."
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Sunny. High 11. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc4:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Wednesday night: Clear. Low minus 3."
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Clear. Low minus 3. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc5:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Thursday: Sunny. High 12."
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Sunny. High 12. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc6:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Thursday night: Clear. Low plus 2."
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Clear. Low plus 2. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc7:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Friday: Sunny. High 20."
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Sunny. High 20. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc8:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Friday night: Cloudy. Low 11."
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Increasing cloudiness. Low 11. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc9:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Saturday: Chance of showers. High 21. POP 30%"
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Cloudy with 30 percent chance of showers. High 21. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc10:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Saturday night: Chance of showers. Low 14. POP 30%"
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Cloudy with 30 percent chance of showers. Low 14. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc11:20240422150000"
                ]
            },
            {
                "_": "\\n  \\n  \\n  \\n  \\n  \\n  \\n  \\n",
                "title": [
                    "Sunday: Chance of showers. High 21. POP 30%"
                ],
                "link": [
                    {
                        "$": {
                            "type": "text/html",
                            "href": "https://weather.gc.ca/city/pages/on-161_metric_e.html"
                        }
                    }
                ],
                "updated": [
                    "2024-04-22T15:00:00Z"
                ],
                "published": [
                    "2024-04-22T15:00:00Z"
                ],
                "category": [
                    {
                        "$": {
                            "term": "Weather Forecasts"
                        }
                    }
                ],
                "summary": [
                    {
                        "_": "Cloudy with 30 percent chance of showers. High 21. Forecast issued 11:00 AM EDT Monday 22 April 2024",
                        "$": {
                            "type": "html"
                        }
                    }
                ],
                "id": [
                    "tag:weather.gc.ca,2013-04-16:on-161_fc12:20240422150000"
                ]
            }
        ]
    }
}
1 Like

I think I tried that at some point a while back and had issues with it (or couldn't figure it out), but that's a good point. Perhaps I should try it again.

EDIT:

Nope, never tried it. Don't have an XML node and didn't know one existed. But I see I can install one via the palette manager and will (thank you) and I'll have a go at it.

EDIT2:

That's brilliant! I will rewrite my forecast node(s) to use this. Good bye (most) while loops. Thanks E1cid

That looks like an interesting and useful dashboard.

I just wish I could understand what variables it's using.
Perhaps it is perfectly valid syntax which I'm unfamiliar with, perhaps it relies on the fact that a context variable containing an object is a pointer.
But is it a node scoped variable called "global" or a global scoped variable called "activity_tab"?

It is the latter ... global scoped variable call "activity_tab" . It has to be global so that all tabs can fed the process monitor. There is no doubt however (as you point out) that such a variable is vulnerable.

No, no, no!

There is one built into the core and you should always use those before hunting for a contributed node.

image

If I used that on my live system, the MQTT activity light would stay lit all the time I suspect! :grinning:

But I do output my Telegraf data to MQTT as well as InfluxDB so I do have things like cpu, memory, networking and a lot more available should I want them (though I tend to use Grafana to get those dashboards). Still, perhaps another page is on the horizon for my CYD mini-display.

Lol. I hear you TotallyInformation, and as it happens I did find the core version (too many bloody nodes) and I used it. Don't know why I didn't see it earlier. I think I need to review my palette and trim. The node_modules directory is bloated and my flow file is now 1.1MB.

Mine is 1.8MB with a further 2.8MB of context & 2MB more (discounting the 136MB node_modules folder) for uibuilder. so you are doing OK to be honest. :slight_smile:

Oops! And a 17MB imapfilter.log file probably should tidy that one up!

… though the fastxml node I also wrote produces easier to use object (IMHO).

dceejay I think I'll try it. The core version XML node has my head spinning with the sheer amount and depth of the JSON data it seems to have produced (from a fairly simple XML page I thought).

IE: msg.payload.feed.entry[10].title[0]

Right now looking at the XML node output it doesn't seem it would be less code overall ... I still have to filter most of the JSON strings to what I need for the speaking output.

Almost everything I do results in a voice message for the house overhead speakers and I can tell you trying to produce voice worthy text creates some unique problems. For example, to be voice message friendly it should say "Today .... tonight... tomorrow... tomorrow night... For Wednesday ...." This means I need to have the code determine what day it is, get the weather for that day. label it "today", not Monday (or whatever) and then make sure 2 days weather forecast is Wednesday, not Saturday (the order the XML was built to send it).

Right now managing and cleaning all those deep JSON objects seems like more work then my "while" loops. In a way, I kinda feel like I've created a custom XML (more efficient) parser for my exact needs.

1 Like