Gave it a try, now I could find functions to disable MP2 feed-in or battery charge depending on battery SOC and injected power to the grid : no feed-in whenever grid power is below -2000W (should already be the case using ESS with 0W target, but for some reasons, is not) - and no battery charge using a junction combining SOC and grid power (the more power injected to grid, the higher SOC allowed to charge up to, namely 100% at -8000W down to 50% at 0W). Seemed to work at first but with strange behavior, like discharging when it should not (ie no feed-in), “passthough” state seen on MP2, and now completely stuck with “referenceError, context not defined” - I had to use context to store payload from messages so as to be able to combine them and create message to MP2.
Now I understand a bit better Node Red, my functions seem ok to set “disable feed-in” and “disable charge”, but still the MP2 state seen on the dashboard sometimes changes from “external control” to " Discharging" (with low power between 50-100Watts) and then “Passthrough” (with no discharge).
[
{
"id": "a1878c92aa203952",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "4a934764ca949cbe",
"type": "victron-input-vebus",
"z": "a1878c92aa203952",
"service": "com.victronenergy.vebus/275",
"path": "/Ac/Out/L1/P",
"serviceObj": {
"service": "com.victronenergy.vebus/275",
"name": "MultiPlus-II 48/3000/35-32",
"communityTag": "vebus"
},
"pathObj": {
"path": "/Ac/Out/L1/P",
"type": "float",
"name": "Output power phase L1 (W)"
},
"name": "Grid_power",
"onlyChanges": false,
"roundValues": "no",
"rateLimit": "0",
"outputs": 1,
"conditionalMode": false,
"outputTrue": "true",
"outputFalse": "false",
"debounce": "2000",
"x": 310,
"y": 340,
"wires": [
[
"e793cd3799bf40e5",
"0ae4d2f49d2376db"
]
]
},
{
"id": "57d182b120d4fdca",
"type": "victron-input-battery",
"z": "a1878c92aa203952",
"service": "com.victronenergy.battery/512",
"path": "/Soc",
"serviceObj": {
"service": "com.victronenergy.battery/512",
"name": "JK-BMS",
"communityTag": "battery"
},
"pathObj": {
"path": "/Soc",
"type": "float",
"name": "State of charge (%)"
},
"name": "SOC",
"onlyChanges": false,
"roundValues": "no",
"rateLimit": "1",
"outputs": 1,
"conditionalMode": false,
"outputTrue": "true",
"outputFalse": "false",
"debounce": "2000",
"x": 310,
"y": 520,
"wires": [
[
"edee4111305ff472"
]
]
},
{
"id": "ceada869b0725cfb",
"type": "victron-output-ess",
"z": "a1878c92aa203952",
"service": "com.victronenergy.vebus/275",
"path": "/Hub4/DisableCharge",
"serviceObj": {
"service": "com.victronenergy.vebus/275",
"name": "MultiPlus-II 48/3000/35-32",
"communityTag": "ess"
},
"pathObj": {
"path": "/Hub4/DisableCharge",
"type": "enum",
"name": "Disable charge",
"enum": {
"0": "No",
"1": "Yes"
},
"mode": "both"
},
"name": "",
"onlyChanges": false,
"roundValues": "no",
"rateLimit": 0,
"outputs": 0,
"conditionalMode": false,
"condition1Operator": ">",
"condition2Enabled": false,
"condition2Service": "",
"condition2Path": "",
"condition2Operator": ">",
"logicOperator": "AND",
"outputTrue": "true",
"outputFalse": "false",
"outputOnChange": false,
"debounce": 2000,
"x": 910,
"y": 380,
"wires": []
},
{
"id": "b3a93f1167f77fbf",
"type": "victron-output-ess",
"z": "a1878c92aa203952",
"service": "com.victronenergy.vebus/275",
"path": "/Hub4/DisableFeedIn",
"serviceObj": {
"service": "com.victronenergy.vebus/275",
"name": "MultiPlus-II 48/3000/35-32",
"communityTag": "ess"
},
"pathObj": {
"path": "/Hub4/DisableFeedIn",
"type": "enum",
"name": "Disable feed-in",
"enum": {
"0": "No",
"1": "Yes"
},
"mode": "both"
},
"name": "",
"onlyChanges": false,
"roundValues": "no",
"rateLimit": 0,
"outputs": 0,
"conditionalMode": false,
"condition1Operator": ">",
"condition2Enabled": false,
"condition2Service": "",
"condition2Path": "",
"condition2Operator": ">",
"logicOperator": "AND",
"outputTrue": "true",
"outputFalse": "false",
"outputOnChange": false,
"debounce": 2000,
"x": 910,
"y": 320,
"wires": []
},
{
"id": "e793cd3799bf40e5",
"type": "function",
"z": "a1878c92aa203952",
"name": "function 1",
"func": "if (msg.payload < -400)\n msg.payload = 1;\nelse\n msg.payload = 0;\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 320,
"wires": [
[
"b3a93f1167f77fbf"
]
]
},
{
"id": "0ae4d2f49d2376db",
"type": "function",
"z": "a1878c92aa203952",
"name": "function 2",
"func": "// msg has grid_power and mySOC has SOC stored\nvar gp = msg.payload;\nvar SOC = flow.get(\"mySOC\")||0.5;\n\nif ((SOC + Math.min(0,gp/20000))>0.5)\n msg.payload = 1;\nelse\n msg.payload = 0;\n\n//msg.entity = \"f2\"\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 380,
"wires": [
[
"3cc50a647b88c759",
"ceada869b0725cfb"
]
]
},
{
"id": "edee4111305ff472",
"type": "change",
"z": "a1878c92aa203952",
"name": "storeSOC",
"rules": [
{
"t": "set",
"p": "mySOC",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 460,
"y": 520,
"wires": [
[]
]
},
{
"id": "3cc50a647b88c759",
"type": "debug",
"z": "a1878c92aa203952",
"name": "debug 1",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 840,
"y": 480,
"wires": []
},
{
"id": "13c77840f94ebb7f",
"type": "global-config",
"env": [],
"modules": {
"@victronenergy/node-red-contrib-victron": "1.6.64"
}
}
]
Now I think the Node Red function work and allow charging slowly batteries upon largest feed-in time, and discharging at night to keep 0W coming from grid. But still the Fan turns ON during the day when feed-in is above approx 7kW, and independant of charging enabled or not (and anyway, charging with up to a few 100s of watt should not require fan). This is with v558, so I suspect there is still a bug with fan behavior.
Maybe there is a way to log things more in detail to check what is going on. I do not like the idea of adding unnecessary wear to a device that should work 10 yrs at the very least, especially when I set it to remain far from its power limits.

