First you have to configure your own MQTT server (Broker) You can use the same configuration as for the MQTT Output node.
The next node is a "default" "Switch" node. This node filters the different idx's of your virtual Domoticz switches (On/Off and Push On Button).
The On/Off Switch goes to output 1 and the Push On button goes to output 2.
The "Change"node moves msg.payload.nvalue to msg.payload and that data is sent to to ModBus "Write" node.
You can remove all the "Debug" nodes, as soon as everything has been tested.
Code: Select all
[
{
"id": "93913941cc4231cc",
"type": "mqtt in",
"z": "972c9476422a46d9",
"name": "From Domoticz",
"topic": "domoticz/out",
"qos": "0",
"datatype": "auto-detect",
"broker": "175c3dc01f359e9d",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 140,
"y": 440,
"wires": [
[
"5dfe82928ca830f0"
]
]
},
{
"id": "5dfe82928ca830f0",
"type": "switch",
"z": "972c9476422a46d9",
"name": "Split Commands",
"property": "payload.idx",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "10",
"vt": "num"
},
{
"t": "eq",
"v": "11",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 370,
"y": 440,
"wires": [
[
"7a74f7aa86cdb761",
"416007f8a4a3c831"
],
[
"dad788f1bf3bc6c6",
"6039a68fa21840c4"
]
]
},
{
"id": "7a74f7aa86cdb761",
"type": "debug",
"z": "972c9476422a46d9",
"name": "debug 14",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 580,
"y": 340,
"wires": []
},
{
"id": "dad788f1bf3bc6c6",
"type": "debug",
"z": "972c9476422a46d9",
"name": "debug 15",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 580,
"y": 540,
"wires": []
},
{
"id": "d3eec76e54bbc6f0",
"type": "modbus-write",
"z": "972c9476422a46d9",
"name": "To Vents",
"showStatusActivities": false,
"showErrors": false,
"showWarnings": true,
"unitid": "1",
"dataType": "Coil",
"adr": "0",
"quantity": "1",
"server": "7f7fed9221928721",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"delayOnStart": false,
"startDelayTime": "",
"x": 880,
"y": 400,
"wires": [
[
"aa132a17d7edbe25"
],
[
"0f9c72e16fb0bc5e"
]
]
},
{
"id": "416007f8a4a3c831",
"type": "change",
"z": "972c9476422a46d9",
"name": "",
"rules": [
{
"t": "move",
"p": "payload.nvalue",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 400,
"wires": [
[
"a1b2a6df7e87b16b",
"d3eec76e54bbc6f0"
]
]
},
{
"id": "a1b2a6df7e87b16b",
"type": "debug",
"z": "972c9476422a46d9",
"name": "debug 20",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 880,
"y": 340,
"wires": []
},
{
"id": "aa132a17d7edbe25",
"type": "debug",
"z": "972c9476422a46d9",
"name": "debug 21",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1060,
"y": 380,
"wires": []
},
{
"id": "0f9c72e16fb0bc5e",
"type": "debug",
"z": "972c9476422a46d9",
"name": "debug 22",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1060,
"y": 420,
"wires": []
},
{
"id": "6039a68fa21840c4",
"type": "change",
"z": "972c9476422a46d9",
"name": "",
"rules": [
{
"t": "move",
"p": "payload.nvalue",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 480,
"wires": [
[
"6ebd7c59520cc41f",
"dc6750fcbe3cb228"
]
]
},
{
"id": "6ebd7c59520cc41f",
"type": "modbus-write",
"z": "972c9476422a46d9",
"name": "To Vents",
"showStatusActivities": false,
"showErrors": false,
"showWarnings": true,
"unitid": "1",
"dataType": "Coil",
"adr": "18",
"quantity": "1",
"server": "7f7fed9221928721",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"delayOnStart": false,
"startDelayTime": "",
"x": 880,
"y": 480,
"wires": [
[
"9b4eae8c44c6b861"
],
[
"6f48f5a58816c04e"
]
]
},
{
"id": "9b4eae8c44c6b861",
"type": "debug",
"z": "972c9476422a46d9",
"name": "debug 23",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1060,
"y": 460,
"wires": []
},
{
"id": "6f48f5a58816c04e",
"type": "debug",
"z": "972c9476422a46d9",
"name": "debug 24",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1060,
"y": 500,
"wires": []
},
{
"id": "637b7ab6d1034d60",
"type": "inject",
"z": "972c9476422a46d9",
"name": "Start",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "false",
"payloadType": "bool",
"x": 710,
"y": 440,
"wires": [
[
"d3eec76e54bbc6f0"
]
]
},
{
"id": "dc6750fcbe3cb228",
"type": "debug",
"z": "972c9476422a46d9",
"name": "debug 26",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 880,
"y": 540,
"wires": []
},
{
"id": "175c3dc01f359e9d",
"type": "mqtt-broker",
"name": "Raspberry Pi 1B",
"broker": "192.168.10.51",
"port": 1883,
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": 4,
"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": "7f7fed9221928721",
"type": "modbus-client",
"name": "Reku",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"failureLogEnabled": true,
"tcpHost": "192.168.10.1",
"tcpPort": 502,
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": 9600,
"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
}
]
Test these things carefully, as an error in addressing the registers is easily made.
let me know the results.