Skip to content

Instantly share code, notes, and snippets.

@thomo
Created October 12, 2020 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomo/da4fcd9710333670b58c9df20a67b98d to your computer and use it in GitHub Desktop.
Save thomo/da4fcd9710333670b58c9df20a67b98d to your computer and use it in GitHub Desktop.
PV Calculation
[
{
"id": "8fac7d4.a8d298",
"type": "tab",
"label": "PV",
"disabled": false,
"info": ""
},
{
"id": "83528e7.dc0fc7",
"type": "mqtt in",
"z": "8fac7d4.a8d298",
"name": "Power House Connection",
"topic": "mbmd/se1-1-1/Power",
"qos": "2",
"datatype": "auto",
"broker": "f3aed77c.522758",
"x": 190,
"y": 200,
"wires": [
[
"4e7e0ca9.687b04",
"b9b5ff57.d5eb9"
]
]
},
{
"id": "76efc692.bdc698",
"type": "mqtt in",
"z": "8fac7d4.a8d298",
"name": "PV Production",
"topic": "mbmd/se1-1/Power",
"qos": "2",
"datatype": "auto",
"broker": "f3aed77c.522758",
"x": 150,
"y": 80,
"wires": [
[
"4e7e0ca9.687b04"
]
]
},
{
"id": "659fee86.7462b",
"type": "mqtt out",
"z": "8fac7d4.a8d298",
"name": "House Export",
"topic": "mbmd/se1-1-1/PowerExport",
"qos": "",
"retain": "",
"broker": "f3aed77c.522758",
"x": 880,
"y": 200,
"wires": []
},
{
"id": "4ab9678.0628198",
"type": "mqtt out",
"z": "8fac7d4.a8d298",
"name": "House Import",
"topic": "mbmd/se1-1-1/PowerImport",
"qos": "",
"retain": "",
"broker": "f3aed77c.522758",
"x": 880,
"y": 280,
"wires": []
},
{
"id": "f889eff6.220ef",
"type": "function",
"z": "8fac7d4.a8d298",
"name": "ABS( < 0 )",
"func": "var f = msg.payload\n\nmsg.payload = (f < 0 ? f * -1.0 : 0).toFixed(3)\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 680,
"y": 280,
"wires": [
[
"4ab9678.0628198"
]
]
},
{
"id": "4e7e0ca9.687b04",
"type": "join",
"z": "8fac7d4.a8d298",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 450,
"y": 80,
"wires": [
[
"f68196a3.201248"
]
]
},
{
"id": "f68196a3.201248",
"type": "function",
"z": "8fac7d4.a8d298",
"name": "Differenz",
"func": "var prod = parseFloat(msg.payload[\"mbmd/se1-1/Power\"])\nvar expo = parseFloat(msg.payload[\"mbmd/se1-1-1/Power\"])\n\nif (isNaN(prod) || isNaN(expo)) return null\nif (expo > prod) return null\n\nmsg.payload = (expo > 0 ? prod - expo : prod).toFixed(3)\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 680,
"y": 80,
"wires": [
[
"41f53006.88c84"
]
]
},
{
"id": "41f53006.88c84",
"type": "mqtt out",
"z": "8fac7d4.a8d298",
"name": "Eigenverbrauch",
"topic": "mbmd/se1-1-1/PowerSelfConsumption",
"qos": "",
"retain": "",
"broker": "f3aed77c.522758",
"x": 880,
"y": 80,
"wires": []
},
{
"id": "b9b5ff57.d5eb9",
"type": "function",
"z": "8fac7d4.a8d298",
"name": "toFloat",
"func": "var f = parseFloat(msg.payload)\n\nif (isNaN(f)) return null\n\nmsg.payload = f\nreturn msg\n",
"outputs": 1,
"noerr": 0,
"x": 460,
"y": 200,
"wires": [
[
"3f24b5ea.29dc1a",
"f889eff6.220ef"
]
]
},
{
"id": "3f24b5ea.29dc1a",
"type": "function",
"z": "8fac7d4.a8d298",
"name": ">0",
"func": "var f = msg.payload\n\nmsg.payload = (f >= 0.0 ? f : 0.000).toFixed(3)\n\nreturn msg\n",
"outputs": 1,
"noerr": 0,
"x": 670,
"y": 200,
"wires": [
[
"659fee86.7462b"
]
]
},
{
"id": "f3aed77c.522758",
"type": "mqtt-broker",
"z": "",
"name": "home",
"broker": "my.mqtt.server",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment