Greetings,
i’m having trouble updating the NodeRed program made by a student before me for the automation & manual control of ventilation system in the building & readings from Energy Meters & Impulse Flowmeters
He is using ModBus / TCP, i have not yet connected the ethernet to the Intel NUC nor am i sure will it work automatically and start reading from that cable to NodeRed on NUC.
I tried setting up a simple button in HA & sensor to see if it’s on off (low speed / high speed)
It looks like this in Node-Red:
[
{
"id": "44c6fae4.4e6134",
"type": "modbus-read",
"z": "97f2a942.7250c8",
"name": "",
"topic": "low",
"showStatusActivities": false,
"logIOActivities": false,
"showErrors": false,
"showWarnings": true,
"unitid": "1",
"dataType": "HoldingRegister",
"adr": "23",
"quantity": "2",
"rate": "1",
"rateUnit": "s",
"delayOnStart": false,
"startDelayTime": "",
"server": "10bb4c8a.889823",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"x": 250,
"y": 700,
"wires": [
[ "31d6e100.4b223" ],
[]
]
},
{
"id": "31d6e100.4b223",
"type": "function",
"z": "97f2a942.7250c8",
"name": "",
"func": "let v1 = msg.payload[0]\nlet v2 = msg.payload[1]\nlet v1payload = {payload: v1}\nlet v2payload = {payload: v2}\nif(v2 > v1 ) { return v2payload } \nelse {return v1payload}",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 500,
"y": 720,
"wires": [ [ "e65bf774.684768", "93f2a6e5.453a18", "8151a789e7acf2ce" ] ]
},
{
"id": "6daa681f.a2f868",
"type": "ui_text",
"z": "97f2a942.7250c8",
"group": "5703a672.163828",
"order": 6,
"width": 16,
"height": 1,
"name": "mala hitrost",
"label": "<font size = 6>Preostali čas mala hitrost: {{msg.payload}}",
"format": "",
"layout": "row-center",
"className": "",
"style": false,
"font": "",
"fontSize": "",
"color": "#000000",
"x": 1090,
"y": 720,
"wires": []
},
{
"id": "e65bf774.684768",
"type": "function",
"z": "97f2a942.7250c8",
"name": "",
"func": "let sec = msg.payload\nseconds = sec % 60\ntime = sec / 60\nminutes = time % 60\ntime /= 60\nhours = time % 24\nlet hoursint = parseInt(hours);\nlet minutesint = parseInt(minutes);\nlet secondsint = parseInt(seconds);\nlet string = new String (\"0min : 0sec\");\nlet stringsec = string.replace( seconds > 9 ? \"0sec\" : \"sec\" , secondsint );\nlet stringmin = stringsec.replace( minutes > 9 ? \"0min\" : \"min\" , minutesint );\n//let stringhour = stringmin.replace(hours > 9 ? \"0hour\" : \"hour\" , hoursint );\nreturn { payload:stringmin };",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 800,
"y": 720,
"wires": [ [ "6daa681f.a2f868", "8316ce12.4b12a" ] ]
},
{
"id": "8316ce12.4b12a",
"type": "debug",
"z": "97f2a942.7250c8",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1120,
"y": 820,
"wires": []
},
{
"id": "88d0efdb.b2f78",
"type": "modbus-read",
"z": "97f2a942.7250c8",
"name": "",
"topic": "low",
"showStatusActivities": false,
"logIOActivities": false,
"showErrors": false,
"unitid": "1",
"dataType": "HoldingRegister",
"adr": "25",
"quantity": "2",
"rate": "1",
"rateUnit": "s",
"delayOnStart": false,
"startDelayTime": "",
"server": "10bb4c8a.889823",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"x": 250,
"y": 920,
"wires": [
[ "c86fcb87.8b6f48" ],
[]
]
},
{
"id": "c86fcb87.8b6f48",
"type": "function",
"z": "97f2a942.7250c8",
"name": "",
"func": "let v1 = msg.payload[0]\nlet v2 = msg.payload[1]\nlet v1payload = {payload: v1}\nlet v2payload = {payload: v2}\nif(v2 > v1 ) { return v2payload } \nelse {return v1payload}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 500,
"y": 920,
"wires": [ [ "6325bb5a.e7f7b4", "321ad586.69460a", "228d85285ad7a359" ] ]
},
{
"id": "430fa8a.1bcc758",
"type": "ui_text",
"z": "97f2a942.7250c8",
"group": "5703a672.163828",
"order": 7,
"width": 16,
"height": 1,
"name": "velika hitrost",
"label": "<font size = 6>Preostali čas velika hitrost: {{msg.payload}}",
"format": "",
"layout": "row-center",
"x": 1090,
"y": 920,
"wires": []
},
{
"id": "73fdd17f.d10ee",
"type": "debug",
"z": "97f2a942.7250c8",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1120,
"y": 1020,
"wires": []
},
{
"id": "6325bb5a.e7f7b4",
"type": "debug",
"z": "97f2a942.7250c8",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 770,
"y": 1020,
"wires": []
},
{
"id": "93f2a6e5.453a18",
"type": "debug",
"z": "97f2a942.7250c8",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 810,
"y": 800,
"wires": []
},
{
"id": "321ad586.69460a",
"type": "function",
"z": "97f2a942.7250c8",
"name": "",
"func": "let sec = msg.payload\nseconds = sec % 60\ntime = sec / 60\nminutes = time % 60\ntime /= 60\nhours = time % 24\nlet hoursint = parseInt(hours);\nlet minutesint = parseInt(minutes);\nlet secondsint = parseInt(seconds);\nlet string = new String (\"0min : 0sec\");\nlet stringsec = string.replace( seconds > 9 ? \"0sec\" : \"sec\" , secondsint );\nlet stringmin = stringsec.replace( minutes > 9 ? \"0min\" : \"min\" , minutesint );\n//let stringhour = stringmin.replace(hours > 9 ? \"0hour\" : \"hour\" , hoursint );\nreturn { payload:stringmin };",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 820,
"y": 920,
"wires": [ [ "430fa8a.1bcc758", "73fdd17f.d10ee" ] ]
},
{
"id": "a6fb79af55b13b7f",
"type": "ha-button",
"z": "97f2a942.7250c8",
"name": "Vklop Velike Hitrosti",
"version": 0,
"debugenabled": false,
"outputs": 1,
"entityConfig": "99da321324b56385",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"x": 250,
"y": 980,
"wires": [ [ "c86fcb87.8b6f48" ] ]
},
{
"id": "8151a789e7acf2ce",
"type": "ha-binary-sensor",
"z": "97f2a942.7250c8",
"name": "Mala Hitrost Vklopljena",
"entityConfig": "116c04f6442dc194",
"version": 0,
"state": "true",
"stateType": "bool",
"attributes": [],
"inputOverride": "merge",
"outputProperties": [],
"x": 840,
"y": 860,
"wires": [ [] ]
},
{
"id": "228d85285ad7a359",
"type": "ha-binary-sensor",
"z": "97f2a942.7250c8",
"name": "Velika Hitrost Vklopljena",
"entityConfig": "a865c9ec458968fe",
"version": 0,
"state": "payload",
"stateType": "msg",
"attributes": [],
"inputOverride": "allow",
"outputProperties": [],
"x": 850,
"y": 1080,
"wires": [ [] ]
},
{
"id": "69f4cdd437f07e09",
"type": "ha-switch",
"z": "97f2a942.7250c8",
"name": "Vklop Male Hitrosti",
"version": 0,
"debugenabled": false,
"inputs": 0,
"outputs": 2,
"entityConfig": "e5e1b4c1fb7a3ec7",
"enableInput": false,
"outputOnStateChange": false,
"outputProperties": [
{
"property": "outputType",
"propertyType": "msg",
"value": "state change",
"valueType": "str"
},
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"x": 270,
"y": 780,
"wires": [
[ "31d6e100.4b223" ],
[]
]
},
{
"id": "10bb4c8a.889823",
"type": "modbus-client",
"name": "LOGO",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"tcpHost": "192.168.2.50",
"tcpPort": "505",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"unit_id": "1",
"commandDelay": "1",
"clientTimeout": "1000",
"reconnectOnTimeout": true,
"reconnectTimeout": "2000",
"parallelUnitIdsAllowed": true
},
{
"id": "5703a672.163828",
"type": "ui_group",
"name": "Ročno/auto/temperatura",
"tab": "9f7d7744.697db8",
"order": 2,
"disp": true,
"width": 16,
"collapse": true
},
{
"id": "99da321324b56385",
"type": "ha-entity-config",
"server": "b09259d4.60b188",
"deviceConfig": "91b7b4b9ca651569",
"name": "Potrdi Izbiro",
"version": 6,
"entityType": "button",
"haConfig": [
{
"property": "name",
"value": "Potrdi Izbiro Načina"
},
{
"property": "icon",
"value": "mdi:button"
},
{
"property": "entity_picture",
"value": ""
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "116c04f6442dc194",
"type": "ha-entity-config",
"server": "b09259d4.60b188",
"deviceConfig": "91b7b4b9ca651569",
"name": "Mala Hitrost Vklopljena",
"version": 6,
"entityType": "binary_sensor",
"haConfig": [
{
"property": "name",
"value": "Mala Hitrost Vklopljena"
},
{
"property": "icon",
"value": "mdi:switch"
},
{
"property": "entity_picture",
"value": ""
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "a865c9ec458968fe",
"type": "ha-entity-config",
"server": "b09259d4.60b188",
"deviceConfig": "91b7b4b9ca651569",
"name": "Velika Hitrost Vklopljena",
"version": 6,
"entityType": "binary_sensor",
"haConfig": [
{
"property": "name",
"value": "Velika Hitrost Vklopljena"
},
{
"property": "icon",
"value": "mdi:switch"
},
{
"property": "entity_picture",
"value": ""
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "e5e1b4c1fb7a3ec7",
"type": "ha-entity-config",
"server": "b09259d4.60b188",
"deviceConfig": "91b7b4b9ca651569",
"name": "Vklop Male Hitrost",
"version": 6,
"entityType": "switch",
"haConfig": [
{
"property": "name",
"value": "Vklop Male Hitrost"
},
{
"property": "icon",
"value": "mdi:switch"
},
{
"property": "entity_picture",
"value": ""
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "9f7d7744.697db8",
"type": "ui_tab",
"name": "Klima",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
},
{
"id": "b09259d4.60b188",
"type": "server",
"name": "Home Assistant",
"addon": true
},
{
"id": "91b7b4b9ca651569",
"type": "ha-device-config",
"name": "Kontrola Prezračevanja",
"hwVersion": "",
"manufacturer": "Node-RED",
"model": "",
"swVersion": ""
}
]
The full CODE is posted here for the NodeRed:
Any solutions, tips etc. as it’s my first time with NodeRed would be helpful!