Barchart array store/restore error

Hi all,

First of all, what a great forum this is. a lot of helpfull people. I lost count of the number of times I have found my solutions here. Awesome.

Now I face some an issue which I have yet to solve or find a good working solution for here. Hopefully this changes after this first post :slight_smile: My first post.

What am I trying to do.
I am trying to visualize some data in bar charts. To process the data correctly, I am making use of this contrib >> bar-chart-data <<

It generates an array of data, with label, series, data.
I have 2 of these nodes which produces 2 separate arrays (different data). In a function I combine the two results and plot them into 1 chart. This works quite nice.

image

The problem I am facing:
When I reboot, chart empty. Ofcourse, I expected this.
The output / result of the chart I feed into a global variable which I store in "file".
Normally this function works fine. I use it in different places with no issues.

But the problem I face:

  • when I reboot, after injecting the stored data into the chart (this works), then the BarChart node is starting to produce new values again into the Chart. But the bar chart node is not aware of the history, so the history is then wiped again and the chart starts new from that moment.
  • when I reboot, after injecting the stored data into the BarChart node, the output of the bar chart is not as expected. It puts "NaN" at the current time(label) in the data field. After this the bar chart does not recover anymore.

I have been experimenting with JSON to get rid of the NaN by replacing it with '0', but without succes. You can still see this in the flow directly below. But this part is WIP.

This is the code for the combined array chart. It DOES work, only the store/restore function does not.

[
    {
        "id": "1c223a510a8ec72d",
        "type": "group",
        "z": "ed155b604642d354",
        "style": {
            "stroke": "#999999",
            "stroke-opacity": "1",
            "fill": "none",
            "fill-opacity": "1",
            "label": true,
            "label-position": "nw",
            "color": "#a4a4a4"
        },
        "nodes": [
            "cff31036dc296d8d",
            "d8e8398aee81f6d9",
            "abb3add343d1bea2",
            "41bc927c7f5116b1",
            "757d35eee93ec9e7",
            "2391637fadbbf190",
            "7629b6d3d87712ff",
            "e9d6a960b09e05b8",
            "04b73283ee604dc3",
            "9863257fecbb7ee9",
            "2e566db9a4542376",
            "11df84f0b8499381",
            "ab16835d95c2c933",
            "5f083401791b752a",
            "8564c26fce347ddc",
            "39f46b5fe56dc0a6",
            "e48537c319b7f2ca",
            "5e60c25489fc6f98",
            "74f840e183c2ca78",
            "e6ea853dc5ace9bb"
        ],
        "x": 54,
        "y": 819,
        "w": 1672,
        "h": 402
    },
    {
        "id": "cff31036dc296d8d",
        "type": "bar-chart-data",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "bar-chart-data degreedays-31d",
        "x_interval": "days",
        "x_size": "31",
        "unit": "",
        "precision": "2",
        "is_meter_reading": "False",
        "agg_by": "avg",
        "x": 630,
        "y": 940,
        "wires": [
            [
                "ab16835d95c2c933"
            ]
        ]
    },
    {
        "id": "d8e8398aee81f6d9",
        "type": "bar-chart-data",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "bar-chart-data kwh-31d",
        "x_interval": "days",
        "x_size": "31",
        "unit": "",
        "precision": 2,
        "is_meter_reading": "False",
        "agg_by": "sum",
        "x": 610,
        "y": 900,
        "wires": [
            [
                "e48537c319b7f2ca"
            ]
        ]
    },
    {
        "id": "abb3add343d1bea2",
        "type": "ui_chart",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "group": "87be08e6a82ef6a0",
        "order": 8,
        "width": 0,
        "height": 0,
        "label": "DegreeDays vs Power consumption",
        "chartType": "bar",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#d62728",
            "#aec7e8",
            "#98df8a",
            "#d62728",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1360,
        "y": 1100,
        "wires": [
            [
                "9863257fecbb7ee9"
            ]
        ]
    },
    {
        "id": "41bc927c7f5116b1",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Store information kwh_31d",
        "func": "var myArray4 = msg.payload;\nglobal.set(\"kwh_31d\", myArray4,\"file\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1580,
        "y": 900,
        "wires": [
            []
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "757d35eee93ec9e7",
        "type": "inject",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "900",
        "crontab": "",
        "once": false,
        "onceDelay": "0.1",
        "topic": "trigger",
        "x": 180,
        "y": 1080,
        "wires": [
            [
                "2391637fadbbf190"
            ]
        ]
    },
    {
        "id": "2391637fadbbf190",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "DATA (kWh + DegreeDays) Chart Creation",
        "func": "var myArray1 = global.get(\"kwh_31d\",\"file\");\nvar myArray2 = global.get(\"degreedays_31d\",\"file\");\nlet msg1={}, msg2={};\nmsg1.payload = myArray1;\nmsg2.payload = myArray2;\n\nvar varlabels = msg1.payload[0].labels;\nvar varkwh_data         = msg1.payload[0].data[0];\nvar vargraaddagen_data  = msg2.payload[0].data[0];\nvar m={};\n    m.labels    = varlabels;\n    m.series    = ['DegreeDays (°C)', 'Energy consumption HEAT (kWh)'];\n    m.data      = [vargraaddagen_data, varkwh_data];\n\nreturn {payload:[m]};\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 430,
        "y": 1080,
        "wires": [
            [
                "5f083401791b752a"
            ]
        ],
        "outputLabels": [
            "graaddagen_calc"
        ]
    },
    {
        "id": "7629b6d3d87712ff",
        "type": "link in",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "links": [
            "2064b5a11ffc43b3"
        ],
        "x": 115,
        "y": 940,
        "wires": [
            [
                "cff31036dc296d8d"
            ]
        ]
    },
    {
        "id": "e9d6a960b09e05b8",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Store information degreedays_31d",
        "func": "var myArray5 = msg.payload;\nglobal.set(\"degreedays_31d\", myArray5,\"file\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1560,
        "y": 940,
        "wires": [
            []
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "04b73283ee604dc3",
        "type": "inject",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "RESET",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[ ]",
        "payloadType": "json",
        "x": 150,
        "y": 1180,
        "wires": [
            [
                "abb3add343d1bea2"
            ]
        ]
    },
    {
        "id": "9863257fecbb7ee9",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Store information",
        "func": "\nvar myArray6 = msg.payload;\nglobal.set(\"barchart_kwh_degreedays_31d\", myArray6,\"file\");\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1610,
        "y": 1100,
        "wires": [
            []
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "2e566db9a4542376",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Load information",
        "func": "var myArray6 = global.get(\"barchart_kwh_degreedays_31d\",\"file\");\n\nmsg.payload = myArray6;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 1120,
        "wires": [
            [
                "7014e347bfa57006"
            ]
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "11df84f0b8499381",
        "type": "inject",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "300",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "topic": "trigger",
        "x": 160,
        "y": 900,
        "wires": [
            [
                "8564c26fce347ddc"
            ]
        ]
    },
    {
        "id": "ab16835d95c2c933",
        "type": "delay",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 860,
        "y": 940,
        "wires": [
            [
                "e9d6a960b09e05b8"
            ]
        ]
    },
    {
        "id": "5f083401791b752a",
        "type": "delay",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 680,
        "y": 1080,
        "wires": [
            [
                "7014e347bfa57006"
            ]
        ]
    },
    {
        "id": "8564c26fce347ddc",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Load information",
        "func": "var myArray4 = global.get(\"kwh_31d\",\"file\");\n\nmsg.payload = myArray4;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 370,
        "y": 900,
        "wires": [
            [
                "d8e8398aee81f6d9"
            ]
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "39f46b5fe56dc0a6",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Load information",
        "func": "var myArray5 = global.get(\"degreedays_31d\",\"file\");\n\nmsg.payload = myArray5;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 370,
        "y": 980,
        "wires": [
            [
                "cff31036dc296d8d"
            ]
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "e48537c319b7f2ca",
        "type": "delay",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 860,
        "y": 900,
        "wires": [
            [
                "41bc927c7f5116b1"
            ]
        ]
    },
    {
        "id": "5e60c25489fc6f98",
        "type": "inject",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Load on boot",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "0.1",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 170,
        "y": 1120,
        "wires": [
            [
                "2e566db9a4542376"
            ]
        ]
    },
    {
        "id": "74f840e183c2ca78",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "W to kWh conversion",
        "func": "msg1 = {};\nmsg2 = {};\nmsg3 = {};\nmsg4 = {};\nmsg5 = {};\n\nvar CurrentTime = new Date().getTime();\nvar PreviousTime = flow.get(\"PreviousTime\");\nvar PreviousMessage = flow.get(\"PreviousMessage\");\nvar PreviousTopic = flow.get(\"PreviousTopic\");\nvar LastMessage = msg.payload;\nvar LastTopic= msg.topic;\n\n if (PreviousTime === \"undefined\") {\nflow.set('PreviousTime',CurrentTime);\n\n   \n}\n\nelse {\nTimeElapsed = ((CurrentTime - PreviousTime)/1000);\nflow.set('PreviousTime',CurrentTime);\nflow.set('PreviousMessage',msg.payload);\nflow.set('PreviousTopic',msg.topic);\nmsg3.last = {\"lastTime\":CurrentTime,\"LastMessage\":LastMessage,\"LastTopic\":LastTopic};\nmsg3.Previous = {\"PreviousTime\":PreviousTime,\"PreviousMessage\":PreviousMessage,\"PreviousTopic\":PreviousTopic};\n\n\nmsg1.payload = (TimeElapsed + \"  Seconds\");\ntemp = parseFloat(TimeElapsed.toFixed(0));\nmsg2.payload = temp;\nmsg3.payload = {\"Count\":temp,\"Units\":\"Seconds\"}; \nmsg5.payload = (PreviousMessage * ( temp / 3600000 ));   //  Calculation to Wh portion\nNumber(msg5.payload).toFixed(2);\nmsg5.topic = 'Energy_Consumption_HEAT_kWh';\n   }\n   \nreturn msg5;\n \n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 860,
        "wires": [
            [
                "d8e8398aee81f6d9"
            ]
        ],
        "outputLabels": [
            "Energy_Consumption_HEAT_kWh"
        ],
        "icon": "node-red/timer.png"
    },
    {
        "id": "e6ea853dc5ace9bb",
        "type": "link in",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "links": [
            "9de1bde370b68508"
        ],
        "x": 125,
        "y": 860,
        "wires": [
            [
                "74f840e183c2ca78"
            ]
        ]
    },
    {
        "id": "87be08e6a82ef6a0",
        "type": "ui_group",
        "name": "Degree days information",
        "tab": "a681244e6db9a6a7",
        "order": 1,
        "disp": true,
        "width": "15",
        "collapse": false,
        "className": ""
    },
    {
        "id": "a681244e6db9a6a7",
        "type": "ui_tab",
        "name": "Degree Days",
        "icon": "dashboard",
        "order": 11,
        "disabled": false,
        "hidden": false
    }
]

As an other example on the minimalistic approach I had, see the flow below.

[
    {
        "id": "332197c8279cef3a",
        "type": "group",
        "z": "ed155b604642d354",
        "g": "8a294a78bd96d1ac",
        "name": "Chart Past month + Store variables",
        "style": {
            "label": true
        },
        "nodes": [
            "e7b37912a947c1c3",
            "c335ac3c4a8f1e0c",
            "6e6937d8bda7e168",
            "50e098756084f59a",
            "2cc78bac6057732d",
            "e64edede4c04268f",
            "fdcbec7c08cde234"
        ],
        "x": 104,
        "y": 239,
        "w": 1622,
        "h": 122
    },
    {
        "id": "e7b37912a947c1c3",
        "type": "bar-chart-data",
        "z": "ed155b604642d354",
        "g": "332197c8279cef3a",
        "name": "bar-chart-data2",
        "x_interval": "days",
        "x_size": "31",
        "unit": "",
        "precision": "1",
        "is_meter_reading": "False",
        "agg_by": "avg",
        "x": 620,
        "y": 280,
        "wires": [
            [
                "2cc78bac6057732d"
            ]
        ]
    },
    {
        "id": "c335ac3c4a8f1e0c",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "332197c8279cef3a",
        "name": "Load information",
        "func": "var myArray1 = global.get(\"chart_month\",\"file\");\n\nmsg.payload = myArray1;\nmsg.topic = \"graaddagen_calc\";\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 410,
        "y": 320,
        "wires": [
            [
                "e7b37912a947c1c3"
            ]
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "6e6937d8bda7e168",
        "type": "inject",
        "z": "ed155b604642d354",
        "g": "332197c8279cef3a",
        "name": "Load on boot",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "2",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 320,
        "wires": [
            [
                "c335ac3c4a8f1e0c"
            ]
        ]
    },
    {
        "id": "50e098756084f59a",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "332197c8279cef3a",
        "name": "Store information",
        "func": "\nvar myArray1 = msg.payload;\nglobal.set(\"chart_month\", myArray1,\"file\");\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1610,
        "y": 280,
        "wires": [
            []
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "2cc78bac6057732d",
        "type": "ui_chart",
        "z": "ed155b604642d354",
        "g": "332197c8279cef3a",
        "name": "",
        "group": "87be08e6a82ef6a0",
        "order": 5,
        "width": 15,
        "height": 5,
        "label": "Past 31 days",
        "chartType": "bar",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "0",
        "ymax": "20",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": true,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1410,
        "y": 280,
        "wires": [
            [
                "50e098756084f59a"
            ]
        ]
    },
    {
        "id": "e64edede4c04268f",
        "type": "link in",
        "z": "ed155b604642d354",
        "g": "332197c8279cef3a",
        "name": "",
        "links": [
            "2064b5a11ffc43b3"
        ],
        "x": 165,
        "y": 280,
        "wires": [
            [
                "fdcbec7c08cde234"
            ]
        ]
    },
    {
        "id": "fdcbec7c08cde234",
        "type": "delay",
        "z": "ed155b604642d354",
        "g": "332197c8279cef3a",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 380,
        "y": 280,
        "wires": [
            [
                "e7b37912a947c1c3"
            ]
        ]
    },
    {
        "id": "87be08e6a82ef6a0",
        "type": "ui_group",
        "name": "Degree days information",
        "tab": "a681244e6db9a6a7",
        "order": 1,
        "disp": true,
        "width": "15",
        "collapse": false,
        "className": ""
    },
    {
        "id": "a681244e6db9a6a7",
        "type": "ui_tab",
        "name": "Degree Days",
        "icon": "dashboard",
        "order": 11,
        "disabled": false,
        "hidden": false
    }
]

An example of how the data looks like, fed to the chart, see code below:

[{"labels":["03-13","03-14","03-15","03-16","03-17","03-18","03-19","03-20","03-21","03-22","03-23","03-24","03-25","03-26","03-27","03-28","03-29","03-30","03-31","04-01","04-02","04-03","04-04","04-05","04-06","04-07","04-08","04-09","04-10","04-11","04-12"],"series":["DegreeDays (°C)","Energy consumption HEAT (kWh)"],"data":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11.98,8.79,6.93],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.13,4.62,3.18]]}]

I know the difference between time based measurement points, and a complete array.
I fear this is what is throwing me off here.
A chart with plain lines (time based values) can easilly be restored.
A chart with an array can be restored as well. But the combination BarChart node > Chart is the current challenge in this case.

To motivate why I use the BarChart node;
I really like the function to calculate the average per x-category, minute/hour/day. Also in kWh calculations I can use the sum function in it to add all partial kWh measurements so it adds up to a correct value per day.

If I need to get rid of this node, I need to create a function which does this calculation on a collection of datapoints in each time cagetory (x-axis).
Also in this node, the logic suits my goal, that the x-category is like a bucket that gets filled. This is different to default chart/logic. The start and cut-off per bucket is often not how I require it.

Does anybody have a good suggestion? or am I missing something that I am doing wrong :slight_smile:
I read in the barchart contrib faq there is a restore function as well, but I dont understand it, or got it to work.

Many thanks in advance for any help.

Hi,
I dont want to push my post on top again.
But I cant edit the post anymore it seems.
also, I think I have made the post too big and difficult to understand/follow. At least I think due to the lack of response.

Basically, my issue is:
Upon restore data into charts, I get NaN.

Hope someone is able to help. :slight_smile:

If the bar chart data node accepts numbers, then feeding in an object would create a NaN. I think you would need to create a function yourself to restore the data to the chart and add new incoming data.
If you need help with this, best supply samples of incoming data, and how you wish it to outputted.

1 Like

Thank you very much for your reply E1cid !! :slight_smile:

I think you are right about the cause. I have cleaned up the code a bit to make it clear.

In the above image you can see I have tidied up the function / code a bit.
In yellow and blue the 2 sources are conditioned and fed to the barchart node to create the buckets with data. Below that, the combination of the two buckets is done.

(1) Bucket 1 debugger:

[{"labels":["03-20","03-21","03-22","03-23","03-24","03-25","03-26","03-27","03-28","03-29","03-30","03-31","04-01","04-02","04-03","04-04","04-05","04-06","04-07","04-08","04-09","04-10","04-11","04-12","04-13","04-14","04-15","04-16","04-17","04-18","04-19"],"series":["Energy_Consumption_HEAT_kWh"],"data":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]}]

*** Note: the data says all 0,0,0,0,0.... I just deleted historical data, and there is no power usage now.*

(2) Bucket 2 debugger:

[{"labels":["03-20","03-21","03-22","03-23","03-24","03-25","03-26","03-27","03-28","03-29","03-30","03-31","04-01","04-02","04-03","04-04","04-05","04-06","04-07","04-08","04-09","04-10","04-11","04-12","04-13","04-14","04-15","04-16","04-17","04-18","04-19"],"series":["graaddagen_calc"],"data":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6.05,5.19]]}]

(3) Combined debugger:

[{"labels":["03-20","03-21","03-22","03-23","03-24","03-25","03-26","03-27","03-28","03-29","03-30","03-31","04-01","04-02","04-03","04-04","04-05","04-06","04-07","04-08","04-09","04-10","04-11","04-12","04-13","04-14","04-15","04-16","04-17","04-18","04-19"],"series":["DegreeDays (°C)","Energy consumption HEAT (kWh)"],"data":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6.05,5.19],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]}]

So what I think what I need to do, is to take the output of (3), get the latest value of only the current bucket, and push that to the chart node to create a timeline series. Those are easily stored / restored.
Am I right?

For reference, here is the complete flow of what you see in the image.

[
    {
        "id": "1c223a510a8ec72d",
        "type": "group",
        "z": "ed155b604642d354",
        "name": "Combined bar-chart",
        "style": {
            "label": true
        },
        "nodes": [
            "757d35eee93ec9e7",
            "2391637fadbbf190",
            "9863257fecbb7ee9",
            "305c8ef765dff998",
            "6472e1e423188a37",
            "41e8d01708c19225",
            "2fefa5d6e0e950ac",
            "4eaa2cfa2749c551",
            "3ce36bc606018d50"
        ],
        "x": 88,
        "y": 913,
        "w": 1784,
        "h": 468
    },
    {
        "id": "757d35eee93ec9e7",
        "type": "inject",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "900",
        "crontab": "",
        "once": false,
        "onceDelay": "0.1",
        "topic": "trigger",
        "x": 220,
        "y": 1300,
        "wires": [
            [
                "2391637fadbbf190"
            ]
        ]
    },
    {
        "id": "2391637fadbbf190",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Function - bucket 1 + 2 combined",
        "func": "var myArray1 = global.get(\"kwh_31d\",\"file\");\nvar myArray2 = global.get(\"degreedays_31d\",\"file\");\nlet msg1={}, msg2={};\nmsg1.payload = myArray1;\nmsg2.payload = myArray2;\n\nvar varlabels = msg1.payload[0].labels;\nvar varkwh_data         = msg1.payload[0].data[0];\nvar vargraaddagen_data  = msg2.payload[0].data[0];\nvar m={};\n    m.labels    = varlabels;\n    m.series    = ['DegreeDays (°C)', 'Energy consumption HEAT (kWh)'];\n    m.data      = [vargraaddagen_data, varkwh_data];\n\nreturn {payload:[m]};\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 1300,
        "wires": [
            [
                "9863257fecbb7ee9",
                "305c8ef765dff998",
                "4eaa2cfa2749c551"
            ]
        ],
        "outputLabels": [
            "graaddagen_calc"
        ]
    },
    {
        "id": "9863257fecbb7ee9",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Store combined barchart to [barchart_kwh_degreedays_31d]",
        "func": "\nvar myArray6 = msg.payload;\nglobal.set(\"barchart_kwh_degreedays_31d\", myArray6,\"file\");\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 960,
        "y": 1300,
        "wires": [
            []
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "305c8ef765dff998",
        "type": "debug",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 810,
        "y": 1340,
        "wires": []
    },
    {
        "id": "6472e1e423188a37",
        "type": "group",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Bucket 2 - Degree days calculation",
        "style": {
            "fill": "#bfdbef",
            "label": true
        },
        "nodes": [
            "cff31036dc296d8d",
            "7629b6d3d87712ff",
            "e9d6a960b09e05b8",
            "ebb1f055b317a1a0"
        ],
        "x": 114,
        "y": 1079,
        "w": 1732,
        "h": 102
    },
    {
        "id": "cff31036dc296d8d",
        "type": "bar-chart-data",
        "z": "ed155b604642d354",
        "g": "6472e1e423188a37",
        "name": "bar-chart-data degreedays-31d",
        "x_interval": "days",
        "x_size": "31",
        "unit": "",
        "precision": "2",
        "is_meter_reading": "False",
        "agg_by": "avg",
        "x": 870,
        "y": 1140,
        "wires": [
            [
                "ebb1f055b317a1a0",
                "e9d6a960b09e05b8"
            ]
        ]
    },
    {
        "id": "7629b6d3d87712ff",
        "type": "link in",
        "z": "ed155b604642d354",
        "g": "6472e1e423188a37",
        "name": "",
        "links": [
            "2064b5a11ffc43b3"
        ],
        "x": 155,
        "y": 1120,
        "wires": [
            [
                "cff31036dc296d8d"
            ]
        ]
    },
    {
        "id": "e9d6a960b09e05b8",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "6472e1e423188a37",
        "name": "Store information to degreedays_31d",
        "func": "var myArray5 = msg.payload;\nglobal.set(\"degreedays_31d\", myArray5,\"file\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1670,
        "y": 1120,
        "wires": [
            []
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "ebb1f055b317a1a0",
        "type": "debug",
        "z": "ed155b604642d354",
        "g": "6472e1e423188a37",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1110,
        "y": 1140,
        "wires": []
    },
    {
        "id": "41e8d01708c19225",
        "type": "comment",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Bucket 1 + 2 combined to chart",
        "info": "",
        "x": 270,
        "y": 1260,
        "wires": []
    },
    {
        "id": "2fefa5d6e0e950ac",
        "type": "ui_chart",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "group": "87be08e6a82ef6a0",
        "order": 4,
        "width": 0,
        "height": 0,
        "label": "Chart - kWh + Degree Days (31d)",
        "chartType": "bar",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#ad1625",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 880,
        "y": 1260,
        "wires": [
            []
        ]
    },
    {
        "id": "4eaa2cfa2749c551",
        "type": "ui_chart",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "group": "87be08e6a82ef6a0",
        "order": 4,
        "width": 0,
        "height": 0,
        "label": "Chart - kWh + Degree Days (31d)",
        "chartType": "bar",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#ad1625",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 880,
        "y": 1260,
        "wires": [
            []
        ]
    },
    {
        "id": "3ce36bc606018d50",
        "type": "group",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Bucket 1 - kWh calculation",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "550d61dd1ac867d3",
            "41bc927c7f5116b1",
            "74f840e183c2ca78",
            "e6ea853dc5ace9bb",
            "a55f6f90370f8fee"
        ],
        "x": 114,
        "y": 939,
        "w": 1732,
        "h": 102
    },
    {
        "id": "550d61dd1ac867d3",
        "type": "bar-chart-data",
        "z": "ed155b604642d354",
        "g": "3ce36bc606018d50",
        "name": "bar-chart-data kwh-31d",
        "x_interval": "days",
        "x_size": "31",
        "unit": "",
        "precision": 2,
        "is_meter_reading": "False",
        "agg_by": "sum",
        "x": 850,
        "y": 1000,
        "wires": [
            [
                "a55f6f90370f8fee",
                "41bc927c7f5116b1"
            ]
        ]
    },
    {
        "id": "41bc927c7f5116b1",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "3ce36bc606018d50",
        "name": "Store information to kwh_31d",
        "func": "var myArray4 = msg.payload;\nglobal.set(\"kwh_31d\", myArray4,\"file\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1700,
        "y": 1000,
        "wires": [
            []
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "74f840e183c2ca78",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "3ce36bc606018d50",
        "name": "W to kWh conversion",
        "func": "msg1 = {};\nmsg2 = {};\nmsg3 = {};\nmsg4 = {};\nmsg5 = {};\n\nvar CurrentTime = new Date().getTime();\nvar PreviousTime = flow.get(\"PreviousTime\");\nvar PreviousMessage = flow.get(\"PreviousMessage\");\nvar PreviousTopic = flow.get(\"PreviousTopic\");\nvar LastMessage = msg.payload;\nvar LastTopic= msg.topic;\n\n if (PreviousTime === \"undefined\") {\nflow.set('PreviousTime',CurrentTime);\n\n   \n}\n\nelse {\nTimeElapsed = ((CurrentTime - PreviousTime)/1000);\nflow.set('PreviousTime',CurrentTime);\nflow.set('PreviousMessage',msg.payload);\nflow.set('PreviousTopic',msg.topic);\nmsg3.last = {\"lastTime\":CurrentTime,\"LastMessage\":LastMessage,\"LastTopic\":LastTopic};\nmsg3.Previous = {\"PreviousTime\":PreviousTime,\"PreviousMessage\":PreviousMessage,\"PreviousTopic\":PreviousTopic};\n\n\nmsg1.payload = (TimeElapsed + \"  Seconds\");\ntemp = parseFloat(TimeElapsed.toFixed(0));\nmsg2.payload = temp;\nmsg3.payload = {\"Count\":temp,\"Units\":\"Seconds\"}; \nmsg5.payload = (PreviousMessage * ( temp / 3600000 ));   //  Calculation to Wh portion\nNumber(msg5.payload).toFixed(2);\nmsg5.topic = 'Energy_Consumption_HEAT_kWh';\n   }\n   \nreturn msg5;\n \n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 1000,
        "wires": [
            [
                "550d61dd1ac867d3"
            ]
        ],
        "outputLabels": [
            "Energy_Consumption_HEAT_kWh"
        ],
        "icon": "node-red/timer.png"
    },
    {
        "id": "e6ea853dc5ace9bb",
        "type": "link in",
        "z": "ed155b604642d354",
        "g": "3ce36bc606018d50",
        "name": "",
        "links": [
            "9de1bde370b68508"
        ],
        "x": 155,
        "y": 1000,
        "wires": [
            [
                "74f840e183c2ca78"
            ]
        ]
    },
    {
        "id": "a55f6f90370f8fee",
        "type": "debug",
        "z": "ed155b604642d354",
        "g": "3ce36bc606018d50",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1110,
        "y": 980,
        "wires": []
    },
    {
        "id": "87be08e6a82ef6a0",
        "type": "ui_group",
        "name": "Degree days information",
        "tab": "a681244e6db9a6a7",
        "order": 1,
        "disp": true,
        "width": "15",
        "collapse": false,
        "className": ""
    },
    {
        "id": "a681244e6db9a6a7",
        "type": "ui_tab",
        "name": "Degree Days",
        "icon": "dashboard",
        "order": 11,
        "disabled": false,
        "hidden": false
    }
]

Can i see a sample of the incoming live data, and how often it comes.

I do not use the bar chart data node, How is it preparing the data is it totaling it over x days?

I would right a function/flow to do the bar chart data nodes function. Maybe adding incoming new data to stored data daily.

This will be quite the challange I think. It is the 'difficult' route. But maybe the best/robust one as well.

There are two source:

1: Current power usage - source mqtt. frequncy is random. anything from 30seconds - 2 minutes.
2: Outside temp coming from darksky. Tte temperature is converted to a degreeday value (= 18 - Tvalue) everytime a value changes. This is stored in a global variable and used below (2)

For (1), I convert W > kWh. I take timestamp of current and previous value, and with that I calculate the kWh portion. The barchart node has the option to SUM all values into a bucket, which gives me the kWh consumption per hour or day.

For (2) I just need the average value of that day. So I produce (from trigger 1 value / 5 minutes) values and the barchart averages this and puts it into the bucket of today.

Sample of the incomming data:
(1) - kWh

19-4-2022 21:52:58node: 8175b7938e10de57
Energy_Consumption_HEAT_kWh : msg.payload : number
0

(2) the degreedays value

19-4-2022 21:52:44node: a5c23e1d09ab1a02
graaddagen_calc : msg.payload : number
4.300000000000001

Just to note and express my worry;
I have tried regular charts without the bar-chart node.
The strange behaviour I saw was that the average value of Tuesday ended up in the chart as Wednesday. It think this is a timing thing when the result is added to the X-axis. At the start of the day, or at the end of the day. The bar chart does this correclty in the array. This is why I ended up with using bar-chart.

@E1cid

https://flows.nodered.org/node/node-red-contrib-dashboard-bar-chart-data

There is a store / restore function which should work. It is written here.

Restore

If you put the output of this node to the input of this kind of node (via persist node ), the data will be restored. This could be helpful to avoid getting a blank bar-chart after node-red has been restarted (reboot).

Logfiles to bar-chart

If msg.ts or msg.timestamp is given, this timestamp will be used for the reading instead of the current timestamp. You could use this feature to load (older) logfiles into bar-chart data. Caution: All values older than the given timestamp will be discarded => You have to start with the oldest value and will loose all values that are not inside the log files - except the current values are older than the ones from the logfile.

But I was unable to get this to work.
IF this is working, then maybe al lot of the difficult rewriting is not needed anyway.

I am running node red in docker and I could not get it working. It was not persistant or restoring.
I do have global variables in "file" working propperly and persistantly.

So you should be able to restore the individual barchart data nodes from context then delay a short time and then restore ui-chart

try this

[{"id":"250f5cd5.a81994","type":"function","z":"bf9e1e33.030598","name":"W to kWh conversion","func":"msg1 = {};\nmsg2 = {};\nmsg3 = {};\nmsg4 = {};\nmsg5 = {};\n\nvar CurrentTime = new Date().getTime();\nvar PreviousTime = flow.get(\"PreviousTime\");\nvar PreviousMessage = flow.get(\"PreviousMessage\");\nvar PreviousTopic = flow.get(\"PreviousTopic\");\nvar LastMessage = msg.payload;\nvar LastTopic= msg.topic;\n\n if (PreviousTime === \"undefined\") {\nflow.set('PreviousTime',CurrentTime);\n\n   \n}\n\nelse {\nTimeElapsed = ((CurrentTime - PreviousTime)/1000);\nflow.set('PreviousTime',CurrentTime);\nflow.set('PreviousMessage',msg.payload);\nflow.set('PreviousTopic',msg.topic);\nmsg3.last = {\"lastTime\":CurrentTime,\"LastMessage\":LastMessage,\"LastTopic\":LastTopic};\nmsg3.Previous = {\"PreviousTime\":PreviousTime,\"PreviousMessage\":PreviousMessage,\"PreviousTopic\":PreviousTopic};\n\n\nmsg1.payload = (TimeElapsed + \"  Seconds\");\ntemp = parseFloat(TimeElapsed.toFixed(0));\nmsg2.payload = temp;\nmsg3.payload = {\"Count\":temp,\"Units\":\"Seconds\"}; \nmsg5.payload = (PreviousMessage * ( temp / 3600000 ));   //  Calculation to Wh portion\nNumber(msg5.payload).toFixed(2);\nmsg5.topic = 'Energy_Consumption_HEAT_kWh';\n   }\n   \nreturn msg5;\n \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":1020,"wires":[["96359052.baeb3"]],"outputLabels":["Energy_Consumption_HEAT_kWh"],"icon":"node-red/timer.png"},{"id":"5fae8ec8.9663c","type":"link in","z":"bf9e1e33.030598","name":"","links":["9de1bde370b68508"],"x":135,"y":1020,"wires":[["250f5cd5.a81994"]]},{"id":"96359052.baeb3","type":"bar-chart-data","z":"bf9e1e33.030598","g":"3ce36bc606018d50","name":"bar-chart-data kwh-31d","x_interval":"days","x_size":"31","unit":"","precision":2,"is_meter_reading":"False","agg_by":"sum","x":690,"y":1020,"wires":[["8820703b.4347a","757ff989.9f929"]]},{"id":"1b19ba10.fa9d16","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"kwh_31d","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":1460,"wires":[["11f71f2a.f6d511","96359052.baeb3"]]},{"id":"8820703b.4347a","type":"debug","z":"bf9e1e33.030598","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":960,"wires":[]},{"id":"757ff989.9f929","type":"function","z":"bf9e1e33.030598","name":"Store information to kwh_31d","func":"var myArray4 = msg.payload;\nglobal.set(\"kwh_31d\", myArray4,\"file\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":1020,"wires":[[]],"outputLabels":["graaddagen 24h"]},{"id":"d369f75e.b41d58","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":330,"y":1460,"wires":[["1b19ba10.fa9d16"]]},{"id":"11f71f2a.f6d511","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"degreedays_31d","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":1460,"wires":[["aeef37b5.73088","44cd10df.6a017"]]},{"id":"aeef37b5.73088","type":"delay","z":"bf9e1e33.030598","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1000,"y":1460,"wires":[["3141d38b.a79cbc"]]},{"id":"44cd10df.6a017","type":"bar-chart-data","z":"bf9e1e33.030598","g":"6472e1e423188a37","name":"bar-chart-data degreedays-31d","x_interval":"days","x_size":"31","unit":"","precision":"2","is_meter_reading":"False","agg_by":"avg","x":430,"y":1140,"wires":[["a5e2ca50.8c776","f41534c3.9dab1"]]},{"id":"3141d38b.a79cbc","type":"function","z":"bf9e1e33.030598","name":"Function - bucket 1 + 2 combined","func":"var myArray1 = global.get(\"kwh_31d\",\"file\");\nvar myArray2 = global.get(\"degreedays_31d\",\"file\");\nlet msg1={}, msg2={};\nmsg1.payload = myArray1;\nmsg2.payload = myArray2;\n\nvar varlabels = msg1.payload[0].labels;\nvar varkwh_data         = msg1.payload[0].data[0];\nvar vargraaddagen_data  = msg2.payload[0].data[0];\nvar m={};\n    m.labels    = varlabels;\n    m.series    = ['DegreeDays (°C)', 'Energy consumption HEAT (kWh)'];\n    m.data      = [vargraaddagen_data, varkwh_data];\n\nreturn {payload:[m]};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":1320,"wires":[["5541c491.2a4adc","1e90e92f.84ec8f","98ccc7.d3bde338"]],"outputLabels":["graaddagen_calc"]},{"id":"1fa08d1d.2609d3","type":"link in","z":"bf9e1e33.030598","name":"","links":["2064b5a11ffc43b3"],"x":185,"y":1140,"wires":[["44cd10df.6a017"]]},{"id":"a5e2ca50.8c776","type":"debug","z":"bf9e1e33.030598","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":1200,"wires":[]},{"id":"f41534c3.9dab1","type":"function","z":"bf9e1e33.030598","name":"Store information to degreedays_31d","func":"var myArray5 = msg.payload;\nglobal.set(\"degreedays_31d\", myArray5,\"file\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":900,"y":1120,"wires":[[]],"outputLabels":["graaddagen 24h"]},{"id":"26fe9626.1fffa2","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"900","crontab":"","once":false,"onceDelay":"0.1","topic":"trigger","payloadType":"str","x":250,"y":1320,"wires":[["3141d38b.a79cbc"]]},{"id":"5541c491.2a4adc","type":"function","z":"bf9e1e33.030598","name":"Store combined barchart to [barchart_kwh_degreedays_31d]","func":"\nvar myArray6 = msg.payload;\nglobal.set(\"barchart_kwh_degreedays_31d\", myArray6,\"file\");\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":1320,"wires":[[]],"outputLabels":["graaddagen 24h"]},{"id":"1e90e92f.84ec8f","type":"debug","z":"bf9e1e33.030598","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":840,"y":1360,"wires":[]},{"id":"98ccc7.d3bde338","type":"ui_chart","z":"bf9e1e33.030598","name":"","group":"b498a01f.25c518","order":4,"width":0,"height":0,"label":"Chart - kWh + Degree Days (31d)","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#ad1625","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":910,"y":1280,"wires":[[]]},{"id":"b498a01f.25c518","type":"ui_group","name":"Degree days information","tab":"a681244e6db9a6a7","order":1,"disp":true,"width":"15","collapse":false,"className":""},{"id":"a681244e6db9a6a7","type":"ui_tab","name":"Degree Days","icon":"dashboard","order":11,"disabled":false,"hidden":false}]

Thank you for your time spent!!! Very much appreciated. :blush:
I imported your flow.
I see two things now working as you expected.

Values from the set.payload nodes are pushed to the barchart node. The output of the barchart still contains NaN.
Values from the real measurements are pushed to the barchard node. the output of these values are a new array.

20-4-2022 20:26:18node: 472a7bae1e7e22f6
graaddagen_calc : msg.payload : array[1]
array[1]
 0: object
 labels: array[31]
 series: array[2]
 data: array[2]
  0: array[31]
    [0 … 9]
    [10 … 19]
    [20 … 29]
    [30 … 30]
      30: NaN
  1: array[31]
    [0 … 9]
    [10 … 19]
    [20 … 29]
    [30 … 30]
      30: 3.8

Maybe there is some syntax needed to the timestamp in the inject node. But I dont understand it.

Logfiles to bar-chart

If msg.ts or msg.timestamp is given, this timestamp will be used for the reading instead of the current timestamp. You could use this feature to load (older) logfiles into bar-chart data. Caution: All values older than the given timestamp will be discarded => You have to start with the oldest value and will loose all values that are not inside the log files - except the current values are older than the ones from the logfile.

This might be a good hint.
Maybe we need to manipulate the timestamp to a -32days timestamp.

No I think you need to find the format of the restore data, may be install the persist node. and log the store format of the out node json on node-red restart with a debug node. That way you can see how the data would be feed back. Or just try using the persist node.
There is an example flow on the bar chart data node flow page.

I have little hope for the persist node.
When you look in the github of the persist node, you see it is nearly abandonned.
I have tried it, but I get an error message.

20-4-2022 21:48:29
msg : string[151]
"[RED.events] Deprecated use of "nodes-started" event from "/data/node_modules/node-red-contrib-persist/persist.js:164:20". Use "flows:started" instead."

This is the reason I am trying to make use of storing it in variables my self :frowning:

Then may be open an issue on github, ask for the restore format.
Have you captured the complete message object from the data node? i.e set the debug to the complete msg object. Maybe there is some other output we are missing. Looking at the persist node page, it looks like it stores the complete msg object, including topic and _msgid.

1 Like

will try that now. good suggestion.

{"_msgid":"64dc16cb3bda3e36","payload":[{"labels":["03-21","03-22","03-23","03-24","03-25","03-26","03-27","03-28","03-29","03-30","03-31","04-01","04-02","04-03","04-04","04-05","04-06","04-07","04-08","04-09","04-10","04-11","04-12","04-13","04-14","04-15","04-16","04-17","04-18","04-19","04-20"],"series":["","graaddagen_calc"],"data":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,null],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4.85]]}],"topic":"graaddagen_calc","_event":"node:2064b5a11ffc43b3","bar_keys":["20220321","20220322","20220323","20220324","20220325","20220326","20220327","20220328","20220329","20220330","20220331","20220401","20220402","20220403","20220404","20220405","20220406","20220407","20220408","20220409","20220410","20220411","20220412","20220413","20220414","20220415","20220416","20220417","20220418","20220419","20220420"],"data_counter":[{"20220420":1},{"20220420":24}],"topics":["","graaddagen_calc"],"data_min":null,"data_max":null,"data_sum":null,"settings":{"unit":"","x_size":"31","precision":"2","is_meter_reading":false,"agg_by":"avg"}}

Ok there is plenty info there that may be needed to restore
try storing complete msg and then send the complete msg to restore the bar chart data nodes, you would also need to alter you ui-chart function to look for payload.
i.e. Maybe some errors not tested

[{"id":"936fffe6.3b90b","type":"function","z":"bf9e1e33.030598","name":"W to kWh conversion","func":"msg1 = {};\nmsg2 = {};\nmsg3 = {};\nmsg4 = {};\nmsg5 = {};\n\nvar CurrentTime = new Date().getTime();\nvar PreviousTime = flow.get(\"PreviousTime\");\nvar PreviousMessage = flow.get(\"PreviousMessage\");\nvar PreviousTopic = flow.get(\"PreviousTopic\");\nvar LastMessage = msg.payload;\nvar LastTopic= msg.topic;\n\n if (PreviousTime === \"undefined\") {\nflow.set('PreviousTime',CurrentTime);\n\n   \n}\n\nelse {\nTimeElapsed = ((CurrentTime - PreviousTime)/1000);\nflow.set('PreviousTime',CurrentTime);\nflow.set('PreviousMessage',msg.payload);\nflow.set('PreviousTopic',msg.topic);\nmsg3.last = {\"lastTime\":CurrentTime,\"LastMessage\":LastMessage,\"LastTopic\":LastTopic};\nmsg3.Previous = {\"PreviousTime\":PreviousTime,\"PreviousMessage\":PreviousMessage,\"PreviousTopic\":PreviousTopic};\n\n\nmsg1.payload = (TimeElapsed + \"  Seconds\");\ntemp = parseFloat(TimeElapsed.toFixed(0));\nmsg2.payload = temp;\nmsg3.payload = {\"Count\":temp,\"Units\":\"Seconds\"}; \nmsg5.payload = (PreviousMessage * ( temp / 3600000 ));   //  Calculation to Wh portion\nNumber(msg5.payload).toFixed(2);\nmsg5.topic = 'Energy_Consumption_HEAT_kWh';\n   }\n   \nreturn msg5;\n \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":1200,"wires":[["6fe6484b.b6a83"]],"outputLabels":["Energy_Consumption_HEAT_kWh"],"icon":"node-red/timer.png"},{"id":"bf5edbf5.65212","type":"link in","z":"bf9e1e33.030598","name":"","links":["9de1bde370b68508"],"x":15,"y":1200,"wires":[["936fffe6.3b90b"]]},{"id":"6fe6484b.b6a83","type":"bar-chart-data","z":"bf9e1e33.030598","g":"3ce36bc606018d50","name":"bar-chart-data kwh-31d","x_interval":"days","x_size":"31","unit":"","precision":2,"is_meter_reading":"False","agg_by":"sum","x":570,"y":1200,"wires":[["7dadfcbb.b82e14","db8fb89a.59669"]]},{"id":"4a366cf6.8219cc","type":"function","z":"bf9e1e33.030598","name":"","func":"msg = global.get(\"kwh_31d\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":1640,"wires":[["6cb7fe2d.a8f178","6fe6484b.b6a83"]]},{"id":"7dadfcbb.b82e14","type":"debug","z":"bf9e1e33.030598","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":1140,"wires":[]},{"id":"db8fb89a.59669","type":"function","z":"bf9e1e33.030598","name":"Store information to kwh_31d","func":"var myArray4 = msg;\nglobal.set(\"kwh_31d\", myArray4,\"file\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":1200,"wires":[[]],"outputLabels":["graaddagen 24h"]},{"id":"124c607f.79e2e8","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":1640,"wires":[["4a366cf6.8219cc"]]},{"id":"6cb7fe2d.a8f178","type":"function","z":"bf9e1e33.030598","name":"","func":"msg = global.get(\"degreedays_31d\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":1640,"wires":[["e486f482.8c0938","e486f482.8c0938","15e09547.3f82db"]]},{"id":"e486f482.8c0938","type":"delay","z":"bf9e1e33.030598","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":880,"y":1640,"wires":[["1e97310d.9790e7"]]},{"id":"15e09547.3f82db","type":"bar-chart-data","z":"bf9e1e33.030598","g":"6472e1e423188a37","name":"bar-chart-data degreedays-31d","x_interval":"days","x_size":"31","unit":"","precision":"2","is_meter_reading":"False","agg_by":"avg","x":310,"y":1320,"wires":[["4447217.8456a6","9d5f08f4.674d"]]},{"id":"1e97310d.9790e7","type":"function","z":"bf9e1e33.030598","name":"Function - bucket 1 + 2 combined","func":"var myArray1 = global.get(\"kwh_31d\",\"file\");\nvar myArray2 = global.get(\"degreedays_31d\",\"file\");\nlet msg1={}, msg2={};\nmsg1.payload = myArray1.payload;\nmsg2.payload = myArray2.payload;\n\nvar varlabels = msg1.payload[0].labels;\nvar varkwh_data         = msg1.payload[0].data[0];\nvar vargraaddagen_data  = msg2.payload[0].data[0];\nvar m={};\n    m.labels    = varlabels;\n    m.series    = ['DegreeDays (°C)', 'Energy consumption HEAT (kWh)'];\n    m.data      = [vargraaddagen_data, varkwh_data];\n\nreturn {payload:[m]};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":1500,"wires":[["9b4871a9.4341d","9955dc39.ac85b","6a9291e4.bcf4b"]],"outputLabels":["graaddagen_calc"]},{"id":"9ea6d771.9a31f8","type":"link in","z":"bf9e1e33.030598","name":"","links":["2064b5a11ffc43b3"],"x":65,"y":1320,"wires":[["15e09547.3f82db"]]},{"id":"4447217.8456a6","type":"debug","z":"bf9e1e33.030598","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":1380,"wires":[]},{"id":"9d5f08f4.674d","type":"function","z":"bf9e1e33.030598","name":"Store information to degreedays_31d","func":"var myArray5 = msg;\nglobal.set(\"degreedays_31d\", myArray5,\"file\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":1300,"wires":[[]],"outputLabels":["graaddagen 24h"]},{"id":"4c49376f.06eb18","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"900","crontab":"","once":false,"onceDelay":"0.1","topic":"trigger","payloadType":"str","x":130,"y":1500,"wires":[["1e97310d.9790e7"]]},{"id":"9b4871a9.4341d","type":"function","z":"bf9e1e33.030598","name":"Store combined barchart to [barchart_kwh_degreedays_31d]","func":"\nvar myArray6 = msg.payload;\nglobal.set(\"barchart_kwh_degreedays_31d\", myArray6,\"file\");\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":1500,"wires":[[]],"outputLabels":["graaddagen 24h"]},{"id":"9955dc39.ac85b","type":"debug","z":"bf9e1e33.030598","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":720,"y":1540,"wires":[]},{"id":"6a9291e4.bcf4b","type":"ui_chart","z":"bf9e1e33.030598","name":"","group":"b498a01f.25c518","order":4,"width":0,"height":0,"label":"Chart - kWh + Degree Days (31d)","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#ad1625","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":790,"y":1460,"wires":[[]]},{"id":"b498a01f.25c518","type":"ui_group","name":"Degree days information","tab":"a681244e6db9a6a7","order":1,"disp":true,"width":"15","collapse":false,"className":""},{"id":"a681244e6db9a6a7","type":"ui_tab","name":"Degree Days","icon":"dashboard","order":11,"disabled":false,"hidden":false}]
1 Like

I think that is it. :slight_smile: I did a quick test, and it seems to work :slight_smile:
I will test further with an actual reboot to test if this is it.
fingers crossed.

Mega thanks already. I am hopefull !!!

Ok, thats it !!! You fixed it for/with me :slight_smile:

The cause was indeed that I was storing too little information. unaware of the other information besides payload. I feel a bit silly, but much much more happy than silly :grinning: :smile:

Now after reboot all the information in the graphs are restored as I would expect them to.
This is now supurb!

It now looks like this:

The code of the above functionality is below:

[
    {
        "id": "1c223a510a8ec72d",
        "type": "group",
        "z": "ed155b604642d354",
        "name": "Combined bar-chart",
        "style": {
            "label": true
        },
        "nodes": [
            "757d35eee93ec9e7",
            "2391637fadbbf190",
            "6472e1e423188a37",
            "41e8d01708c19225",
            "4eaa2cfa2749c551",
            "3ce36bc606018d50",
            "681a0775921a043e",
            "b2548a4bf37f2567"
        ],
        "x": 68,
        "y": 933,
        "w": 1324,
        "h": 408
    },
    {
        "id": "757d35eee93ec9e7",
        "type": "inject",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Once per 15minutes",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "900",
        "crontab": "",
        "once": true,
        "onceDelay": "5",
        "topic": "trigger",
        "x": 240,
        "y": 1300,
        "wires": [
            [
                "2391637fadbbf190"
            ]
        ]
    },
    {
        "id": "2391637fadbbf190",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Function - bucket 1 + 2 combined",
        "func": "var myArray1 = global.get(\"kwh_31d\",\"file\");\nvar myArray2 = global.get(\"degreedays_31d\",\"file\");\nlet msg1={}, msg2={};\nmsg1 = myArray1;\nmsg2 = myArray2;\n\nvar varlabels = msg1.payload[0].labels;\nvar varkwh_data         = msg1.payload[0].data[0];\nvar vargraaddagen_data  = msg2.payload[0].data[0];\nvar m={};\n    m.labels    = varlabels;\n    m.series    = ['DegreeDays (°C)', 'Energy consumption HEAT (kWh)'];\n    m.data      = [vargraaddagen_data, varkwh_data];\n\nreturn {payload:[m]};\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 520,
        "y": 1300,
        "wires": [
            [
                "4eaa2cfa2749c551"
            ]
        ],
        "outputLabels": [
            "graaddagen_calc"
        ]
    },
    {
        "id": "6472e1e423188a37",
        "type": "group",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Bucket 2 - Degree days calculation",
        "style": {
            "fill": "#bfdbef",
            "label": true
        },
        "nodes": [
            "cff31036dc296d8d",
            "7629b6d3d87712ff",
            "e9d6a960b09e05b8"
        ],
        "x": 94,
        "y": 1119,
        "w": 1272,
        "h": 82
    },
    {
        "id": "cff31036dc296d8d",
        "type": "bar-chart-data",
        "z": "ed155b604642d354",
        "g": "6472e1e423188a37",
        "name": "bar-chart-data degreedays-31d",
        "x_interval": "days",
        "x_size": "31",
        "unit": "",
        "precision": "2",
        "is_meter_reading": "False",
        "agg_by": "avg",
        "x": 850,
        "y": 1160,
        "wires": [
            [
                "e9d6a960b09e05b8"
            ]
        ]
    },
    {
        "id": "7629b6d3d87712ff",
        "type": "link in",
        "z": "ed155b604642d354",
        "g": "6472e1e423188a37",
        "name": "",
        "links": [
            "2064b5a11ffc43b3"
        ],
        "x": 135,
        "y": 1160,
        "wires": [
            [
                "cff31036dc296d8d"
            ]
        ]
    },
    {
        "id": "e9d6a960b09e05b8",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "6472e1e423188a37",
        "name": "Store information to degreedays_31d",
        "func": "var myArray5 = msg;\nglobal.set(\"degreedays_31d\", myArray5,\"file\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1190,
        "y": 1160,
        "wires": [
            []
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "41e8d01708c19225",
        "type": "comment",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Bucket 1 + 2 combined to chart",
        "info": "",
        "x": 250,
        "y": 1260,
        "wires": []
    },
    {
        "id": "4eaa2cfa2749c551",
        "type": "ui_chart",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "",
        "group": "87be08e6a82ef6a0",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "Chart - kWh + Degree Days (31d)",
        "chartType": "bar",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#ad1625",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 860,
        "y": 1300,
        "wires": [
            []
        ]
    },
    {
        "id": "3ce36bc606018d50",
        "type": "group",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Bucket 1 - kWh calculation",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "550d61dd1ac867d3",
            "41bc927c7f5116b1",
            "74f840e183c2ca78",
            "e6ea853dc5ace9bb"
        ],
        "x": 94,
        "y": 959,
        "w": 1272,
        "h": 82
    },
    {
        "id": "550d61dd1ac867d3",
        "type": "bar-chart-data",
        "z": "ed155b604642d354",
        "g": "3ce36bc606018d50",
        "name": "bar-chart-data kwh-31d",
        "x_interval": "days",
        "x_size": "31",
        "unit": "",
        "precision": 2,
        "is_meter_reading": "False",
        "agg_by": "sum",
        "x": 830,
        "y": 1000,
        "wires": [
            [
                "41bc927c7f5116b1"
            ]
        ]
    },
    {
        "id": "41bc927c7f5116b1",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "3ce36bc606018d50",
        "name": "Store information to kwh_31d",
        "func": "var myArray4 = msg;\nglobal.set(\"kwh_31d\", myArray4,\"file\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1220,
        "y": 1000,
        "wires": [
            []
        ],
        "outputLabels": [
            "graaddagen 24h"
        ]
    },
    {
        "id": "74f840e183c2ca78",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "3ce36bc606018d50",
        "name": "W to kWh conversion",
        "func": "msg1 = {};\nmsg2 = {};\nmsg3 = {};\nmsg4 = {};\nmsg5 = {};\n\nvar CurrentTime = new Date().getTime();\nvar PreviousTime = flow.get(\"PreviousTime\");\nvar PreviousMessage = flow.get(\"PreviousMessage\");\nvar PreviousTopic = flow.get(\"PreviousTopic\");\nvar LastMessage = msg.payload;\nvar LastTopic= msg.topic;\n\n if (PreviousTime === \"undefined\") {\nflow.set('PreviousTime',CurrentTime);\n\n   \n}\n\nelse {\nTimeElapsed = ((CurrentTime - PreviousTime)/1000);\nflow.set('PreviousTime',CurrentTime);\nflow.set('PreviousMessage',msg.payload);\nflow.set('PreviousTopic',msg.topic);\nmsg3.last = {\"lastTime\":CurrentTime,\"LastMessage\":LastMessage,\"LastTopic\":LastTopic};\nmsg3.Previous = {\"PreviousTime\":PreviousTime,\"PreviousMessage\":PreviousMessage,\"PreviousTopic\":PreviousTopic};\n\n\nmsg1.payload = (TimeElapsed + \"  Seconds\");\ntemp = parseFloat(TimeElapsed.toFixed(0));\nmsg2.payload = temp;\nmsg3.payload = {\"Count\":temp,\"Units\":\"Seconds\"}; \nmsg5.payload = (PreviousMessage * ( temp / 3600000 ));   //  Calculation to Wh portion\nNumber(msg5.payload).toFixed(2);\nmsg5.topic = 'Energy_Consumption_HEAT_kWh';\n   }\n   \nreturn msg5;\n \n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 480,
        "y": 1000,
        "wires": [
            [
                "550d61dd1ac867d3"
            ]
        ],
        "outputLabels": [
            "Energy_Consumption_HEAT_kWh"
        ],
        "icon": "node-red/timer.png"
    },
    {
        "id": "e6ea853dc5ace9bb",
        "type": "link in",
        "z": "ed155b604642d354",
        "g": "3ce36bc606018d50",
        "name": "",
        "links": [
            "9de1bde370b68508"
        ],
        "x": 135,
        "y": 1000,
        "wires": [
            [
                "74f840e183c2ca78"
            ]
        ]
    },
    {
        "id": "681a0775921a043e",
        "type": "function",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Load bar-chart data",
        "func": "var myArray1 = global.get(\"kwh_31d\",\"file\");\nvar myArray2 = global.get(\"degreedays_31d\",\"file\");\n\nlet msg1={}, msg2=[];\nmsg1 = myArray1;\nmsg2 = myArray2;\n\nreturn [msg1,msg2];",
        "outputs": 2,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 490,
        "y": 1080,
        "wires": [
            [
                "550d61dd1ac867d3"
            ],
            [
                "cff31036dc296d8d"
            ]
        ],
        "outputLabels": [
            "kwh_31d",
            "degreedays_31d"
        ]
    },
    {
        "id": "b2548a4bf37f2567",
        "type": "inject",
        "z": "ed155b604642d354",
        "g": "1c223a510a8ec72d",
        "name": "Restore after boot",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "0.5",
        "topic": "trigger",
        "x": 210,
        "y": 1080,
        "wires": [
            [
                "681a0775921a043e"
            ]
        ]
    },
    {
        "id": "87be08e6a82ef6a0",
        "type": "ui_group",
        "name": "Degree days information",
        "tab": "a681244e6db9a6a7",
        "order": 1,
        "disp": true,
        "width": "15",
        "collapse": false,
        "className": ""
    },
    {
        "id": "a681244e6db9a6a7",
        "type": "ui_tab",
        "name": "Degree Days",
        "icon": "dashboard",
        "order": 11,
        "disabled": false,
        "hidden": false
    }
]

Again...
Many many thanks @E1cid !!!

1 Like

Maybe you like to know/see what you have helped me with. :slight_smile:

You helped me with my NR flow to control a Panasonic Heatpump.
HeatPump can communicate through MQTT, making it possible to create any interface. I choose NR and to share it with the public.

Here is the github page for it.

I have put your name in the acknowledgments.

thanks again!

2 Likes