Skip to content

Instantly share code, notes, and snippets.

@MatsA
Last active November 15, 2024 15:26
Show Gist options
  • Save MatsA/1d61e47eeb2c76e3958d3f7766ce0f22 to your computer and use it in GitHub Desktop.
Save MatsA/1d61e47eeb2c76e3958d3f7766ce0f22 to your computer and use it in GitHub Desktop.
Modbus RTU gateway
[
{
"id": "7ee227b81ec212ad",
"type": "tab",
"label": "Swegon RTU Server & Client",
"disabled": false,
"info": "",
"env": [],
"_mcu": {
"mcu": false
}
},
{
"id": "c7f7731101aa3453",
"type": "http in",
"z": "7ee227b81ec212ad",
"name": "",
"url": "/modbus/flex/read",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 220,
"y": 100,
"wires": [
[
"c462771353757f19"
]
]
},
{
"id": "c462771353757f19",
"type": "modbus-flex-getter",
"z": "7ee227b81ec212ad",
"name": "",
"showStatusActivities": false,
"showErrors": false,
"showWarnings": true,
"logIOActivities": false,
"server": "02330a92ab2124a0",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"keepMsgProperties": true,
"delayOnStart": false,
"startDelayTime": "",
"x": 460,
"y": 100,
"wires": [
[
"b9be1db6360db952",
"8d9e75a0a3b7a668"
],
[
"f9c50779c12ada62"
]
]
},
{
"id": "f9c50779c12ada62",
"type": "modbus-response",
"z": "7ee227b81ec212ad",
"name": "",
"registerShowMax": 20,
"x": 210,
"y": 160,
"wires": []
},
{
"id": "b9be1db6360db952",
"type": "debug",
"z": "7ee227b81ec212ad",
"name": "Msg object",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 710,
"y": 100,
"wires": []
},
{
"id": "8d9e75a0a3b7a668",
"type": "http response",
"z": "7ee227b81ec212ad",
"name": "",
"statusCode": "",
"headers": {},
"x": 690,
"y": 140,
"wires": []
},
{
"id": "802c10d393a45b73",
"type": "comment",
"z": "7ee227b81ec212ad",
"name": "MODBUS RTU Server",
"info": "",
"x": 220,
"y": 60,
"wires": []
},
{
"id": "3fe3c2ab31244f44",
"type": "http in",
"z": "7ee227b81ec212ad",
"name": "",
"url": "/modbus/flex/write",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 220,
"y": 220,
"wires": [
[
"ca686aacbaf545c4"
]
]
},
{
"id": "d0fded9180d5b13f",
"type": "http response",
"z": "7ee227b81ec212ad",
"name": "",
"statusCode": "",
"headers": {},
"x": 690,
"y": 260,
"wires": []
},
{
"id": "00064aabd0983f2a",
"type": "modbus-response",
"z": "7ee227b81ec212ad",
"name": "",
"registerShowMax": 20,
"x": 210,
"y": 280,
"wires": []
},
{
"id": "e0d700fc9b17b919",
"type": "debug",
"z": "7ee227b81ec212ad",
"name": "Msg object",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 710,
"y": 220,
"wires": []
},
{
"id": "ca686aacbaf545c4",
"type": "modbus-flex-write",
"z": "7ee227b81ec212ad",
"name": "",
"showStatusActivities": false,
"showErrors": false,
"showWarnings": true,
"server": "02330a92ab2124a0",
"emptyMsgOnFail": false,
"keepMsgProperties": true,
"delayOnStart": false,
"startDelayTime": "",
"x": 450,
"y": 220,
"wires": [
[
"e0d700fc9b17b919",
"d0fded9180d5b13f"
],
[
"00064aabd0983f2a"
]
]
},
{
"id": "f04cc6cd8abdedc2",
"type": "change",
"z": "7ee227b81ec212ad",
"name": "temp",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\t \"fc\": 4,\t \"address\": 6200,\t \"quantity\": 12\t}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"_mcu": {
"mcu": false
},
"x": 370,
"y": 520,
"wires": [
[
"36d2406d014330f6"
]
]
},
{
"id": "3186157b3375119f",
"type": "inject",
"z": "7ee227b81ec212ad",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "60",
"crontab": "",
"once": true,
"onceDelay": "10",
"topic": "",
"payload": "",
"payloadType": "date",
"_mcu": {
"mcu": false
},
"x": 210,
"y": 540,
"wires": [
[
"f04cc6cd8abdedc2",
"eacb8a97e8181b2f",
"d4215838d14993ef",
"078b8ceeac941ba9",
"e3cd8d9b3a6579df"
]
]
},
{
"id": "36d2406d014330f6",
"type": "http request",
"z": "7ee227b81ec212ad",
"name": "Flex read",
"method": "GET",
"ret": "obj",
"paytoqs": "query",
"url": "http://test.local:1880/modbus/flex/read",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"_mcu": {
"mcu": false
},
"x": 520,
"y": 520,
"wires": [
[
"08c4df376d72e492"
]
]
},
{
"id": "ba954c5377d60c4f",
"type": "debug",
"z": "7ee227b81ec212ad",
"name": "debug 7",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"_mcu": {
"mcu": false
},
"x": 840,
"y": 400,
"wires": []
},
{
"id": "08c4df376d72e492",
"type": "function",
"z": "7ee227b81ec212ad",
"name": "temp",
"func": "let tempInDiff = 0\nlet tempOutDiff = 0\n\nlet outDoor = {};\noutDoor.payload = msg.payload[10] / 10;\noutDoor.topic = \"Temp outdoor °C\";\n\nlet supAir = {}\nsupAir.payload = msg.payload[2] / 10;\nsupAir.topic = \"Temp supply air °C\";\n\nlet extAir = {}\nextAir.payload = msg.payload[5] / 10;\nextAir.topic = \"Temp extract air °C\";\n\nlet exhAir = {}\nexhAir.payload = msg.payload[4] / 10;\nexhAir.topic = \"Temp exhaust air °C\";\n\ntempInDiff = supAir.payload - outDoor.payload\ntempOutDiff = extAir.payload - exhAir.payload\n\n// node.warn(tempInDiff);\n// node.warn(tempOutDiff);\n\nlet eff = {}\neff.payload = (Math.round(100 * (tempOutDiff / tempInDiff)) / 10);\neff.topic = \"FTX efficiency 10 x %\";\n\nreturn [outDoor, supAir, extAir, exhAir, eff];",
"outputs": 5,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"_mcu": {
"mcu": false
},
"x": 650,
"y": 520,
"wires": [
[
"ac8408626da9efea"
],
[
"ac8408626da9efea"
],
[
"ac8408626da9efea"
],
[
"ac8408626da9efea"
],
[
"ac8408626da9efea"
]
]
},
{
"id": "ac8408626da9efea",
"type": "ui_chart",
"z": "7ee227b81ec212ad",
"name": "",
"group": "d497830247ab26c1",
"order": 5,
"width": 0,
"height": 0,
"label": "Misc temp data",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": "3",
"removeOlderPoints": "",
"removeOlderUnit": "86400",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"_mcu": {
"mcu": false
},
"x": 860,
"y": 520,
"wires": [
[]
]
},
{
"id": "3276c2ac93f55ba5",
"type": "function",
"z": "7ee227b81ec212ad",
"name": "Fan %",
"func": "\nlet fanSupply = {};\nfanSupply.payload = msg.payload[2];\nfanSupply.topic = \"Fan supply %\";\n\nlet fanExhaust = {}\nfanExhaust.payload = msg.payload[3];\nfanExhaust.topic = \"Fan exhaust %\";\n\nreturn [fanSupply, fanExhaust];\n",
"outputs": 2,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"_mcu": {
"mcu": false
},
"x": 650,
"y": 580,
"wires": [
[
"c8aaad6df50a359d"
],
[
"c8aaad6df50a359d"
]
]
},
{
"id": "99c59ca3f9651390",
"type": "function",
"z": "7ee227b81ec212ad",
"name": "Mode",
"func": "// Swegon reg. 6434\n\nswitch (msg.payload[0]) {\n case 0:\n msg.payload = \"Stopped\";\n break;\n case 1 :\n msg.payload = \"Traveling\";\n break;\n case 2:\n msg.payload = \"Away\";\n break;\n case 3:\n msg.payload = \"Home\";\n break;\n case 4:\n msg.payload = \"Home +\";\n break;\n case 5:\n msg.payload = \"Boost\";\n break;\n case 6:\n msg.payload = \"Fireplace\";\n break;\n default:\n msg.payload = \"Error\"\n}\n\nreturn msg",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"_mcu": {
"mcu": false
},
"x": 650,
"y": 460,
"wires": [
[
"8fb0cf71f0f77e37"
]
]
},
{
"id": "dffe518aef60802e",
"type": "function",
"z": "7ee227b81ec212ad",
"name": "Rotor % RPM",
"func": "/*\n\nmsg.topic = \"rotor\"\n\nmsg.payload =\n{\n 'fc': 4,\n 'address': 6331,\n 'quantity': 1\n};\n\n\n*/\n\nmsg.payload = msg.payload[0];\nmsg.topic = \"Rotor %\";\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"_mcu": {
"mcu": false
},
"x": 680,
"y": 660,
"wires": [
[
"c8aaad6df50a359d"
]
]
},
{
"id": "eacb8a97e8181b2f",
"type": "change",
"z": "7ee227b81ec212ad",
"name": "fan",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\t \"fc\": 4,\t \"address\": 6300,\t \"quantity\": 10\t}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"_mcu": {
"mcu": false
},
"x": 370,
"y": 580,
"wires": [
[
"a2ad27c0fda02c03"
]
]
},
{
"id": "a2ad27c0fda02c03",
"type": "http request",
"z": "7ee227b81ec212ad",
"name": "Flex read",
"method": "GET",
"ret": "obj",
"paytoqs": "query",
"url": "http://test.local:1880/modbus/flex/read",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"_mcu": {
"mcu": false
},
"x": 520,
"y": 580,
"wires": [
[
"3276c2ac93f55ba5"
]
]
},
{
"id": "d4215838d14993ef",
"type": "change",
"z": "7ee227b81ec212ad",
"name": "rotor %",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\t \"fc\": 4,\t \"address\": 6331,\t \"quantity\": 1\t}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"_mcu": {
"mcu": false
},
"x": 380,
"y": 660,
"wires": [
[
"067fa9114b6fe9c0"
]
]
},
{
"id": "067fa9114b6fe9c0",
"type": "http request",
"z": "7ee227b81ec212ad",
"name": "Flex read",
"method": "GET",
"ret": "obj",
"paytoqs": "query",
"url": "http://test.local:1880/modbus/flex/read",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"_mcu": {
"mcu": false
},
"x": 520,
"y": 660,
"wires": [
[
"dffe518aef60802e"
]
]
},
{
"id": "c8aaad6df50a359d",
"type": "ui_chart",
"z": "7ee227b81ec212ad",
"name": "",
"group": "d497830247ab26c1",
"order": 6,
"width": 0,
"height": 0,
"label": "Fan, rotor, heater % of max",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "0",
"ymax": "100",
"removeOlder": "3",
"removeOlderPoints": "",
"removeOlderUnit": "86400",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"_mcu": {
"mcu": false
},
"x": 900,
"y": 620,
"wires": [
[]
]
},
{
"id": "078b8ceeac941ba9",
"type": "change",
"z": "7ee227b81ec212ad",
"name": "Post heat",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\t \"fc\": 4,\t \"address\": 6317,\t \"quantity\": 1\t}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"_mcu": {
"mcu": false
},
"x": 380,
"y": 620,
"wires": [
[
"0f3553860771cdde"
]
]
},
{
"id": "0f3553860771cdde",
"type": "http request",
"z": "7ee227b81ec212ad",
"name": "Flex read",
"method": "GET",
"ret": "obj",
"paytoqs": "query",
"url": "http://test.local:1880/modbus/flex/read",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"_mcu": {
"mcu": false
},
"x": 520,
"y": 620,
"wires": [
[
"c77d7ba7efaa0db9"
]
]
},
{
"id": "c77d7ba7efaa0db9",
"type": "function",
"z": "7ee227b81ec212ad",
"name": "Heater %",
"func": "\n\nmsg.payload = msg.payload[0];\nmsg.topic = \"Heater %\";\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"_mcu": {
"mcu": false
},
"x": 660,
"y": 620,
"wires": [
[
"c8aaad6df50a359d"
]
]
},
{
"id": "8fb0cf71f0f77e37",
"type": "ui_text",
"z": "7ee227b81ec212ad",
"group": "d497830247ab26c1",
"order": 1,
"width": 3,
"height": 1,
"name": "",
"label": "<b> Mode;</b>",
"format": "{{msg.payload}}",
"layout": "row-left",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"_mcu": {
"mcu": false
},
"x": 860,
"y": 460,
"wires": []
},
{
"id": "e3cd8d9b3a6579df",
"type": "change",
"z": "7ee227b81ec212ad",
"name": "Mode",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\t \"fc\": 4,\t \"address\": 6433,\t \"quantity\": 1\t}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"_mcu": {
"mcu": false
},
"x": 370,
"y": 460,
"wires": [
[
"27d5778b606b241f"
]
]
},
{
"id": "27d5778b606b241f",
"type": "http request",
"z": "7ee227b81ec212ad",
"name": "Flex read",
"method": "GET",
"ret": "obj",
"paytoqs": "query",
"url": "http://test.local:1880/modbus/flex/read",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"_mcu": {
"mcu": false
},
"x": 520,
"y": 460,
"wires": [
[
"99c59ca3f9651390"
]
]
},
{
"id": "6dc7f2e7d2c10671",
"type": "change",
"z": "7ee227b81ec212ad",
"name": "Set Mode",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\t \"value\": msg.payload,\t \"fc\": 6,\t \"address\": 5000,\t \"quantity\": 1\t}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"_mcu": {
"mcu": false
},
"x": 380,
"y": 400,
"wires": [
[
"65c49f0d76ddcf4a"
]
]
},
{
"id": "65c49f0d76ddcf4a",
"type": "http request",
"z": "7ee227b81ec212ad",
"name": "Flex write",
"method": "GET",
"ret": "obj",
"paytoqs": "query",
"url": "http://test.local:1880/modbus/flex/write",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"_mcu": {
"mcu": false
},
"x": 520,
"y": 400,
"wires": [
[
"ba954c5377d60c4f",
"e3cd8d9b3a6579df"
]
]
},
{
"id": "c23020b4aa9504ec",
"type": "ui_dropdown",
"z": "7ee227b81ec212ad",
"name": "Set new mode",
"label": "<b> Set new mode; </b>",
"tooltip": "",
"place": "Select option",
"group": "d497830247ab26c1",
"order": 2,
"width": 6,
"height": 1,
"passthru": true,
"multiple": false,
"options": [
{
"label": "Shut down",
"value": "0",
"type": "str"
},
{
"label": "Travelling",
"value": "4",
"type": "str"
},
{
"label": "Away",
"value": "1",
"type": "str"
},
{
"label": "Home",
"value": "2",
"type": "str"
},
{
"label": "Home +",
"value": "5",
"type": "str"
},
{
"label": "Boost",
"value": "3",
"type": "str"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"_mcu": {
"mcu": false
},
"x": 200,
"y": 400,
"wires": [
[
"6dc7f2e7d2c10671"
]
]
},
{
"id": "874e72d2691ff820",
"type": "comment",
"z": "7ee227b81ec212ad",
"name": "Modbus client",
"info": "",
"_mcu": {
"mcu": false
},
"x": 190,
"y": 340,
"wires": []
},
{
"id": "02330a92ab2124a0",
"type": "modbus-client",
"name": "Test 2",
"clienttype": "simpleser",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"failureLogEnabled": true,
"tcpHost": "127.0.0.1",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB0",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "38400",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": "1",
"commandDelay": "1",
"clientTimeout": "1000",
"reconnectOnTimeout": true,
"reconnectTimeout": "2000",
"parallelUnitIdsAllowed": true,
"showErrors": false,
"showWarnings": true,
"showLogs": true
},
{
"id": "d497830247ab26c1",
"type": "ui_group",
"name": "Swegon Casa R7 Genius",
"tab": "4eca7a9d477b6296",
"order": 1,
"disp": true,
"width": "15",
"collapse": false,
"className": ""
},
{
"id": "4eca7a9d477b6296",
"type": "ui_tab",
"name": "Swegon",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment