Erweiterte TTGO Anzeige

Hallo zusammen,

ich hab mal wieder ein bisschen gebastelt :wink:

Used Power ist die Leistung die “verbraucht“ wird. Also was von der Photovoltaik komm nicht an der Batterie als Ladung ankommt.

24h Usage ist die Leistung die die letzten 24h “verbraucht“ wurde. Damit kann man dann ganz gut abschätzen was man so am Tag an Leistung braucht. Wird um 23:59 Uhr zurückgesetzt.

charging ist, glaub ich, selbsterklärend :upside_down_face:

Diese Infos sind für den Einen oder Anderen vielleicht auch interessant.

@Vincent & @Karl Wenn ihr das in der nächsten Version so oder anders nutzen wollt: feel free :wink:

Init_flow (Power Usage)

[
    {
        "id": "1dafaa9025efaab6",
        "type": "function",
        "z": "1f780f8f.dbcd5",
        "name": "set global",
        "func": "global.set(\"24hUsage\", msg.payload);\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1100,
        "y": 1740,
        "wires": [
            []
        ]
    },
    {
        "id": "2a100bdb385a6949",
        "type": "file in",
        "z": "1f780f8f.dbcd5",
        "name": "",
        "filename": "pekaway/24husage",
        "filenameType": "str",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 830,
        "y": 1740,
        "wires": [
            [
                "1dafaa9025efaab6"
            ]
        ]
    }
]

Monit (Power Usage)

[
    {
        "id": "84269381f87b5156",
        "type": "function",
        "z": "527dade3be53f8eb",
        "name": "calc EffectivePower",
        "func": "var check1 = global.get(\"VE_BatteryVolt\");\ncheck1 = parseFloat(check1)\n\nvar check2 = global.get(\"VE_solarCurrent\");\ncheck2 = check2 / 1000;\ncheck2 = parseFloat(check2);\n\n// calc1 => Power Solar\nvar calc1 = check1 * check2;\ncalc1 = Math.round(calc1 * 10.0) / 10.0;\n\nvar check3 = global.get(\"pkwshuntvolt\");\ncheck3 = parseFloat(check3)\ncheck3 = Math.round(check3 * 100.0) / 100.0;\n\nvar check4 = global.get(\"pkwshuntamps\");\ncheck4 = parseFloat(check4)\ncheck4 = Math.round(check4 * 100.0) / 100.0;\n\n// calc1 => Power Shunt\nvar calc2 = check3 * check4;\ncalc2 = Math.round(calc2 * 10.0) / 10.0;\n\nif (calc2 < 0) {\n    msg.payload = {}\n    msg.label = Number(calc1 * -1 + calc2).toFixed(1);\n    node.send([msg, null])\n    msg.payload = Number(calc1 * -1 + calc2).toFixed(1);\n    return [null, msg];\n} else {\n    msg.payload = {}\n    msg.label = Number((calc1 - calc2) * -1).toFixed(1);\n    node.send([msg, null])\n    msg.payload = Number((calc1 - calc2) * -1).toFixed(1);\n    return [null, msg];\n}",
        "outputs": 2,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 510,
        "y": 1120,
        "wires": [
            [
                "0bb6e1bd4e2c36e1",
                "dcc2e72c7b7f3cee",
                "52c1958c28fc9350"
            ],
            [
                "88aa39265b91885d"
            ]
        ]
    },
    {
        "id": "88aa39265b91885d",
        "type": "smooth",
        "z": "527dade3be53f8eb",
        "name": "",
        "property": "payload",
        "action": "min",
        "count": "5",
        "round": "1",
        "mult": "single",
        "reduce": true,
        "x": 700,
        "y": 1120,
        "wires": [
            [
                "0bb6e1bd4e2c36e1",
                "dcc2e72c7b7f3cee",
                "52c1958c28fc9350"
            ]
        ]
    },
    {
        "id": "0bb6e1bd4e2c36e1",
        "type": "ui_chart",
        "z": "527dade3be53f8eb",
        "name": "EffectivePower 24h",
        "group": "50d24057c2d2b0fb",
        "order": 8,
        "width": "6",
        "height": "4",
        "label": "EffectivePower: {{msg.label}} W",
        "chartType": "line",
        "legend": "false",
        "xformat": "dd HH:mm",
        "interpolate": "cubic",
        "nodata": "waiting for readings",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "24",
        "removeOlderPoints": "800",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 910,
        "y": 1120,
        "wires": [
            []
        ],
        "info": "last 10 hours or 200 points"
    },
    {
        "id": "dcc2e72c7b7f3cee",
        "type": "ui_chart",
        "z": "527dade3be53f8eb",
        "name": "EffectivePower 4d",
        "group": "f782473829dc5d6e",
        "order": 5,
        "width": "6",
        "height": "4",
        "label": "EffectivePower: {{msg.label}} W",
        "chartType": "line",
        "legend": "false",
        "xformat": "dd HH:mm",
        "interpolate": "cubic",
        "nodata": "waiting for readings",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "4",
        "removeOlderPoints": "1200",
        "removeOlderUnit": "86400",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1130,
        "y": 1120,
        "wires": [
            []
        ],
        "info": "last 10 hours or 200 points"
    },
    {
        "id": "52c1958c28fc9350",
        "type": "ui_chart",
        "z": "527dade3be53f8eb",
        "name": "EffectivePower 1h",
        "group": "035a0fef21f20204",
        "order": 8,
        "width": "6",
        "height": "4",
        "label": "EffectivePower: {{msg.label}} W",
        "chartType": "line",
        "legend": "false",
        "xformat": "dd HH:mm",
        "interpolate": "cubic",
        "nodata": "waiting for readings",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "1",
        "removeOlderPoints": "60",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1330,
        "y": 1120,
        "wires": [
            []
        ],
        "info": "last 10 hours or 200 points"
    },
    {
        "id": "5b9f6305cb79e611",
        "type": "function",
        "z": "527dade3be53f8eb",
        "name": "get 24hUsage",
        "func": "var check2 = global.get(\"24hUsage\");\ncheck2 = parseFloat(check2)\ncheck2 = Math.round(check2 * 10.0) / 10.0;\n\nmsg.payload = {}\nmsg.label = check2\nnode.send([msg, null])\n\nmsg.payload = Number(check2);\nreturn [null, msg];",
        "outputs": 2,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 500,
        "y": 1160,
        "wires": [
            [
                "5b9fb37c9cf66f6b",
                "dcc70801d5617dcd",
                "25d0890dd0d44e9c"
            ],
            [
                "441679ff3c1280c7",
                "7b30ea79bec8e114"
            ]
        ]
    },
    {
        "id": "441679ff3c1280c7",
        "type": "smooth",
        "z": "527dade3be53f8eb",
        "name": "",
        "property": "payload",
        "action": "min",
        "count": "5",
        "round": "1",
        "mult": "single",
        "reduce": true,
        "x": 700,
        "y": 1160,
        "wires": [
            [
                "5b9fb37c9cf66f6b",
                "dcc70801d5617dcd",
                "25d0890dd0d44e9c"
            ]
        ]
    },
    {
        "id": "5b9fb37c9cf66f6b",
        "type": "ui_chart",
        "z": "527dade3be53f8eb",
        "name": "24hUsage 24h",
        "group": "50d24057c2d2b0fb",
        "order": 8,
        "width": "6",
        "height": "4",
        "label": "24hUsage: {{msg.label}} Wh",
        "chartType": "line",
        "legend": "false",
        "xformat": "dd HH:mm",
        "interpolate": "cubic",
        "nodata": "waiting for readings",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "24",
        "removeOlderPoints": "800",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 900,
        "y": 1160,
        "wires": [
            []
        ],
        "info": "last 10 hours or 200 points"
    },
    {
        "id": "dcc70801d5617dcd",
        "type": "ui_chart",
        "z": "527dade3be53f8eb",
        "name": "24hUsage 4d",
        "group": "f782473829dc5d6e",
        "order": 5,
        "width": "6",
        "height": "4",
        "label": "24hUsage: {{msg.label}} Wh",
        "chartType": "line",
        "legend": "false",
        "xformat": "dd HH:mm",
        "interpolate": "cubic",
        "nodata": "waiting for readings",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "4",
        "removeOlderPoints": "1200",
        "removeOlderUnit": "86400",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1110,
        "y": 1160,
        "wires": [
            []
        ],
        "info": "last 10 hours or 200 points"
    },
    {
        "id": "25d0890dd0d44e9c",
        "type": "ui_chart",
        "z": "527dade3be53f8eb",
        "name": "24hUsage 1h",
        "group": "035a0fef21f20204",
        "order": 8,
        "width": "6",
        "height": "4",
        "label": "24hUsage: {{msg.label}} Wh",
        "chartType": "line",
        "legend": "false",
        "xformat": "dd HH:mm",
        "interpolate": "cubic",
        "nodata": "waiting for readings",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "1",
        "removeOlderPoints": "60",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1310,
        "y": 1160,
        "wires": [
            []
        ],
        "info": "last 10 hours or 200 points"
    },
    {
        "id": "7b30ea79bec8e114",
        "type": "file",
        "z": "527dade3be53f8eb",
        "name": "",
        "filename": "pekaway/24husage",
        "filenameType": "str",
        "appendNewline": false,
        "createDir": true,
        "overwriteFile": "true",
        "encoding": "none",
        "x": 730,
        "y": 1200,
        "wires": [
            []
        ]
    },
    {
        "id": "50d24057c2d2b0fb",
        "type": "ui_group",
        "name": "Solar Charger",
        "tab": "72361f1d56c6ed7e",
        "order": 5,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "f782473829dc5d6e",
        "type": "ui_group",
        "name": "Solar Charger",
        "tab": "787037d182cecd62",
        "order": 3,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "035a0fef21f20204",
        "type": "ui_group",
        "name": "Solar Charger",
        "tab": "785db1ed4917f4c3",
        "order": 3,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "72361f1d56c6ed7e",
        "type": "ui_tab",
        "name": "Monitor 24 Hours",
        "icon": "mi-history",
        "order": 13,
        "disabled": false,
        "hidden": false
    },
    {
        "id": "787037d182cecd62",
        "type": "ui_tab",
        "name": "Monitor 4 Days",
        "icon": "mi-history",
        "order": 14,
        "disabled": false,
        "hidden": false
    },
    {
        "id": "785db1ed4917f4c3",
        "type": "ui_tab",
        "name": "Monitor 1 Hour",
        "icon": "mi-history",
        "order": 12,
        "disabled": false,
        "hidden": false
    }
]

Monit (TTGO)

[
    {
        "id": "7e06940daf37a32e",
        "type": "function",
        "z": "527dade3be53f8eb",
        "name": "format values (wdhm)",
        "func": "var volt = Number(global.get(\"MainBattVolt\"));\nvar soc = Number(global.get(\"MainBattSoc\"));\nvar amps = Number(msg.payload)\nvar cap = 0\nif (global.get(\"BatteryDataDelivery\") == \"BMS\") { cap = Number(global.get(\"BMScap\")) }\nelse if (global.get(\"BatteryDataDelivery\") == \"PekawayWirelessShunt\") { cap = Number(global.get(\"pkwshuntCap\")) * (Number(global.get(\"pkwshuntSOC\")) / 100) }\nelse if (global.get(\"BatteryDataDelivery\") == \"VICTRON\") { \n    msg.payload = global.get(\"VE_timetogo\")\n    global.set(\"ttgo\", msg.payload)\n    return msg\n }\n else if (global.get(\"BatteryDataDelivery\") == \"CANBMS\") { \n    msg.payload = global.get(\"canbus_BMS\") || \"\"\n    const ttgo = `${msg.payload?.ttg?.label ?? \"\"}: ${msg.payload?.ttg?.pretty ?? \"\"}`;\n    global.set(\"ttgo\", ttgo)\n    msg.payload = ttgo\n    return msg\n }\nelse if (global.get(\"BatteryDataDelivery\") == \"1\") { cap = 0 }\n\nmsg.amps = amps;\nmsg.cap = cap;\n\nif (amps > 0) {\n//    msg.payload = \"charging\";\n    msg.ttgo = Number((cap / amps).toFixed(2));\n\n    let days = Math.floor(msg.ttgo / 24); // Extract the whole number of days\n    let remainingHours = msg.ttgo % 24; // Calculate remaining hours\n\n    let hours = Math.floor(remainingHours); // Extract the whole number part of hours\n    let rawMinutes = Math.round((remainingHours - hours) * 60); // Extract the fractional part, convert to minutes, and round\n\n    // Round minutes to the nearest 15-minute interval\n    let roundedMinutes = Math.round(rawMinutes / 15) * 15;\n\n    // Adjust hours and days if rounding up results in 24 hours\n    if (roundedMinutes === 60) {\n        hours += 1;\n        roundedMinutes = 0;\n        if (hours === 24) {\n            days += 1;\n            hours = 0;\n        }\n    }\n\n    // Format the result\n    let result = '';\n    let commaW = '';\n    let commaD = '';\n    let commaH = '';\n    if (days > 0) {\n        commaD = ', '\n        if (days == 1) { result += days + 'd' }\n        else { result += days + 'd´s'; }\n    }\n    if (hours > 0) {\n        commaH = ', '\n        if (hours == 1) { result += commaD + hours + 'h' }\n        else { result += commaD + hours + 'h'; }\n    }\n    if (roundedMinutes > 0) {\n        let comma = (commaD != \"\" || commaH != \"\") ? \", \" : \"\"\n        result += comma + roundedMinutes + 'm'\n    }\n\n    // Return the formatted result\n    msg.payload = \"charging: \" + result + \" at \" + Number((volt *amps ).toFixed(2)) + \"W\";\n} else if (amps === 0) {\n    msg.payload = \"not using power\";\n} else {\n    amps = amps * -1;\n    msg.ttgo = Number((cap / amps).toFixed(2));\n\n    let days = Math.floor(msg.ttgo / 24); // Extract the whole number of days\n    let remainingHours = msg.ttgo % 24; // Calculate remaining hours\n\n    let hours = Math.floor(remainingHours); // Extract the whole number part of hours\n    let rawMinutes = Math.round((remainingHours - hours) * 60); // Extract the fractional part, convert to minutes, and round\n\n    // Round minutes to the nearest 15-minute interval\n    let roundedMinutes = Math.round(rawMinutes / 15) * 15;\n\n    // Adjust hours and days if rounding up results in 24 hours\n    if (roundedMinutes === 60) {\n        hours += 1;\n        roundedMinutes = 0;\n        if (hours === 24) {\n            days += 1;\n            hours = 0;\n        }\n    }\n\n    // Format the result\n    let result = '';\n    let commaW = '';\n    let commaD = '';\n    let commaH = '';\n    if (days > 0) {\n        commaD = ', '\n        if (days == 1) { result += days + ' day' }\n        else {result += days + ' days';}\n    }\n    if (hours > 0) {\n        commaH = ', '\n        if (hours == 1) { result += commaD + hours + ' hour' }\n        else { result += commaD + hours + ' hours';}\n    }\n    if (roundedMinutes > 0) {\n        let comma = (commaD != \"\" || commaH != \"\") ? \", \" : \"\"\n        result += comma + roundedMinutes + ' minutes'\n    }\n\n    // Return the formatted result\n    msg.payload = result;\n}\n\nglobal.set(\"ttgo\", msg.payload)\nreturn msg",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 920.9999122619629,
        "y": 2478.9999504089355,
        "wires": [
            [
                "0501371eb97401c5",
                "25e5a65c9c817408"
            ]
        ]
    },
    {
        "id": "dfb1c188242b7de0",
        "type": "function",
        "z": "527dade3be53f8eb",
        "name": "format values (wdhm)",
        "func": "var volt = Number(global.get(\"MainBattVolt\"));\nvar soc = Number(global.get(\"MainBattSoc\"));\nvar amps = Number(msg.payload)\nvar cap = 0\nif (global.get(\"BatteryDataDelivery\") == \"BMS\") { cap = Number(global.get(\"BMScap\")) }\nelse if (global.get(\"BatteryDataDelivery\") == \"PekawayWirelessShunt\") { cap = Number(global.get(\"pkwshuntCap\")) * (Number(global.get(\"pkwshuntSOC\")) / 100) }\nelse if (global.get(\"BatteryDataDelivery\") == \"VICTRON\") { \n    msg.payload = global.get(\"VE_timetogo\")\n    global.set(\"ttgo\", msg.payload)\n    return msg\n }\n else if (global.get(\"BatteryDataDelivery\") == \"CANBMS\") { \n    msg.payload = global.get(\"canbus_BMS\") || \"\"\n    const ttgo = `${msg.payload?.ttg?.label ?? \"\"}: ${msg.payload?.ttg?.pretty ?? \"\"}`;\n    global.set(\"ttgo\", ttgo)\n    msg.payload = ttgo\n    return msg\n }\nelse if (global.get(\"BatteryDataDelivery\") == \"1\") { cap = 0 }\n\nmsg.amps = amps;\nmsg.cap = cap;\n\nif (amps > 0) {\n//    msg.payload = \"charging\";\n    msg.ttgo = Number((cap / amps).toFixed(2));\n\n    let days = Math.floor(msg.ttgo / 24); // Extract the whole number of days\n    let remainingHours = msg.ttgo % 24; // Calculate remaining hours\n\n    let hours = Math.floor(remainingHours); // Extract the whole number part of hours\n    let rawMinutes = Math.round((remainingHours - hours) * 60); // Extract the fractional part, convert to minutes, and round\n\n    // Round minutes to the nearest 15-minute interval\n    let roundedMinutes = Math.round(rawMinutes / 15) * 15;\n\n    // Adjust hours and days if rounding up results in 24 hours\n    if (roundedMinutes === 60) {\n        hours += 1;\n        roundedMinutes = 0;\n        if (hours === 24) {\n            days += 1;\n            hours = 0;\n        }\n    }\n\n    // Format the result\n    let result = '';\n    let commaW = '';\n    let commaD = '';\n    let commaH = '';\n    if (days > 0) {\n        commaD = ', '\n        if (days == 1) { result += days + 'd' }\n        else { result += days + 'd´s'; }\n    }\n    if (hours > 0) {\n        commaH = ', '\n        if (hours == 1) { result += commaD + hours + 'h' }\n        else { result += commaD + hours + 'h'; }\n    }\n    if (roundedMinutes > 0) {\n        let comma = (commaD != \"\" || commaH != \"\") ? \", \" : \"\"\n        result += comma + roundedMinutes + 'm'\n    }\n\n    // Return the formatted result\n    msg.payload = \"charging: \" + result + \" at \" + Number((volt *amps ).toFixed(2)) + \"W\";\n} else if (amps === 0) {\n    msg.payload = \"not using power\";\n} else {\n    amps = amps * -1;\n    msg.ttgo = Number((cap / amps).toFixed(2));\n\n    let days = Math.floor(msg.ttgo / 24); // Extract the whole number of days\n    let remainingHours = msg.ttgo % 24; // Calculate remaining hours\n\n    let hours = Math.floor(remainingHours); // Extract the whole number part of hours\n    let rawMinutes = Math.round((remainingHours - hours) * 60); // Extract the fractional part, convert to minutes, and round\n\n    // Round minutes to the nearest 15-minute interval\n    let roundedMinutes = Math.round(rawMinutes / 15) * 15;\n\n    // Adjust hours and days if rounding up results in 24 hours\n    if (roundedMinutes === 60) {\n        hours += 1;\n        roundedMinutes = 0;\n        if (hours === 24) {\n            days += 1;\n            hours = 0;\n        }\n    }\n\n    // Format the result\n    let result = '';\n    let commaW = '';\n    let commaD = '';\n    let commaH = '';\n    if (days > 0) {\n        commaD = ', '\n        if (days == 1) { result += days + ' day' }\n        else {result += days + ' days';}\n    }\n    if (hours > 0) {\n        commaH = ', '\n        if (hours == 1) { result += commaD + hours + ' hour' }\n        else { result += commaD + hours + ' hours';}\n    }\n    if (roundedMinutes > 0) {\n        let comma = (commaD != \"\" || commaH != \"\") ? \", \" : \"\"\n        result += comma + roundedMinutes + ' minutes'\n    }\n\n    // Return the formatted result\n    msg.payload = result;\n}\n\nglobal.set(\"ttgo\", msg.payload)\nreturn msg",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 920.9999122619629,
        "y": 2518.9999504089355,
        "wires": [
            [
                "0501371eb97401c5",
                "25e5a65c9c817408"
            ]
        ]
    }
]

Sensor - Dashboard (Power Usage)

[
    {
        "id": "e685ab230c07e15e",
        "type": "function",
        "z": "e10bdbef.f84828",
        "name": "calc Effective Power",
        "func": "var check1 = global.get(\"VE_BatteryVolt\");\ncheck1 = parseFloat(check1)\n\nvar check2 = global.get(\"VE_solarCurrent\");\n// kommt mit V2.09 jetzt in A und nicht in mA\n//check2 = check2 / 1000;\ncheck2 = parseFloat(check2);\n\nvar calc1 = check1 * check2;\ncalc1 = Math.round(calc1 * 10.0) / 10.0;\n\nvar check3 = global.get(\"pkwshuntvolt\");\ncheck3 = parseFloat(check3)\ncheck3 = Math.round(check3 * 100.0) / 100.0;\n\nvar check4 = global.get(\"pkwshuntamps\");\ncheck4 = parseFloat(check4)\ncheck4 = Math.round(check4 * 100.0) / 100.0;\n\nvar calc2 = check3 * check4;\ncalc2 = Math.round(calc2 * 10.0) / 10.0;\n\nvar check5 = Number(global.get(\"24hUsage\"));\n\nif (calc2 < 0) {\n    msg.payload = Number(calc1 * -1 + calc2).toFixed(1);\n\n    var check6 = Number(check5 + (calc1 * -1 + calc2) / 3600 * 5);\n\n    if (isNaN(check6)) {\n        global.set(\"24hUsage\", check5);\n    }\n    else {\n        global.set(\"24hUsage\", check6);\n    }\n\n} else {\n    msg.payload = Number((calc1 - calc2) * -1).toFixed(1);\n\n    var check6 = Number(check5 + ((calc1 - calc2) * -1) / 3600 * 5);\n\n    if (isNaN(check6)) {\n        global.set(\"24hUsage\", check5);\n    }\n    else {\n        global.set(\"24hUsage\", check6);\n    }\n\n}\n\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 920,
        "wires": [
            [
                "98031d37f54288e6"
            ]
        ]
    },
    {
        "id": "98031d37f54288e6",
        "type": "ui_text",
        "z": "e10bdbef.f84828",
        "group": "dcfc4576570aad18",
        "order": 2,
        "width": "0",
        "height": "0",
        "name": "",
        "label": "Used Power",
        "format": "{{msg.payload}} W",
        "layout": "row-spread",
        "className": "",
        "x": 550,
        "y": 920,
        "wires": []
    },
    {
        "id": "0e858c1e6f3a77e0",
        "type": "function",
        "z": "e10bdbef.f84828",
        "name": "get globalJRG",
        "func": "msg.payload = global.get(\"24hUsage\");\nmsg.payload = Number(msg.payload).toFixed(1);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 960,
        "wires": [
            [
                "b01c5574ee6a2504"
            ]
        ]
    },
    {
        "id": "b01c5574ee6a2504",
        "type": "ui_text",
        "z": "e10bdbef.f84828",
        "group": "dcfc4576570aad18",
        "order": 5,
        "width": "0",
        "height": "0",
        "name": "",
        "label": "24h Usage",
        "format": "{{msg.payload}} Wh",
        "layout": "row-spread",
        "className": "",
        "x": 510,
        "y": 960,
        "wires": []
    },
    {
        "id": "a649db0820b975fc",
        "type": "function",
        "z": "e10bdbef.f84828",
        "name": "reset 24hUsage",
        "func": "//global.set(\"24hUsage\", 0);\n\nvar d = new Date();\nvar day = d.getDate()  //day as a number 1 -31\nvar weekday = d.getDay()  //-weekday as a number  0-6\nvar month = d.getMonth() // month as a number 0-11\nvar year = d.getFullYear() //year as a four digit number (yyyy)\nvar hours = d.getHours() //the hour (0-23)\nvar minutes = d.getMinutes() //-the minute (0-59)\nvar seconds = d.getSeconds() //-the seconds (0-59)\n\nif (hours == 23 && minutes == 59 ) {\n    msg.payload = \"TRUE: Es ist \" + hours + \" Uhr \" + minutes + \" und \" + seconds + \" Sekunden\";\n    global.set(\"24hUsage\", 0);\n}\nelse{\n    msg.payload = \"FALSE: Es ist \" + hours + \" Uhr \" + minutes + \" und \" + seconds + \" Sekunden\";\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 1000,
        "wires": [
            [
                "de7910910d5c2383"
            ]
        ]
    },
    {
        "id": "de7910910d5c2383",
        "type": "debug",
        "z": "e10bdbef.f84828",
        "name": "reset 24hUsage",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 540,
        "y": 1000,
        "wires": []
    },
    {
        "id": "dcfc4576570aad18",
        "type": "ui_group",
        "name": "Time to Go",
        "tab": "deee53a800de461d",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": true,
        "className": ""
    },
    {
        "id": "deee53a800de461d",
        "type": "ui_tab",
        "name": "Info",
        "icon": "mi-info",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]
2 Likes

die Idee vom Tagesverbrauch is garend mal so dumm … glaub sowas werd ich mir auch implementieren … danke dir

3 Likes