If you want the "join" node to monitor any change after the first three, then set this option...
[
{
"id": "684ac4402a1bd08b",
"type": "inject",
"z": "7b8698059fd2bbef",
"name": "temperature 75",
"props": [
{
"p": "payload.temperature",
"v": "75",
"vt": "num"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "temperature",
"x": 260,
"y": 140,
"wires": [
[
"15bef60d2e5de063"
]
]
},
{
"id": "5ed32446c518aa4e",
"type": "inject",
"z": "7b8698059fd2bbef",
"name": "soc83",
"props": [
{
"p": "payload.soc",
"v": "83",
"vt": "num"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "soc",
"x": 280,
"y": 200,
"wires": [
[
"15bef60d2e5de063"
]
]
},
{
"id": "084672b6c8770d95",
"type": "inject",
"z": "7b8698059fd2bbef",
"name": "pvpower 600",
"props": [
{
"p": "payload.pvpower",
"v": "600",
"vt": "num"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "pvpower",
"x": 260,
"y": 260,
"wires": [
[
"15bef60d2e5de063"
]
]
},
{
"id": "15bef60d2e5de063",
"type": "join",
"z": "7b8698059fd2bbef",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": true,
"timeout": "",
"count": "3",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 510,
"y": 200,
"wires": [
[
"d0b4ab06cc28aad6"
]
]
},
{
"id": "27ed164bb6f81c44",
"type": "comment",
"z": "7b8698059fd2bbef",
"name": "Simulate three inputs",
"info": "",
"x": 240,
"y": 60,
"wires": []
},
{
"id": "efa07285342ca10a",
"type": "debug",
"z": "7b8698059fd2bbef",
"name": "vystup",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 870,
"y": 200,
"wires": []
},
{
"id": "d0b4ab06cc28aad6",
"type": "function",
"z": "7b8698059fd2bbef",
"name": "function 28",
"func": "if (msg.payload.pvpower > 300 && msg.payload.soc > 80 && msg.payload.temperature < 80) {\n msg.payload = msg.payload.pvpower;\n} else {\n msg.payload = false;\n}\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 690,
"y": 200,
"wires": [
[
"efa07285342ca10a"
]
]
}
]
I don't know why, but it doesn't work the way it should... I really don't know how to achieve it anymore. Here I wrote another function in which there is only one condition and if it is not met, it sends a 'false' message to the output.
You haven't got the code quite right in the function node...
It should be this...
if (msg.payload.pvpower.pvpower > 300 && msg.payload.soc.soc > 80 && msg.payload.temperature.temperature < 80) {
msg.payload = msg.payload.pvpower.pvpower;
} else {
msg.payload = false;
}
return msg;
Note:
The IF statement you have above is NOT the same as your original requirement...
I need to receive messages from pvpower at the output from the function but if either the temperature is more than 80 or soc less than 80, it won't send anything
Just been trying some of the other options in the "join" node.
If you select create a "merged Object"...
Then you can revert to using this JavaScript in your function node...
if (msg.payload.pvpower > 300 && msg.payload.soc > 80 && msg.payload.temperature < 80) {
msg.payload = msg.payload.pvpower;
} else {
msg.payload = false;
}
return msg;
Hopefully, that should make things a bit simpler to understand?
If you select the option "create a merged Object"...in the "Join" node in the last flow you posted above (ref 21), then I think your flow might work.
Guys, thank you again for the direction. It made me very anxious to correct the mistakes I made and didn't notice them.When I managed to run 3 conditions for sending a message today, I added more conditions there and I also added that the output message switches between two outputs. Here is a picture and the whole flow what it looks like.I control it from the dashboard where I have the controls for the spirals and where it also shows me which spiral is on or off.And based on the weather and surpluses from the PV plant, I will switch the output from the function between the upper and lower spirals.
The two multipleswitch nodes, the switch and the extractor, store the values in the context flow and from there the node function takes them for processing.
and here my function node js code
if (msg.payload.pvpower > 300 && msg.payload.soc > 80 && msg.payload.temperature < 80 && msg.payload.bat > 200 && flow.get("vytazovanie") === true) {
msg.payload = msg.payload.pvpower;
} else {
msg.payload = false;
}
if (flow.get("prepinac") === "hore") {
return [msg, null];
} else {
return [null, msg];
}
Hello, gentlemen... I'm playing a little more with the function nodes and I've created a new function node but it doesn't work as I intended. And this is so that if the conditions of SOC, temperature and BAT go more than 1400, it turns on the spiral1.if the shuttle goes to bat 1400 again or still and spiral1 is switched on then it sends "spiral2 ON".if the shuttle goes to bat 1400 and spiral1 and spiral2 is switched on then it sends "spiral3 ON".
if (flow.get("vytazovanie") === true) {
if (msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {
msg.payload = "spirala1 ON";
} else if (flow.get("spirala1") === "ON" && msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {
msg.payload = "spirala2 ON";
} else if (flow.get("spirala1") === "ON" && flow.get("spirala2") === "ON" && msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {
msg.payload = "spirala3 ON";
} else if (msg.payload.bat < 30 && flow.get("spirala1") === "ON" && flow.get("spirala2") === "ON" && msg.payload.spirala3 === "ON") {
msg.payload = "spirala3 OFF";
} else if (msg.payload.bat < 30 && flow.get("spirala1") === "ON" && flow.get("spirala2") === "ON" && msg.payload.spirala3 === "OFF") {
msg.payload = "spirala2 OFF";
} else if (msg.payload.bat < 30 && flow.get("spirala1") === "ON" && flow.get("spirala2") === "OFF" && msg.payload.spirala3 === "OFF") {
msg.payload = "spirala1 OFF";
}
} else {
msg.payload = "OFF";
return msg;
}
// Vypínanie špirál, ak SOC klesne pod 80 alebo teplota stupne nad 80
if (msg.payload.soc < 80 || msg.payload.temperature > 80) {
output1.payload = "OFF";
output2.payload = "OFF";
node.send([output1, output2]);
}
// Posielanie hore alebo dole na zaklade prepinaca
if (flow.get("prepinac") === "hore") {
return [msg, null];
} else {
return [null, msg];
}
A function can only return msg
once, so in the first if ...else
some message will be returned and it will never evaluate the rest of your script.
I found it difficult to work out what is happening in your nested and multiple IF constructs, so I ran your code through ChatGPT which yields this response...
The provided JavaScript code has several issues. Let's break down the corrections needed:
- Initialization of
output1
andoutput2
: The variablesoutput1
andoutput2
are used but not initialized. - Misuse of
msg.payload.spirala3
: There are instances wheremsg.payload.spirala3
is used but it should be retrieved from the flow context. - Flow context retrieval:
flow.get("spiralaX")
is used within the conditions, but the state changes should be saved back into the flow context. - Misplacement of
return msg
: Thereturn msg
statement will exit the function early, preventing subsequent code from running. - Unreachable code and missing initialization of
msg.payload
: The payload is overwritten early in the code, making some of the logic unreachable or incorrectly executed. - Logical grouping and setting the flow context: When turning spirals on/off, ensure the states are properly set and stored in the flow context.
According to ChatGPT, here's the corrected version of your JavaScript code:
let output1 = {};
let output2 = {};
if (flow.get("vytazovanie") === true) {
if (msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {
msg.payload = "spirala1 ON";
flow.set("spirala1", "ON");
} else if (flow.get("spirala1") === "ON" && msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {
msg.payload = "spirala2 ON";
flow.set("spirala2", "ON");
} else if (flow.get("spirala1") === "ON" && flow.get("spirala2") === "ON" && msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {
msg.payload = "spirala3 ON";
flow.set("spirala3", "ON");
} else if (msg.payload.bat < 30 && flow.get("spirala1") === "ON" && flow.get("spirala2") === "ON" && flow.get("spirala3") === "ON") {
msg.payload = "spirala3 OFF";
flow.set("spirala3", "OFF");
} else if (msg.payload.bat < 30 && flow.get("spirala1") === "ON" && flow.get("spirala2") === "ON" && flow.get("spirala3") === "OFF") {
msg.payload = "spirala2 OFF";
flow.set("spirala2", "OFF");
} else if (msg.payload.bat < 30 && flow.get("spirala1") === "ON" && flow.get("spirala2") === "OFF" && flow.get("spirala3") === "OFF") {
msg.payload = "spirala1 OFF";
flow.set("spirala1", "OFF");
}
} else {
msg.payload = "OFF";
}
// Vypínanie špirál, ak SOC klesne pod 80 alebo teplota stupne nad 80
if (msg.payload.soc < 80 || msg.payload.temperature > 80) {
output1.payload = "OFF";
output2.payload = "OFF";
node.send([output1, output2]);
}
// Posielanie hore alebo dole na zaklade prepinaca
if (flow.get("prepinac") === "hore") {
return [msg, null];
} else {
return [null, msg];
}
return msg;
[
{
"id": "9cb4408dec3cec45",
"type": "victron-input-temperature",
"z": "7bb4b982f37a1f91",
"service": "com.victronenergy.temperature/24",
"path": "/Temperature",
"serviceObj": {
"service": "com.victronenergy.temperature/24",
"name": "Akumulacka vrch"
},
"pathObj": {
"path": "/Temperature",
"type": "float",
"name": "Temperature (°C)"
},
"name": "temperature",
"onlyChanges": false,
"roundValues": "1",
"x": 130,
"y": 1520,
"wires": [
[
"72b8afdb0c028826"
]
]
},
{
"id": "72b8afdb0c028826",
"type": "join",
"z": "7bb4b982f37a1f91",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "3",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 350,
"y": 1480,
"wires": [
[
"803efd449ee103a1"
]
]
},
{
"id": "c3454808368cce43",
"type": "inject",
"z": "7bb4b982f37a1f91",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "bat",
"payload": "1450",
"payloadType": "num",
"x": 140,
"y": 1480,
"wires": [
[
"72b8afdb0c028826"
]
]
},
{
"id": "a687ace9c2680386",
"type": "inject",
"z": "7bb4b982f37a1f91",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "soc",
"payload": "85",
"payloadType": "num",
"x": 140,
"y": 1440,
"wires": [
[
"72b8afdb0c028826"
]
]
},
{
"id": "fa54042223c20b04",
"type": "function",
"z": "7bb4b982f37a1f91",
"name": "function 49",
"func": "msg.topic = \"spirala1\";\nflow.set(\"spirala1\", msg.payload);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 310,
"y": 1600,
"wires": [
[]
]
},
{
"id": "19284b37d45800ac",
"type": "function",
"z": "7bb4b982f37a1f91",
"name": "function 50",
"func": "msg.topic = \"spirala2\";\nflow.set(\"spirala2\", msg.payload);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 310,
"y": 1660,
"wires": [
[]
]
},
{
"id": "6c7632b238f16b32",
"type": "function",
"z": "7bb4b982f37a1f91",
"name": "function 51",
"func": "msg.topic = \"spirala3\";\nflow.set(\"spirala3\", msg.payload);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 310,
"y": 1720,
"wires": [
[]
]
},
{
"id": "36186e634336a10e",
"type": "debug",
"z": "7bb4b982f37a1f91",
"name": "debug 34",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 640,
"y": 1380,
"wires": []
},
{
"id": "0a8a2ea5ea6928e6",
"type": "debug",
"z": "7bb4b982f37a1f91",
"name": "debug 35",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 1560,
"wires": []
},
{
"id": "803efd449ee103a1",
"type": "function",
"z": "7bb4b982f37a1f91",
"name": "function 53",
"func": "let output1 = {};\nlet output2 = {};\n\nif (flow.get(\"vytazovanie\") === true) {\n if (msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {\n msg.payload = \"spirala1 1\";\n flow.set(\"spirala1\", \"1\");\n } else if (flow.get(\"spirala1\") === \"1\" && msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {\n msg.payload = \"spirala2 1\";\n flow.set(\"spirala2\", \"1\");\n } else if (flow.get(\"spirala1\") === \"1\" && flow.get(\"spirala2\") === \"1\" && msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {\n msg.payload = \"spirala3 1\";\n flow.set(\"spirala3\", \"1\");\n } else if (msg.payload.bat < 30 && flow.get(\"spirala1\") === \"1\" && flow.get(\"spirala2\") === \"1\" && flow.get(\"spirala3\") === \"1\") {\n msg.payload = \"spirala3 0\";\n flow.set(\"spirala3\", \"0\");\n } else if (msg.payload.bat < 30 && flow.get(\"spirala1\") === \"1\" && flow.get(\"spirala2\") === \"1\" && flow.get(\"spirala3\") === \"0\") {\n msg.payload = \"spirala2 0\";\n flow.set(\"spirala2\", \"0\");\n } else if (msg.payload.bat < 30 && flow.get(\"spirala1\") === \"1\" && flow.get(\"spirala2\") === \"0\" && flow.get(\"spirala3\") === \"0\") {\n msg.payload = \"spirala1 0\";\n flow.set(\"spirala1\", \"0\");\n } \n} else {\n msg.payload = \"OFF\";\n}\n\n// Posielanie hore alebo dole na zaklade prepinaca\nif (flow.get(\"prepinac\") === \"hore\") {\n return [msg, null];\n} else {\n return [null, msg];\n}",
"outputs": 2,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 490,
"y": 1480,
"wires": [
[
"36186e634336a10e",
"e7c9fc8e9278124f"
],
[
"0a8a2ea5ea6928e6"
]
]
},
{
"id": "7274ed0f303db499",
"type": "victron-input-battery",
"z": "7bb4b982f37a1f91",
"service": "com.victronenergy.battery/277",
"path": "/Relay/0/State",
"serviceObj": {
"service": "com.victronenergy.battery/277",
"name": "Baterka"
},
"pathObj": {
"path": "/Relay/0/State",
"type": "enum",
"name": "Relay status",
"enum": {
"0": "Open",
"1": "Closed"
}
},
"initial": "",
"name": "spirala1",
"onlyChanges": false,
"x": 110,
"y": 1600,
"wires": [
[
"fa54042223c20b04"
]
]
},
{
"id": "89f26af5d635f161",
"type": "victron-input-relay",
"z": "7bb4b982f37a1f91",
"service": "com.victronenergy.system/0",
"path": "/Relay/0/State",
"serviceObj": {
"service": "com.victronenergy.system/0",
"name": "Venus system"
},
"pathObj": {
"path": "/Relay/0/State",
"type": "enum",
"name": "Venus relay 1 state",
"enum": {
"0": "Open",
"1": "Closed"
}
},
"initial": "",
"name": "spirala2",
"onlyChanges": false,
"x": 110,
"y": 1660,
"wires": [
[
"19284b37d45800ac"
]
]
},
{
"id": "f60fb54ea8b74b84",
"type": "victron-input-relay",
"z": "7bb4b982f37a1f91",
"service": "com.victronenergy.system/0",
"path": "/Relay/1/State",
"serviceObj": {
"service": "com.victronenergy.system/0",
"name": "Venus system"
},
"pathObj": {
"path": "/Relay/1/State",
"type": "enum",
"name": "Venus relay 2 state",
"enum": {
"0": "Open",
"1": "Closed"
}
},
"initial": "",
"name": "spirala3",
"onlyChanges": false,
"x": 110,
"y": 1720,
"wires": [
[
"6c7632b238f16b32"
]
]
},
{
"id": "da65f8666bfc1a72",
"type": "victron-output-relay",
"z": "7bb4b982f37a1f91",
"service": "com.victronenergy.system/0",
"path": "/Relay/0/State",
"serviceObj": {
"service": "com.victronenergy.system/0",
"name": "Venus device"
},
"pathObj": {
"path": "/Relay/0/State",
"type": "enum",
"name": "Venus relay 1 state",
"enum": {
"0": "Open",
"1": "Closed"
},
"writable": true,
"disabled": false
},
"initial": "",
"name": "spirala2",
"onlyChanges": false,
"x": 1100,
"y": 1460,
"wires": []
},
{
"id": "352ef9f596e3c543",
"type": "victron-output-relay",
"z": "7bb4b982f37a1f91",
"service": "com.victronenergy.system/0",
"path": "/Relay/1/State",
"serviceObj": {
"service": "com.victronenergy.system/0",
"name": "Venus device"
},
"pathObj": {
"path": "/Relay/1/State",
"type": "enum",
"name": "Venus relay 2 state",
"enum": {
"0": "Open",
"1": "Closed"
},
"writable": true
},
"initial": "",
"name": "spirala3",
"onlyChanges": false,
"x": 1100,
"y": 1520,
"wires": []
},
{
"id": "435a2b80bec00f09",
"type": "victron-output-relay",
"z": "7bb4b982f37a1f91",
"service": "com.victronenergy.battery/277",
"path": "/Relay/0/State",
"serviceObj": {
"service": "com.victronenergy.battery/277",
"name": "Baterka"
},
"pathObj": {
"path": "/Relay/0/State",
"type": "enum",
"name": "Relay status",
"enum": {
"0": "Open",
"1": "Closed"
},
"writable": true
},
"initial": "",
"name": "spirala1",
"onlyChanges": false,
"x": 1100,
"y": 1400,
"wires": []
},
{
"id": "e7c9fc8e9278124f",
"type": "switch",
"z": "7bb4b982f37a1f91",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "spirala1 1",
"vt": "str"
},
{
"t": "cont",
"v": "spirala1 0",
"vt": "str"
},
{
"t": "cont",
"v": "spirala2 1",
"vt": "str"
},
{
"t": "cont",
"v": "spirala2 0",
"vt": "str"
},
{
"t": "cont",
"v": "spirala3 1",
"vt": "str"
},
{
"t": "cont",
"v": "spirala3 0",
"vt": "str"
},
{
"t": "cont",
"v": "OFF",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 7,
"x": 670,
"y": 1460,
"wires": [
[
"bccb3ab71d4d9c6b"
],
[
"bccb3ab71d4d9c6b"
],
[
"1af6c9287dea1841"
],
[
"1af6c9287dea1841"
],
[
"7db54b1f99f24679"
],
[
"7db54b1f99f24679"
],
[
"7db54b1f99f24679",
"1af6c9287dea1841",
"bccb3ab71d4d9c6b"
]
]
},
{
"id": "bccb3ab71d4d9c6b",
"type": "change",
"z": "7bb4b982f37a1f91",
"name": "",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "spirala1 1",
"fromt": "str",
"to": "1",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "spirala1 0",
"fromt": "str",
"to": "0",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "OFF",
"fromt": "str",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 880,
"y": 1400,
"wires": [
[
"435a2b80bec00f09"
]
]
},
{
"id": "1af6c9287dea1841",
"type": "change",
"z": "7bb4b982f37a1f91",
"name": "",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "spirala2 1",
"fromt": "str",
"to": "1",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "spirala2 0",
"fromt": "str",
"to": "0",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "OFF",
"fromt": "str",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 880,
"y": 1460,
"wires": [
[
"da65f8666bfc1a72"
]
]
},
{
"id": "7db54b1f99f24679",
"type": "change",
"z": "7bb4b982f37a1f91",
"name": "",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "spirala3 1",
"fromt": "str",
"to": "1",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "spirala3 0",
"fromt": "str",
"to": "0",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "OFF",
"fromt": "str",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 880,
"y": 1520,
"wires": [
[
"352ef9f596e3c543"
]
]
},
{
"id": "64ed8a4486002ff5",
"type": "group",
"z": "7bb4b982f37a1f91",
"name": "voľba vyťažovania ovládanie v dashboarde",
"style": {
"label": true,
"color": "#3f3f3f",
"stroke": "#3f3f3f",
"label-position": "n"
},
"nodes": [
"bbd2e98c4e13adda",
"bbf603013f5c4f82",
"5eded41771b42501",
"9866c1f1d3d76651"
],
"x": 34,
"y": 1259,
"w": 392,
"h": 142
},
{
"id": "bbd2e98c4e13adda",
"type": "ui_multistate_switch",
"z": "7bb4b982f37a1f91",
"g": "64ed8a4486002ff5",
"name": "prepinac",
"group": "d7e013c07cc5b346",
"order": 2,
"width": 0,
"height": 1,
"label": "Výber špirál",
"stateField": "payload",
"enableField": "enable",
"passthroughField": "change",
"inputMsgField": "inputmsg",
"rounded": true,
"useThemeColors": true,
"hideSelectedLabel": false,
"multilineLabel": false,
"passThrough": "change",
"inputMsg": "none",
"userInput": "enabled_show",
"options": [
{
"label": "vrch AN",
"value": "hore",
"valueType": "str",
"color": "#009933"
},
{
"label": "spodok AN",
"value": "dolu",
"valueType": "str",
"color": "#999999"
}
],
"topic": "msg.payload",
"x": 120,
"y": 1360,
"wires": [
[
"9866c1f1d3d76651"
]
]
},
{
"id": "bbf603013f5c4f82",
"type": "ui_multistate_switch",
"z": "7bb4b982f37a1f91",
"g": "64ed8a4486002ff5",
"name": "vytazovanie",
"group": "d7e013c07cc5b346",
"order": 1,
"width": 0,
"height": 1,
"label": "Vyťažovanie",
"stateField": "payload",
"enableField": "enable",
"passthroughField": "passthrough",
"inputMsgField": "inputmsg",
"rounded": true,
"useThemeColors": false,
"hideSelectedLabel": false,
"multilineLabel": false,
"passThrough": "change",
"inputMsg": "none",
"userInput": "enabled_show",
"options": [
{
"label": "Vypnuté",
"value": "false",
"valueType": "bool",
"color": "#ff0019"
},
{
"label": "Zapnuté",
"value": "true",
"valueType": "bool",
"color": "#009900"
}
],
"topic": "msg.payload",
"x": 130,
"y": 1300,
"wires": [
[
"5eded41771b42501"
]
]
},
{
"id": "5eded41771b42501",
"type": "function",
"z": "7bb4b982f37a1f91",
"g": "64ed8a4486002ff5",
"name": "context-flow",
"func": "// Change Node nastavenie\nmsg.topic = \"vytazovanie\";\nflow.set(\"vytazovanie\", msg.payload);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 1300,
"wires": [
[]
]
},
{
"id": "9866c1f1d3d76651",
"type": "function",
"z": "7bb4b982f37a1f91",
"g": "64ed8a4486002ff5",
"name": "context-flow",
"func": "// Change Node nastavenie\nmsg.topic = \"prepinac\";\nflow.set(\"prepinac\", msg.payload);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 1360,
"wires": [
[]
]
},
{
"id": "d7e013c07cc5b346",
"type": "ui_group",
"name": "Voľba vyťažovania ",
"tab": "f1fc31401dd012dd",
"order": 4,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "f1fc31401dd012dd",
"type": "ui_tab",
"name": "Tab 2",
"icon": "dashboard",
"order": 2
}
]
This is a copy of the whole test flow, except that it lacks the output to the lower spirals, but it doesn't matter, just to give you the idea that it doesn't work that way according to the code.
Try this.
[{"id":"5c22dc58c00d6d57","type":"tab","label":"Victron","disabled":false,"info":"","env":[]},{"id":"a9ee9143e3a2a6b3","type":"group","z":"5c22dc58c00d6d57","name":"voľba vyťažovania ovládanie v dashboarde","style":{"label":true,"color":"#3f3f3f","stroke":"#3f3f3f","label-position":"n"},"nodes":["9b8f22f3a1d85b7b","85fee20f9cceed0e","25e4887cfbfb3b2a","e1ba89f7bded151a"],"x":34,"y":39,"w":392,"h":142},{"id":"52d2066b05f4371d","type":"victron-input-temperature","z":"5c22dc58c00d6d57","service":"com.victronenergy.temperature/24","path":"/Temperature","serviceObj":{"service":"com.victronenergy.temperature/24","name":"Akumulacka vrch"},"pathObj":{"path":"/Temperature","type":"float","name":"Temperature (°C)"},"name":"temperature","onlyChanges":false,"roundValues":"1","x":130,"y":300,"wires":[["24175936f23b4cf3"]]},{"id":"df09d5bc174815ed","type":"join","z":"5c22dc58c00d6d57","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":350,"y":260,"wires":[["2393b485adccca9f","bda2d11e53c3ca8b"]]},{"id":"5218fc9afce42845","type":"inject","z":"5c22dc58c00d6d57","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"bat","payload":"1450","payloadType":"num","x":140,"y":260,"wires":[["df09d5bc174815ed"]]},{"id":"08df8b03d51e1f33","type":"inject","z":"5c22dc58c00d6d57","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"soc","payload":"85","payloadType":"num","x":140,"y":220,"wires":[["df09d5bc174815ed"]]},{"id":"718e4d7a7df110b9","type":"function","z":"5c22dc58c00d6d57","name":"function 49","func":"msg.topic = \"spirala1\";\nflow.set(\"spirala1\", msg.payload);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":540,"wires":[[]]},{"id":"b36f08f37382f041","type":"function","z":"5c22dc58c00d6d57","name":"function 50","func":"msg.topic = \"spirala2\";\nflow.set(\"spirala2\", msg.payload);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":600,"wires":[[]]},{"id":"1d4a561c52c243fc","type":"function","z":"5c22dc58c00d6d57","name":"function 51","func":"msg.topic = \"spirala3\";\nflow.set(\"spirala3\", msg.payload);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":660,"wires":[[]]},{"id":"8d67fd36ad2bc6e8","type":"debug","z":"5c22dc58c00d6d57","name":"debug 34","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":160,"wires":[]},{"id":"63539cda9d86b948","type":"debug","z":"5c22dc58c00d6d57","name":"debug 35","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":340,"wires":[]},{"id":"2393b485adccca9f","type":"function","z":"5c22dc58c00d6d57","name":"function 53","func":"let output1 = {};\nlet output2 = {};\n\nif (flow.get(\"vytazovanie\") === true) {\n if (msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {\n msg.payload = \"spirala1 1\";\n flow.set(\"spirala1\", \"1\");\n } else if (flow.get(\"spirala1\") === \"1\" && msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {\n msg.payload = \"spirala2 1\";\n flow.set(\"spirala2\", \"1\");\n } else if (flow.get(\"spirala1\") === \"1\" && flow.get(\"spirala2\") === \"1\" && msg.payload.bat > 1400 && msg.payload.soc > 80 && msg.payload.temperature < 80) {\n msg.payload = \"spirala3 1\";\n flow.set(\"spirala3\", \"1\");\n } else if (msg.payload.bat < 30 && flow.get(\"spirala1\") === \"1\" && flow.get(\"spirala2\") === \"1\" && flow.get(\"spirala3\") === \"1\") {\n msg.payload = \"spirala3 0\";\n flow.set(\"spirala3\", \"0\");\n } else if (msg.payload.bat < 30 && flow.get(\"spirala1\") === \"1\" && flow.get(\"spirala2\") === \"1\" && flow.get(\"spirala3\") === \"0\") {\n msg.payload = \"spirala2 0\";\n flow.set(\"spirala2\", \"0\");\n } else if (msg.payload.bat < 30 && flow.get(\"spirala1\") === \"1\" && flow.get(\"spirala2\") === \"0\" && flow.get(\"spirala3\") === \"0\") {\n msg.payload = \"spirala1 0\";\n flow.set(\"spirala1\", \"0\");\n } \n} else {\n msg.payload = \"OFF\";\n}\n\n// Posielanie hore alebo dole na zaklade prepinaca\nif (flow.get(\"prepinac\") === \"hore\") {\n return [msg, null];\n} else { // dolu\n return [null, msg];\n}","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":260,"wires":[["8d67fd36ad2bc6e8","8c119cfd86e6c6c1"],["63539cda9d86b948"]]},{"id":"a76495cbdf7558e8","type":"victron-input-battery","z":"5c22dc58c00d6d57","service":"com.victronenergy.battery/277","path":"/Relay/0/State","serviceObj":{"service":"com.victronenergy.battery/277","name":"Baterka"},"pathObj":{"path":"/Relay/0/State","type":"enum","name":"Relay status","enum":{"0":"Open","1":"Closed"}},"initial":"","name":"spirala1","onlyChanges":false,"x":110,"y":540,"wires":[["718e4d7a7df110b9"]]},{"id":"26069f48f8eb08c8","type":"victron-input-relay","z":"5c22dc58c00d6d57","service":"com.victronenergy.system/0","path":"/Relay/0/State","serviceObj":{"service":"com.victronenergy.system/0","name":"Venus system"},"pathObj":{"path":"/Relay/0/State","type":"enum","name":"Venus relay 1 state","enum":{"0":"Open","1":"Closed"}},"initial":"","name":"spirala2","onlyChanges":false,"x":110,"y":600,"wires":[["b36f08f37382f041"]]},{"id":"2a0b303ba93bf873","type":"victron-input-relay","z":"5c22dc58c00d6d57","service":"com.victronenergy.system/0","path":"/Relay/1/State","serviceObj":{"service":"com.victronenergy.system/0","name":"Venus system"},"pathObj":{"path":"/Relay/1/State","type":"enum","name":"Venus relay 2 state","enum":{"0":"Open","1":"Closed"}},"initial":"","name":"spirala3","onlyChanges":false,"x":110,"y":660,"wires":[["1d4a561c52c243fc"]]},{"id":"fc9edcd44eb237ab","type":"victron-output-relay","z":"5c22dc58c00d6d57","service":"com.victronenergy.system/0","path":"/Relay/0/State","serviceObj":{"service":"com.victronenergy.system/0","name":"Venus device"},"pathObj":{"path":"/Relay/0/State","type":"enum","name":"Venus relay 1 state","enum":{"0":"Open","1":"Closed"},"writable":true,"disabled":false},"initial":"","name":"spirala2","onlyChanges":false,"x":1100,"y":240,"wires":[]},{"id":"8c3db7fcd585bb9b","type":"victron-output-relay","z":"5c22dc58c00d6d57","service":"com.victronenergy.system/0","path":"/Relay/1/State","serviceObj":{"service":"com.victronenergy.system/0","name":"Venus device"},"pathObj":{"path":"/Relay/1/State","type":"enum","name":"Venus relay 2 state","enum":{"0":"Open","1":"Closed"},"writable":true},"initial":"","name":"spirala3","onlyChanges":false,"x":1100,"y":300,"wires":[]},{"id":"9f6ec0894752f4f2","type":"victron-output-relay","z":"5c22dc58c00d6d57","service":"com.victronenergy.battery/277","path":"/Relay/0/State","serviceObj":{"service":"com.victronenergy.battery/277","name":"Baterka"},"pathObj":{"path":"/Relay/0/State","type":"enum","name":"Relay status","enum":{"0":"Open","1":"Closed"},"writable":true},"initial":"","name":"spirala1","onlyChanges":false,"x":1100,"y":180,"wires":[]},{"id":"8c119cfd86e6c6c1","type":"switch","z":"5c22dc58c00d6d57","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"spirala1 1","vt":"str"},{"t":"cont","v":"spirala1 0","vt":"str"},{"t":"cont","v":"spirala2 1","vt":"str"},{"t":"cont","v":"spirala2 0","vt":"str"},{"t":"cont","v":"spirala3 1","vt":"str"},{"t":"cont","v":"spirala3 0","vt":"str"},{"t":"cont","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":7,"x":670,"y":240,"wires":[["2c92c18196d249de"],["2c92c18196d249de"],["d50320b313dc3495"],["d50320b313dc3495"],["cc736b7b0c8c0293"],["cc736b7b0c8c0293"],["cc736b7b0c8c0293","d50320b313dc3495","2c92c18196d249de"]]},{"id":"2c92c18196d249de","type":"change","z":"5c22dc58c00d6d57","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"spirala1 1","fromt":"str","to":"1","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"spirala1 0","fromt":"str","to":"0","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":180,"wires":[["9f6ec0894752f4f2"]]},{"id":"d50320b313dc3495","type":"change","z":"5c22dc58c00d6d57","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"spirala2 1","fromt":"str","to":"1","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"spirala2 0","fromt":"str","to":"0","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":240,"wires":[["fc9edcd44eb237ab"]]},{"id":"cc736b7b0c8c0293","type":"change","z":"5c22dc58c00d6d57","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"spirala3 1","fromt":"str","to":"1","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"spirala3 0","fromt":"str","to":"0","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":300,"wires":[["8c3db7fcd585bb9b"]]},{"id":"9b8f22f3a1d85b7b","type":"ui_multistate_switch","z":"5c22dc58c00d6d57","g":"a9ee9143e3a2a6b3","name":"prepinac","group":"","order":2,"width":0,"height":1,"label":"Výber špirál","stateField":"payload","enableField":"enable","passthroughField":"change","inputMsgField":"inputmsg","rounded":true,"useThemeColors":true,"hideSelectedLabel":false,"multilineLabel":false,"passThrough":"change","inputMsg":"none","userInput":"enabled_show","options":[{"label":"vrch AN","value":"hore","valueType":"str","color":"#009933"},{"label":"spodok AN","value":"dolu","valueType":"str","color":"#999999"}],"topic":"msg.payload","x":120,"y":140,"wires":[["e1ba89f7bded151a"]]},{"id":"85fee20f9cceed0e","type":"ui_multistate_switch","z":"5c22dc58c00d6d57","g":"a9ee9143e3a2a6b3","name":"vytazovanie","group":"","order":1,"width":0,"height":1,"label":"Vyťažovanie","stateField":"payload","enableField":"enable","passthroughField":"passthrough","inputMsgField":"inputmsg","rounded":true,"useThemeColors":false,"hideSelectedLabel":false,"multilineLabel":false,"passThrough":"change","inputMsg":"none","userInput":"enabled_show","options":[{"label":"Vypnuté","value":"false","valueType":"bool","color":"#ff0019"},{"label":"Zapnuté","value":"true","valueType":"bool","color":"#009900"}],"topic":"msg.payload","x":130,"y":80,"wires":[["25e4887cfbfb3b2a"]]},{"id":"25e4887cfbfb3b2a","type":"function","z":"5c22dc58c00d6d57","g":"a9ee9143e3a2a6b3","name":"context-flow","func":"// Change Node nastavenie\nmsg.topic = \"vytazovanie\";\nflow.set(\"vytazovanie\", msg.payload);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":80,"wires":[[]]},{"id":"e1ba89f7bded151a","type":"function","z":"5c22dc58c00d6d57","g":"a9ee9143e3a2a6b3","name":"context-flow","func":"// Change Node nastavenie\nmsg.topic = \"prepinac\";\nflow.set(\"prepinac\", msg.payload);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":140,"wires":[[]]},{"id":"24175936f23b4cf3","type":"function","z":"5c22dc58c00d6d57","name":"topic temperature","func":"msg.topic = 'temperature'\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":320,"wires":[["df09d5bc174815ed"]]},{"id":"5badd2903a1bc8a7","type":"inject","z":"5c22dc58c00d6d57","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"80","payloadType":"num","x":130,"y":360,"wires":[["24175936f23b4cf3"]]},{"id":"bda2d11e53c3ca8b","type":"debug","z":"5c22dc58c00d6d57","name":"debug 2564","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":220,"wires":[]},{"id":"b323fff3ebe7e8ee","type":"inject","z":"5c22dc58c00d6d57","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"79","payloadType":"num","x":130,"y":400,"wires":[["24175936f23b4cf3"]]}]
I don't know what is changed in this flow, except that there is added debug at the output, join and ete inserting a different temperature and SOC, but this flow does not turn on the spiral1 at all, it just writes it at the output of the function. And he also sends only that one message over and over again.... As far as I know, you send me the same function code, but it still only sends that one message "spiral1 1".The values/messages to the join are fine, it is also stored in the context flow as it should.
Yes, it was only to get a signal out of the 'joinnode'.
I'm trying to understand what you want.
There will be a new feature tomorrow.
my idea was to measure the temperature, soc and power that goes to the battery (bat) and on the basis of that turn on the coils.. if the polling is on and the temperature is less than 80 and the soc is greater than 80 and 1400w goes to the battery, then send the right 'spirala1 1 ´ which means that it turns on spiral 1. If the power to the battery increases to 1400 again and spiral 1 is switched on and spiral 2 and spiral 3 are turned off, then it turns on spiral 2 (the node sends from the right ´spiral 2 1). if again the power to the battery increases to 1400 and spirals 1 and 2 are switched on, so it turns on the spiral3 (sends the message 'spirala3 1'). If the output to the battery drops below 30, it checks which of the savers are switched on and gradually turns off one, and again checks whether the output is to the battery.. if it is still below 30 so it checks which coils are on and turns off the next one and so on... Of course, when during this process the temperature drops below 80 or the temperature rises above 80, it turns off all the coils. ..
So what you are saying, by that statement, is the temperatue must be exactly 80 degrees to turn the coils on. Is that really what you want to happen, as it seems a very tight requirement?
Can i suggest you simplify this as you are stuggling with the discrete message and join node concepts
When you talk about Spirals - i assume you mean heating coils in hot water systems - or do you mean standalone space heaters for rooms etc ?
Anyway what i would suggest is this
-
Take the output from each of your nodes that generate the messages and pipe them to a change node (1 for each input)
-
Have that change node set a Context variable - in your cae that could be Battery.SOC, Battery.Temperature, Battery.power
This is then a discrete function that every time it receives an input from the Battery system will update the contect variables.
You can then use your function node to retrieve this Context variable and put each of the properties into a variable within the function node
The advantage of this approach is that you do not have to wait for the 3 inputs to process the function - there will always be a value in the context variable and as such your function node can process away
Once you have this working - it is then easy to sequence the turning on or off of your spirals based on (presumably) the Power available from the battery/PV system.
Craig
No, no, if the temperature reaches 80 or more, it will turn off all spirals. If the temperature drops below 80, it will also turn off all spirals.
Sorry - that still doesn't make sense to me.
In fact your last statement means the spirals will NEVER turn ON.
For example (according to your last statement)...
if the temperature is 79 - the spirals are OFF
if the temperature is 80 - the spirals are OFF
if the temperature is 81 - the spirals are OFF
Can I ask... at what temperature do you think the spirals will or should turn ON ?