[
{
"id": "007424808c9b6283",
"type": "mqtt in",
"z": "2e439fa544a77ab5",
"name": "COMMAND/RX",
"topic": "DATI FOTOVOLTAICO/NODE-RED/INVERTER_VOLTRONIC/COMMAND/TX",
"qos": "2",
"datatype": "auto-detect",
"broker": "e276a877253691df",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 120,
"y": 1060,
"wires": [
[
"289e35eef21e61a0",
"7290101b4768b299"
]
]
},
{
"id": "a409a644c23f12d9",
"type": "cyclic counter",
"z": "2e439fa544a77ab5",
"name": "cyclic counter",
"maxCount": "6",
"timeoutDuration": 0,
"timeoutUnit": "ms",
"outputProperty": "payload",
"x": 320,
"y": 980,
"wires": [
[
"9fbe16961891930f"
]
]
},
{
"id": "3a9e655f2b972f20",
"type": "inject",
"z": "2e439fa544a77ab5",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "2",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 980,
"wires": [
[
"a409a644c23f12d9"
]
]
},
{
"id": "9fbe16961891930f",
"type": "change",
"z": "2e439fa544a77ab5",
"name": "",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "1",
"fromt": "num",
"to": "QPIGS",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "2",
"fromt": "num",
"to": "QMOD",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "3",
"fromt": "num",
"to": "QPIGS",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "4",
"fromt": "num",
"to": "QPIWS",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "5",
"fromt": "num",
"to": "QPIGS",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "6",
"fromt": "num",
"to": "QPIRI",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 520,
"y": 980,
"wires": [
[
"d49e167477b1d0b1"
]
]
},
{
"id": "289e35eef21e61a0",
"type": "trigger",
"z": "2e439fa544a77ab5",
"name": "",
"op1": "close",
"op2": "open",
"op1type": "str",
"op2type": "str",
"duration": "10",
"extend": true,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 330,
"y": 1060,
"wires": [
[
"67211f5b338da45d"
]
]
},
{
"id": "67211f5b338da45d",
"type": "change",
"z": "2e439fa544a77ab5",
"name": "move",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "control",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 1060,
"wires": [
[
"d49e167477b1d0b1"
]
]
},
{
"id": "d49e167477b1d0b1",
"type": "gate",
"z": "2e439fa544a77ab5",
"name": "demo gate",
"controlTopic": "control",
"defaultState": "open",
"openCmd": "open",
"closeCmd": "close",
"toggleCmd": "toggle",
"defaultCmd": "default",
"statusCmd": "status",
"persist": false,
"x": 730,
"y": 1060,
"wires": [
[
"f68aa936bb103d57"
]
]
},
{
"id": "f68aa936bb103d57",
"type": "switch",
"z": "2e439fa544a77ab5",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "close",
"vt": "str"
},
{
"t": "eq",
"v": "open",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 890,
"y": 1060,
"wires": [
[],
[],
[
"a99ad4b6bb706893"
]
]
},
{
"id": "7290101b4768b299",
"type": "delay",
"z": "2e439fa544a77ab5",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 320,
"y": 1120,
"wires": [
[
"a99ad4b6bb706893"
]
]
},
{
"id": "edf507bc4f9d5dec",
"type": "serial out",
"z": "2e439fa544a77ab5",
"name": "VMIII-TX",
"serial": "831becf24befe30b",
"x": 1320,
"y": 1120,
"wires": []
},
{
"id": "3f6be7eed08ff7d8",
"type": "debug",
"z": "2e439fa544a77ab5",
"name": "TX Seriale",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1330,
"y": 1180,
"wires": []
},
{
"id": "a99ad4b6bb706893",
"type": "function",
"z": "2e439fa544a77ab5",
"name": "str>hex/crc/buffer",
"func": "msg.payload = Buffer.from(msg.payload, 'utf-8').toString('hex');\n\nconst { crc16 } = easyCrc;\nmsg.inputData = msg.payload;\nmsg.buffer = Buffer.from(msg.payload, 'hex');\nmsg.crcDecimal = crc16('XMODEM', msg.buffer);\nmsg.crcHex = msg.crcDecimal.toString(16)\nmsg.payload = `${msg.inputData}${msg.crcHex}`\n\nmsg.payload = Buffer.from(msg.payload, 'hex')\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [
{
"var": "easyCrc",
"module": "easy-crc"
}
],
"x": 1110,
"y": 1120,
"wires": [
[
"edf507bc4f9d5dec",
"3f6be7eed08ff7d8"
]
]
},
{
"id": "e276a877253691df",
"type": "mqtt-broker",
"name": "",
"broker": "192.168.1.99",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "5",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "831becf24befe30b",
"type": "serial-port",
"name": "",
"serialport": "/dev/ttyACM0",
"serialbaud": "2400",
"databits": 8,
"parity": "none",
"stopbits": 1,
"waitfor": "(",
"dtr": "none",
"rts": "none",
"cts": "none",
"dsr": "none",
"newline": "\\r",
"bin": "false",
"out": "char",
"addchar": "\\r",
"responsetimeout": 10000
}
]
Good morning.
I have given a fix to the stream that I built with your help!
I publish in its completeness with the hope that it can be improved and also in the interest of others looking for a solution... as happened in my case.
Thanks again
flussoCRC .json (8.9 KB)