Could you explain to me from start, so 0, I just opened new project and I only want to install for example setworkmode node type, how do you do that? Things that I have are only folder setworkmode and inside are files:
index.js
const fs = require("fs");
const path = require("path");
module.exports = function(RED) {
const subflowFile = path.join(__dirname,"subflow.json");
const subflowContents = fs.readFileSync(subflowFile);
const subflowJSON = JSON.parse(subflowContents);
RED.nodes.registerSubflow(subflowJSON);
}
package.json
{
"name": "setworkmode",
"version": "1.0.0",
"description": "Set work mode of leCPS.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"leCPS",
"work",
"mode",
"set"
],
"author": "Toni Opuhač",
"license": "ISC",
"node-red": {
"nodes": {
"Set work mode state": "index.js"
},
"dependencies": [
"node-red-contrib-bigexec",
"node-red-contrib-modbus",
"node-red-contrib-ui-contextmenu",
"node-red-contrib-ui-led",
"node-red-contrib-ui-multistate-switch",
"node-red-dashboard",
"uimonad"
]
},
"dependencies": {
"node-red-contrib-bigexec": "~1.3.3",
"node-red-contrib-modbus": "~5.23.1",
"node-red-contrib-ui-contextmenu": "~2.0.1",
"node-red-contrib-ui-led": "~0.4.11",
"node-red-contrib-ui-multistate-switch": "~1.2.3",
"node-red-dashboard": "~3.1.7",
"uimonad": "file:../subflowModules/uimonad"
}
}
subflow.json
{
"id": "827ff8967a4e86f6",
"type": "subflow",
"name": "Set work mode state",
"info": "",
"category": "function",
"in": [
{
"x": 40,
"y": 140,
"wires": [
{
"id": "7056865d556523f1"
}
]
}
],
"out": [
{
"x": 750,
"y": 140,
"wires": [
{
"id": "352ddb6a0cdcfbab",
"port": 0
},
{
"id": "c348f6c2462bd906",
"port": 0
},
{
"id": "ca9ca3c8f60b1653",
"port": 0
},
{
"id": "8e980d04beae8cd6",
"port": 0
}
]
}
],
"env": [],
"meta": {},
"color": "#FFAAAA",
"inputLabels": [
"CPS modbus payload"
],
"outputLabels": [
"Colored text representing state"
],
"icon": "node-red/swap.svg",
"flow": [
{
"id": "352ddb6a0cdcfbab",
"type": "template",
"z": "827ff8967a4e86f6",
"name": "Set state local-automatic",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "mustache",
"template": "{\n \"color\": \"brown\",\n \"valueText\": \"Trenutno stanje lokalnog-automatskog upravljanja\"\n}",
"output": "json",
"x": 470,
"y": 80,
"wires": [
[]
]
},
{
"id": "c348f6c2462bd906",
"type": "template",
"z": "827ff8967a4e86f6",
"name": "Set state remote",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "mustache",
"template": "{\n \"color\": \"blue\",\n \"valueText\": \"Trenutno stanje daljinskog načina upravljanja\"\n} ",
"output": "json",
"x": 440,
"y": 120,
"wires": [
[]
]
},
{
"id": "ca9ca3c8f60b1653",
"type": "template",
"z": "827ff8967a4e86f6",
"name": "Set state local",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "mustache",
"template": "{\n \"color\": \"green\",\n \"valueText\": \"Trenutno stanje lokalnog načina upravljanja\"\n}",
"output": "json",
"x": 440,
"y": 160,
"wires": [
[]
]
},
{
"id": "8e980d04beae8cd6",
"type": "template",
"z": "827ff8967a4e86f6",
"name": "Set state undefined",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "mustache",
"template": "{\n \"color\": \"purple\",\n \"valueText\": \"Trenutno stanje nije ispravno definirano\"\n}",
"output": "json",
"x": 450,
"y": 200,
"wires": [
[]
]
},
{
"id": "7056865d556523f1",
"type": "switch",
"z": "827ff8967a4e86f6",
"name": "Check work mode state",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "num"
},
{
"t": "eq",
"v": "1",
"vt": "num"
},
{
"t": "eq",
"v": "2",
"vt": "num"
},
{
"t": "eq",
"v": "3",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 4,
"x": 210,
"y": 140,
"wires": [
[
"352ddb6a0cdcfbab"
],
[
"c348f6c2462bd906"
],
[
"ca9ca3c8f60b1653"
],
[
"8e980d04beae8cd6"
]
]
}
]
}
Where do I need to put that folder and what do I need to type and where? Step-by-step please, I'm just starting so I don't know much.