Skip to content

Instantly share code, notes, and snippets.

@dirkjanfaber
Created June 23, 2023 19:17
Show Gist options
  • Save dirkjanfaber/b1edd571ba60e4faa5767bf0254b8034 to your computer and use it in GitHub Desktop.
Save dirkjanfaber/b1edd571ba60e4faa5767bf0254b8034 to your computer and use it in GitHub Desktop.
Node Red decision flow based on two inputs
[
{
"id": "188103abad4ff1bc",
"type": "tab",
"label": "2 inputs",
"disabled": false,
"info": "",
"env": []
},
{
"id": "ef99b5cc27daa945",
"type": "victron-input-battery",
"z": "188103abad4ff1bc",
"service": "com.victronenergy.battery/256",
"path": "/Soc",
"serviceObj": {
"service": "com.victronenergy.battery/256",
"name": "BMV-702"
},
"pathObj": {
"path": "/Soc",
"type": "float",
"name": "State of charge (%)"
},
"name": "",
"onlyChanges": false,
"x": 200,
"y": 100,
"wires": [
[
"62448a39ef78d0a2"
]
]
},
{
"id": "cf012c59723ef20c",
"type": "victron-input-solarcharger",
"z": "188103abad4ff1bc",
"service": "com.victronenergy.solarcharger/258",
"path": "/Yield/Power",
"serviceObj": {
"service": "com.victronenergy.solarcharger/258",
"name": "BlueSolar Charger MPPT 150/35 rev1"
},
"pathObj": {
"path": "/Yield/Power",
"type": "float",
"name": "PV Power (W)"
},
"name": "",
"onlyChanges": false,
"x": 260,
"y": 260,
"wires": [
[
"97a5de681eb8819e"
]
]
},
{
"id": "62448a39ef78d0a2",
"type": "change",
"z": "188103abad4ff1bc",
"name": "Save SOC",
"rules": [
{
"t": "set",
"p": "soc",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 190,
"y": 160,
"wires": [
[
"d49e90329cc02868"
]
]
},
{
"id": "97a5de681eb8819e",
"type": "change",
"z": "188103abad4ff1bc",
"name": "Save PV Power",
"rules": [
{
"t": "set",
"p": "pvpower",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 200,
"y": 200,
"wires": [
[
"d49e90329cc02868"
]
]
},
{
"id": "d49e90329cc02868",
"type": "function",
"z": "188103abad4ff1bc",
"name": "Calculate grid setpoint",
"func": "let soc = flow.get('soc')\nlet pvpower = flow.get('pvpower')\n\nif ( soc === undefined | pvpower === undefined) {\n return;\n}\n\nif (soc > 85 & pvpower > 1500) {\n msg.payload = -1800\n}\nif (soc > 85 & pvpower < 1500) {\n msg.payload = -500\n}\nif ( soc > 50 & soc < 85 & pvpower > 1500) {\n msg.payload = -500\n}\n\nif ( soc < 30 ) {\n msg.payload = 0\n}\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 440,
"y": 180,
"wires": [
[
"0629439fb1499f84"
]
]
},
{
"id": "0629439fb1499f84",
"type": "victron-output-ess",
"z": "188103abad4ff1bc",
"service": "com.victronenergy.settings",
"path": "/Settings/CGwacs/AcPowerSetPoint",
"serviceObj": {
"service": "com.victronenergy.settings",
"name": "Venus settings"
},
"pathObj": {
"path": "/Settings/CGwacs/AcPowerSetPoint",
"type": "integer",
"name": "Grid set-point (W)",
"writable": true
},
"name": "",
"onlyChanges": false,
"x": 700,
"y": 180,
"wires": []
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment