Hello friends.
I try to create a routine where my pump will dose for a given time, then wait and start dosing again.
For this i created 3 fields. One field where i can ENABLE or DISABLE this routine and 3 input fields where i can enter a dosing time and an interval time (how long the pump should not dose). I get this free values from my mqtt server
I read much about how to complete my task but (as always) i stuck. I read that the trigger node may be the correct tool, this is what i have so far. I think my problem is that i cant create a loop:
[
{
"id": "be8463690b65c6df",
"type": "mqtt in",
"z": "d51b33bb70359ba8",
"name": "",
"topic": "CIM500/W_TimerManual",
"qos": "2",
"datatype": "json",
"broker": "b6502b0e06f48d91",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 220,
"y": 3020,
"wires": [
[
"250387881f18addd"
]
]
},
{
"id": "738b4671b374f614",
"type": "mqtt in",
"z": "d51b33bb70359ba8",
"name": "",
"topic": "CIM500/W_TM_DosTime",
"qos": "2",
"datatype": "json",
"broker": "b6502b0e06f48d91",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 220,
"y": 3060,
"wires": [
[
"52926592a348fc92"
]
]
},
{
"id": "8b6e23efd107d4e1",
"type": "mqtt in",
"z": "d51b33bb70359ba8",
"name": "",
"topic": "CIM500/W_TM_Interval",
"qos": "2",
"datatype": "json",
"broker": "b6502b0e06f48d91",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 210,
"y": 3100,
"wires": [
[
"f183aa1d87cd6dc0"
]
]
},
{
"id": "250387881f18addd",
"type": "function",
"z": "d51b33bb70359ba8",
"name": "set_global_TimerManual",
"func": "global.set(\"TimerManual\",msg.payload)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 500,
"y": 3020,
"wires": [
[
"d52ae55726dcd6df"
]
]
},
{
"id": "52926592a348fc92",
"type": "function",
"z": "d51b33bb70359ba8",
"name": "set_global_DosTime",
"func": "global.set(\"DosTime\",msg.payload)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 3060,
"wires": [
[
"d52ae55726dcd6df"
]
]
},
{
"id": "f183aa1d87cd6dc0",
"type": "function",
"z": "d51b33bb70359ba8",
"name": "set_global_Interval",
"func": "global.set(\"Interval\",msg.payload)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 3100,
"wires": [
[
"d52ae55726dcd6df"
]
]
},
{
"id": "d0e3b835a8ee77c9",
"type": "modbus-flex-write",
"z": "d51b33bb70359ba8",
"name": "",
"showStatusActivities": true,
"showErrors": true,
"server": "0e3ec676f3e39293",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 1880,
"y": 2920,
"wires": [
[],
[]
]
},
{
"id": "a44dc45abb4e4060",
"type": "function",
"z": "d51b33bb70359ba8",
"name": "SHUT PUMP ON",
"func": "return msg\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1030,
"y": 2920,
"wires": [
[
"73dcc0ae1a4e4757"
]
]
},
{
"id": "686855ad599dd51a",
"type": "switch",
"z": "d51b33bb70359ba8",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "true"
},
{
"t": "false"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 910,
"y": 3060,
"wires": [
[
"a44dc45abb4e4060"
],
[
"2f14c30c74426a0d"
]
]
},
{
"id": "2f14c30c74426a0d",
"type": "function",
"z": "d51b33bb70359ba8",
"name": "SGUT PUMP OFF",
"func": "msg.payload = 1\n\n\nreturn msg\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1070,
"y": 3180,
"wires": [
[
"c0b87d11400db173"
]
]
},
{
"id": "0d6f29dd2827266e",
"type": "function",
"z": "d51b33bb70359ba8",
"name": "modbus_write_103",
"func": "var fc = 6;\nvar sa = 103;\nvar addresses = 1;\nvar value = msg.payload; // value calculated from buffer-parser\nmsg.slave_ip = \"10.240.6.39\";\n\nmsg.payload = { \"value\": value, 'fc': fc, 'unitid': 1, 'address': sa, 'quantity': addresses };\n\nreturn msg;",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1620,
"y": 2920,
"wires": [
[
"d0e3b835a8ee77c9"
],
[]
]
},
{
"id": "c0b87d11400db173",
"type": "function",
"z": "d51b33bb70359ba8",
"name": "modbus_write_103",
"func": "var fc = 6;\nvar sa = 103;\nvar addresses = 1;\nvar value = msg.payload; // value calculated from buffer-parser\nmsg.slave_ip = \"10.240.6.39\";\n\nmsg.payload = { \"value\": 1, 'fc': fc, 'unitid': 1, 'address': sa, 'quantity': addresses };\n\nreturn msg;",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1300,
"y": 3180,
"wires": [
[
"02db519a558c29f2"
],
[]
]
},
{
"id": "02db519a558c29f2",
"type": "modbus-flex-write",
"z": "d51b33bb70359ba8",
"name": "",
"showStatusActivities": true,
"showErrors": true,
"server": "0e3ec676f3e39293",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 1540,
"y": 3180,
"wires": [
[],
[]
]
},
{
"id": "73dcc0ae1a4e4757",
"type": "trigger",
"z": "d51b33bb70359ba8",
"name": "this should be the dosetime",
"op1": "0",
"op2": "1",
"op1type": "str",
"op2type": "str",
"duration": "5",
"extend": false,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 1310,
"y": 2920,
"wires": [
[
"0d6f29dd2827266e",
"5cb5d15b08c4485d",
"647adcf5cc75da4c"
]
]
},
{
"id": "d52ae55726dcd6df",
"type": "function",
"z": "d51b33bb70359ba8",
"name": "",
"func": "var ManualTimer = global.get(\"TimerManual\")\nmsg.payload = ManualTimer\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 740,
"y": 3060,
"wires": [
[
"686855ad599dd51a"
]
]
},
{
"id": "a5dd8375ea185f5d",
"type": "change",
"z": "d51b33bb70359ba8",
"name": "",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "TRUE",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1240,
"y": 3000,
"wires": [
[
"73dcc0ae1a4e4757"
]
]
},
{
"id": "647adcf5cc75da4c",
"type": "switch",
"z": "d51b33bb70359ba8",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "str"
},
{
"t": "eq",
"v": "1",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1510,
"y": 3060,
"wires": [
[],
[
"a5dd8375ea185f5d"
]
]
},
{
"id": "5cb5d15b08c4485d",
"type": "debug",
"z": "d51b33bb70359ba8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1280,
"y": 2820,
"wires": []
},
{
"id": "f14eca3072b75cf1",
"type": "delay",
"z": "d51b33bb70359ba8",
"name": "Intervall (wait)",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 1720,
"y": 3020,
"wires": [
[]
]
},
{
"id": "b6502b0e06f48d91",
"type": "mqtt-broker",
"name": "",
"broker": "185.164.7.227",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
},
{
"id": "0e3ec676f3e39293",
"type": "modbus-client",
"name": "CIM500",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"tcpHost": "10.240.6.39",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": "1",
"commandDelay": "1",
"clientTimeout": "1000",
"reconnectOnTimeout": true,
"reconnectTimeout": "2000",
"parallelUnitIdsAllowed": true
}
]
thank you