Hi,
I have a solar system and use multiple plug sockets to monitor my devices. I add up the total power consumption of all devices and subtract this from the total solar generation, which I call "grid consumption." This calculation is done every 10 seconds and displayed in Grafana.
I also have multiple plug sockets with battery backups that turn on and off gradually using a Node Gate and a switch between -10 and 200 watts. When the sun is shining and the grid consumption drops to -10, the first device turns on and opens the gate for the second socket and so on.
At the end of the day, I evaluate how much energy in kWh we saved by using solar power instead of regular electricity. However, I am running into a problem because negative values that are fed back into the grid do not represent energy that we save, but rather energy that we lose since we do not receive any feed-in tariffs.
My question is, how can I exclude the negative values from the calculation so that they do not appear in the final evaluation? This is becoming more important as we connect a larger solar system.
Here are the Parts for the calculation:
[
{
"id": "381d404ebd6d60ec",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "82074fe75c506fc9",
"type": "mqtt in",
"z": "381d404ebd6d60ec",
"name": "Solaranlage",
"topic": "b/strom/stecker-solar/SENSOR",
"qos": "2",
"datatype": "auto-detect",
"broker": "8aa7c4c7.b6d308",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 450,
"y": 180,
"wires": [
[
"8b2d2202f429f388"
]
]
},
{
"id": "31d2793efe61a39f",
"type": "join",
"z": "381d404ebd6d60ec",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": true,
"timeout": "",
"count": "16",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 330,
"y": 140,
"wires": [
[
"0e0450d7936183ae"
]
]
},
{
"id": "f481b05358748ed2",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Summe aller Verbraucher",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.L1 + payload.L2 +payload.L3 +payload.L4 +payload.L5 +payload.L6 +payload.L7 +payload.L8 +payload.L9 +payload.L10 +payload.L11 +payload.L12 +payload.L13 +payload.L14 +payload.L15 +payload.L16",
"tot": "jsonata"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "V1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 670,
"y": 140,
"wires": [
[
"0d0962236b7a1afb"
]
]
},
{
"id": "4c5129e0cc84a2d9",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Minus Solar",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.V1 - payload.S1",
"tot": "jsonata"
},
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "payload.netzbezug",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1170,
"y": 140,
"wires": [
[
"189cda9822796309"
]
]
},
{
"id": "8b2d2202f429f388",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Solaranlage Topic",
"rules": [
{
"t": "move",
"p": "payload.ENERGY.Power",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "S1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 690,
"y": 180,
"wires": [
[
"0d0962236b7a1afb"
]
]
},
{
"id": "0d0962236b7a1afb",
"type": "join",
"z": "381d404ebd6d60ec",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": true,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 870,
"y": 140,
"wires": [
[
"87da9e0a2f46c8d7"
]
]
},
{
"id": "0e0450d7936183ae",
"type": "delay",
"z": "381d404ebd6d60ec",
"name": "5 Sec",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "5",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 470,
"y": 140,
"wires": [
[
"f481b05358748ed2"
]
]
},
{
"id": "87da9e0a2f46c8d7",
"type": "delay",
"z": "381d404ebd6d60ec",
"name": "5 Sec",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "5",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 1010,
"y": 140,
"wires": [
[
"4c5129e0cc84a2d9"
]
]
},
{
"id": "189cda9822796309",
"type": "link out",
"z": "381d404ebd6d60ec",
"name": "Netzbezug/Flurschaltung Out",
"mode": "link",
"links": [
"4ee6342d183f867e",
"e040f6efd87777ef"
],
"x": 1295,
"y": 220,
"wires": []
},
{
"id": "5b2a2e12b5a632b6",
"type": "link in",
"z": "381d404ebd6d60ec",
"name": "Power Monitoring In",
"links": [
"4bacd8180a5001cb"
],
"x": 55,
"y": 140,
"wires": [
[
"9e5dd6c9393f53bc"
]
]
},
{
"id": "9e5dd6c9393f53bc",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Form Power",
"rules": [
{
"t": "move",
"p": "payload.power",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 170,
"y": 140,
"wires": [
[
"31d2793efe61a39f"
]
]
},
{
"id": "3eda328590f57505",
"type": "comment",
"z": "381d404ebd6d60ec",
"name": "Flurschaltung",
"info": "",
"x": 1350,
"y": 180,
"wires": []
},
{
"id": "0b723a1cb1df6f3b",
"type": "join",
"z": "381d404ebd6d60ec",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "17",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 350,
"y": 320,
"wires": [
[
"8380d866e217a473"
]
]
},
{
"id": "8380d866e217a473",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Summe aller Verbraucher",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.L0 +payload.L1 +payload.L2 +payload.L3 +payload.L4 +payload.L5 +payload.L6 +payload.L7 +payload.L8 +payload.L9 +payload.L10 +payload.L11 +payload.L12 +payload.L13 +payload.L14 +payload.L15 +payload.L16",
"tot": "jsonata"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "kw1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 320,
"wires": [
[
"c958a8e81531a7b8",
"11639c41df99581b"
]
]
},
{
"id": "c958a8e81531a7b8",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Move",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "payload.kwtotal2023",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 320,
"wires": [
[
"0715e16a4cb1755d"
]
]
},
{
"id": "0715e16a4cb1755d",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Summe aller Verbraucher",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "0.50 * payload.kwtotal2023",
"tot": "jsonata"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "kostentotal",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 950,
"y": 320,
"wires": [
[
"c8e89797e8126f78"
]
]
},
{
"id": "c8e89797e8126f78",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Move kwpreistotal2023",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "payload.kwpreistotal2023",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1210,
"y": 320,
"wires": [
[]
]
},
{
"id": "9326b98c090ca2c7",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Move kwpreistotalsolar2023",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "payload.kwpreistotalsolar2023",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1540,
"y": 360,
"wires": [
[]
]
},
{
"id": "5c9966010320b687",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Summe aller Verbraucher",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "0.50 * payload.kwtotalsolar",
"tot": "jsonata"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "kwpreistotalsolar",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1270,
"y": 360,
"wires": [
[
"9326b98c090ca2c7"
]
]
},
{
"id": "9f6126e0f3427e36",
"type": "mqtt in",
"z": "381d404ebd6d60ec",
"name": "Solaranlage",
"topic": "b/strom/stecker-solar/SENSOR",
"qos": "2",
"datatype": "auto-detect",
"broker": "8aa7c4c7.b6d308",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 110,
"y": 360,
"wires": [
[
"3a022a4a0f5fc8f9"
]
]
},
{
"id": "3a022a4a0f5fc8f9",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "",
"rules": [
{
"t": "move",
"p": "payload.ENERGY.Total",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "S1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 390,
"y": 360,
"wires": [
[
"11639c41df99581b",
"22d6ce2cdc35a64b"
]
]
},
{
"id": "11639c41df99581b",
"type": "join",
"z": "381d404ebd6d60ec",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": true,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 750,
"y": 360,
"wires": [
[
"b0e121f67551c54c"
]
]
},
{
"id": "b0e121f67551c54c",
"type": "delay",
"z": "381d404ebd6d60ec",
"name": "5 Sec",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "5",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 890,
"y": 360,
"wires": [
[
"61655d6d2daba1ae"
]
]
},
{
"id": "61655d6d2daba1ae",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Minus Solar",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.kw1 - payload.S1",
"tot": "jsonata"
},
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "payload.kwtotalsolar",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1050,
"y": 360,
"wires": [
[
"5c9966010320b687"
]
]
},
{
"id": "08fb6978680b1393",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Form Total",
"rules": [
{
"t": "move",
"p": "payload.total",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 190,
"y": 320,
"wires": [
[
"0b723a1cb1df6f3b"
]
]
},
{
"id": "83a9200aacc9ff92",
"type": "link in",
"z": "381d404ebd6d60ec",
"name": "Power Monitoring In",
"links": [
"4bacd8180a5001cb",
"c0b61a0f26f282c2"
],
"x": 55,
"y": 320,
"wires": [
[
"08fb6978680b1393"
]
]
},
{
"id": "ce8059adde0704ef",
"type": "comment",
"z": "381d404ebd6d60ec",
"name": "Stromkosten",
"info": "",
"x": 110,
"y": 280,
"wires": []
},
{
"id": "22d6ce2cdc35a64b",
"type": "change",
"z": "381d404ebd6d60ec",
"name": "Move kwsolar2023",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "payload.kwsolar2023",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 790,
"y": 400,
"wires": [
[]
]
},
{
"id": "8aa7c4c7.b6d308",
"type": "mqtt-broker",
"name": "Mosquitto",
"broker": "172.50.0.5",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"compatmode": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
}
]
Thanks