Lock and Unlock input module channels
This uses a TCP node to directly inject values into VelServ
Velbus Input modules can have their channels disabled for a period of time or permanently.
This flow demonstrates how channels can be disabled for 10 seconds.
You’ll notice that groups of channels can be disabled / enabled in a single packet.
[
{
"id": "81eaba1c.e3e6e8",
"type": "function",
"z": "1233381f.cbcdb8",
"name": "Lock Channel for 10 seconds",
"func": "var address = \"A0\"; // Hex address of Input Module\nvar channel = \"01\"; // Hex value of Channel No 3 of module, derived from a bit array = 00100 (as in =bin2hex(00100) in a spreadsheet )\n\n\n\n// a is the Start of Packet - 0F\n// b is the priority - Low FB, Hight F8\n// c is the base address of the module\n// d is the amount of bytes in the packet, for program group this is 02\n// e is the command - in this case 12 - Forced OFF, with Timeout, 13 Cancel force OFF\n// f is the channel number, as set by 'channel' above\n// g is high byte of time\n// h is middle byte of time\n// i is low byte of time\n// eop is End of Packet - always 04\n\n\nvar a = '0f', b = 'F8', c = address, d = '05', e = '12', f = '00', g = '00', h = '00', i = '00', y = 'ff';\nvar checksum = \"\";\nvar eop = \"04\";\n\nvar incoming = String(msg.payload);\nvar buffer = \"\"\n\n\nvar newMsg = { payload:incoming };\n\n\n// if (incoming === 'LOCK' ) { // Uncomment if filtering\n// Lock channel \n c = address;\n// f = channel; // uncomment to use channel value as set in header\n f = incoming.toString(16); // Comment out to use channel value as set in header\n g = '00'; // High byte of timeout\n h = '00'; // middle byte of timeout\n i = '0a'; // low byte of timeout, in seconds (For example '0A' is 10 seconds)\n \n\n\n checksum = parseInt(a, 16) + parseInt(b, 16)+ parseInt(c, 16)+ parseInt(d, 16)+ parseInt(e, 16)+ parseInt(f, 16)+ parseInt(g, 16)+ parseInt(h, 16)+ parseInt(i, 16);\n checksum = checksum.toString(16);\n checksum = (parseInt(\"FFFF\",16) - parseInt(checksum,16));\n checksum = (parseInt(checksum,10)) + 257;\n checksum = checksum.toString(16);\n checksum = checksum.slice(-2);\n\n\n newMsg.payload = checksum;\n\n\nbuffer = Buffer.from([\"0x\"+a.toString(16),\"0x\"+b.toString(16),\"0x\"+c.toString(16),\"0x\"+d.toString(16),\"0x\"+e.toString(16),\"0x\"+f.toString(16),\"0x\"+g.toString(16),\"0x\"+h.toString(16),\"0x\"+i.toString(16),\"0x\"+checksum,0x04])\nreturn [{payload:buffer},newMsg];\n\n\n//\t} // Uncomment if filtering\n\n\t\n// return [msg,newMsg]; // uncomment if using IF statement",
"outputs": 2,
"noerr": 0,
"x": 580,
"y": 1360,
"wires": [
[
"710aad6a.7e9ba4",
"e297be30.26819"
],
[
"697d4733.d0d308"
]
],
"outputLabels": [
"Payload, Buffer value to TCP port",
"Checksum in HEX"
]
},
{
"id": "710aad6a.7e9ba4",
"type": "debug",
"z": "1233381f.cbcdb8",
"name": "Full TCP Buffer content",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"x": 1150,
"y": 1260,
"wires": []
},
{
"id": "697d4733.d0d308",
"type": "debug",
"z": "1233381f.cbcdb8",
"name": "Velbus packet Checksum",
"active": true,
"tosidebar": false,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"x": 1210,
"y": 1460,
"wires": []
},
{
"id": "b8f1b813.31b8b8",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock All",
"topic": "",
"payload": "FF",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 230,
"y": 1360,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "e297be30.26819",
"type": "tcp out",
"z": "1233381f.cbcdb8",
"host": "127.0.0.1",
"port": "6000",
"beserver": "client",
"base64": false,
"end": true,
"name": "Velserv OUT",
"x": 1150,
"y": 1360,
"wires": []
},
{
"id": "d9558ad7.3776e8",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock Channel 1",
"topic": "",
"payload": "1",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 260,
"y": 1400,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "34f78464.63ee1c",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock Channel 2",
"topic": "",
"payload": "2",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 260,
"y": 1440,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "a5bae3ef.181a9",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock Channel 3",
"topic": "",
"payload": "4",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 260,
"y": 1480,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "12032eb6.d12341",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock Channel 4",
"topic": "",
"payload": "8",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 260,
"y": 1520,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "58089764.3aafe8",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock Channel 5",
"topic": "",
"payload": "10",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 260,
"y": 1560,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "88ca3d61.5b729",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock Channel 6",
"topic": "",
"payload": "20",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 260,
"y": 1600,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "de753314.c7307",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock Channel 7",
"topic": "",
"payload": "40",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 260,
"y": 1640,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "168c9f60.b57dd1",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock Channel 8",
"topic": "",
"payload": "80",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 260,
"y": 1680,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "a41a3968.6539d8",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock Even Channels",
"topic": "",
"payload": "AA",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 250,
"y": 1720,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "a242c8fe.b54628",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "Lock ODD Channels",
"topic": "",
"payload": "55",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 250,
"y": 1760,
"wires": [
[
"81eaba1c.e3e6e8"
]
]
},
{
"id": "ec3291b5.089b",
"type": "function",
"z": "1233381f.cbcdb8",
"name": "Unlock Channel",
"func": "var address = \"A0\"; // Hex address of Input Module\nvar channel = \"01\"; // Hex value of Channel No 3 of module, derived from a bit array = 00100 (as in =bin2hex(00100) in a spreadsheet )\n\n\n\n// a is the Start of Packet - 0F\n// b is the priority - Low FB, Hight F8\n// c is the base address of the module\n// d is the amount of bytes in the packet, for program group this is 02\n// e is the command - in this case 13 Cancel force OFF\n// f is the channel number, as set by 'channel' above\n// g is high byte of time\n// h is middle byte of time\n// i is low byte of time\n// eop is End of Packet - always 04\n\n\nvar a = '0f', b = 'F8', c = address, d = '02', e = '13', f = '00', g = '00', h = '00', i = '00', y = 'ff';\nvar checksum = \"\";\nvar eop = \"04\";\n\nvar incoming = String(msg.payload);\nvar buffer = \"\"\n\n\nvar newMsg = { payload:incoming };\n\n\n// if (incoming === 'UNLOCK' ) { // Uncomment if filtering\n// Unlock channel \n c = address;\n d = '02';\n// f = channel; // uncomment to use channel value as set in header\n f = incoming.toString(16); // Comment out to use channel value as set in header\n// g = '00'; // High byte of timeout\n// h = '00'; // middle byte of timeout\n// i = '0a'; // low byte of timeout, in seconds (For example '0A' is 10 seconds)\n \n\n\n checksum = parseInt(a, 16) + parseInt(b, 16)+ parseInt(c, 16)+ parseInt(d, 16)+ parseInt(e, 16)+ parseInt(f, 16);\n checksum = checksum.toString(16);\n checksum = (parseInt(\"FFFF\",16) - parseInt(checksum,16));\n checksum = (parseInt(checksum,10)) + 257;\n checksum = checksum.toString(16);\n checksum = checksum.slice(-2);\n\n\n newMsg.payload = checksum;\n\n\nbuffer = Buffer.from([\"0x\"+a.toString(16),\"0x\"+b.toString(16),\"0x\"+c.toString(16),\"0x\"+d.toString(16),\"0x\"+e.toString(16),\"0x\"+f.toString(16),\"0x\"+checksum,0x04])\nreturn [{payload:buffer},newMsg];\n\n\n//\t} // Uncomment if filtering\n\n\t\n// return [msg,newMsg]; // uncomment if using IF statement",
"outputs": 2,
"noerr": 0,
"x": 840,
"y": 1520,
"wires": [
[
"e297be30.26819",
"710aad6a.7e9ba4"
],
[
"697d4733.d0d308"
]
],
"outputLabels": [
"Payload, Buffer value to TCP port",
"Checksum in HEX"
]
},
{
"id": "592d71f0.7eb81",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock All",
"topic": "",
"payload": "FF",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 540,
"y": 1520,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "9af0f060.43a44",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock Channel 1",
"topic": "",
"payload": "1",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 570,
"y": 1560,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "dc8a583e.d2e628",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock Channel 2",
"topic": "",
"payload": "2",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 570,
"y": 1600,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "7f032873.744308",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock Channel 3",
"topic": "",
"payload": "4",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 570,
"y": 1640,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "a1213a05.af15e8",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock Channel 4",
"topic": "",
"payload": "8",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 570,
"y": 1680,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "46727131.59a68",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock Channel 5",
"topic": "",
"payload": "10",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 570,
"y": 1720,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "faab023b.f5ca6",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock Channel 6",
"topic": "",
"payload": "20",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 570,
"y": 1760,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "7a6aad8d.ec96f4",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock Channel 7",
"topic": "",
"payload": "40",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 570,
"y": 1800,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "92283226.4193a",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock Channel 8",
"topic": "",
"payload": "80",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 570,
"y": 1840,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "d0431189.daa83",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock Even Channels",
"topic": "",
"payload": "AA",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 580,
"y": 1880,
"wires": [
[
"ec3291b5.089b"
]
]
},
{
"id": "4d060314.57bcdc",
"type": "inject",
"z": "1233381f.cbcdb8",
"name": "UnLock ODD Channels",
"topic": "",
"payload": "55",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 580,
"y": 1920,
"wires": [
[
"ec3291b5.089b"
]
]
}
]
