Dingtian Relay Board via MQTT from Node-Red

I read the suggested topic " RemoteGPIO (ex venus_rgpio) now released in v3.2.1" but it does not seem to relate to my question directly.

I am attempting to control the Dingtian Relay Board via MQTT from Node-Red based on Venus data using the built-in Broker.
I see from MQTT Explorer that the Node-Red part is working correctly, the same as many other Venus values correctly reported at the receiving end.
However, when I attempt to set up the Dingtian relay board, I have no luck establishing the connection, being confused by the so many available pages/settings.
For a start, I don’t know if this is the correct page


since, after setting the port and the Cerbo IP, nothing seems to be delivered here, though I can see the correct signals in Explorer, which is subscribed to the same Victron Broker.
I am new to the concept and I could do with some help in identifying where I go wrong.

Resolved:

For the benefit of others, here’s how the node-red wants to be set up, hoping this will help.
This setup differs from the previously posted on this forum based on MODBUS and Remote GIPO here (RemoteGPIO: Adding Relays and Digital Inputs) which requires the additional app and presumably only works in the Cerbo proximity.
I designed my setup so that it will relay the commands via LAN or WiFi io order to turn On & OFF a hot water element in the house according to the battery SOC.

The two nodes below the Linx shunt node are the battery SOC test buttons followed by the function that converts the set value to the relay’s command and injects it into the MQTT node.
Below are just two groups of simple injects for testing purposes (relay 1 & 2)

The Ding Tian relay board is a little tricky to understand from the manual, but after some research, I found that the IDX (board identifier) needs to be inserted in the MQTT out node.
I found my board idx by connecting MQTT explorer, which gave me all the board details.

Here is my Nore-Red script:

[
{
“id”: “45c7bb2e1d9f9984”,
“type”: “tab”,
“label”: “MQTT Dingtian 2W Relay”,
“disabled”: false,
“info”: “”,
“env”:
},
{
“id”: “ad88452418c97949”,
“type”: “debug”,
“z”: “45c7bb2e1d9f9984”,
“name”: “debug 10”,
“active”: true,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “false”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 800,
“y”: 140,
“wires”:
},
{
“id”: “5131fa42e6633b71”,
“type”: “inject”,
“z”: “45c7bb2e1d9f9984”,
“name”: “”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “%”,
“payload”: “90”,
“payloadType”: “num”,
“x”: 250,
“y”: 120,
“wires”: [
[
“eb970760d3b5d0c1”
]
]
},
{
“id”: “1e4e8ebc4c228fcd”,
“type”: “inject”,
“z”: “45c7bb2e1d9f9984”,
“name”: “”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “%”,
“payload”: “73”,
“payloadType”: “num”,
“x”: 250,
“y”: 180,
“wires”: [
[
“eb970760d3b5d0c1”
]
]
},
{
“id”: “a2ed4903ce5818cc”,
“type”: “inject”,
“z”: “45c7bb2e1d9f9984”,
“name”: “Relay 1 ON”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “{"type":"ON/OFF","idx":"1","status":"ON","time":"0","pass":"0"}”,
“payloadType”: “json”,
“x”: 270,
“y”: 280,
“wires”: [
[
“afe9f41a43ce2d3c”
]
]
},
{
“id”: “afe9f41a43ce2d3c”,
“type”: “mqtt out”,
“z”: “45c7bb2e1d9f9984”,
“name”: “relay/control”,
“topic”: “/dingtian/relay53819/in/control”,
“qos”: “1”,
“retain”: “”,
“respTopic”: “”,
“contentType”: “text/plain”,
“userProps”: “”,
“correl”: “”,
“expiry”: “20”,
“broker”: “f03fb7c9c66fd70b”,
“x”: 630,
“y”: 300,
“wires”:
},
{
“id”: “fe58f9b29d699bda”,
“type”: “inject”,
“z”: “45c7bb2e1d9f9984”,
“name”: “Relay 1 OFF”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “{"type":"ON/OFF","idx":"1","status":"OFF","time":"0","pass":"0"}”,
“payloadType”: “json”,
“x”: 270,
“y”: 320,
“wires”: [
[
“afe9f41a43ce2d3c”
]
]
},
{
“id”: “a1864e1cb859e893”,
“type”: “inject”,
“z”: “45c7bb2e1d9f9984”,
“name”: “Relay 2 ON”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “{"type":"ON/OFF","idx":"2","status":"ON","time":"0","pass":"0"}”,
“payloadType”: “json”,
“x”: 270,
“y”: 380,
“wires”: [
[
“1655b474e57d18a7”
]
]
},
{
“id”: “1655b474e57d18a7”,
“type”: “mqtt out”,
“z”: “45c7bb2e1d9f9984”,
“name”: “relay/control”,
“topic”: “/dingtian/relay53819/in/control”,
“qos”: “1”,
“retain”: “”,
“respTopic”: “”,
“contentType”: “text/plain”,
“userProps”: “”,
“correl”: “”,
“expiry”: “20”,
“broker”: “f03fb7c9c66fd70b”,
“x”: 630,
“y”: 400,
“wires”:
},
{
“id”: “4618ac8593084d74”,
“type”: “inject”,
“z”: “45c7bb2e1d9f9984”,
“name”: “Relay 2 OFF”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “{"type":"ON/OFF","idx":"2","status":"OFF","time":"0","pass":"0"}”,
“payloadType”: “json”,
“x”: 270,
“y”: 420,
“wires”: [
[
“1655b474e57d18a7”
]
]
},
{
“id”: “eb970760d3b5d0c1”,
“type”: “function”,
“z”: “45c7bb2e1d9f9984”,
“name”: “function 4”,
“func”: “// Desired thresholds\nconst thresholdHigh = 80; // Relay ON when SoC > 80%\nconst thresholdLow = 75; // Relay OFF when SoC < 50%\n\n// Get the Battery SoC from the incoming message\nconst batterySoC = parseFloat(msg.payload);\n\n// Initialize the payload\nlet relayPayload = {\n "type": "ON/OFF",\n "idx": "1", // Specify the relay index\n "status": "",\n "time": "0",\n "pass": "0"\n};\n\n// Determine relay state\nif (batterySoC > thresholdHigh) {\n relayPayload.status = "ON"; // Turn relay ON\n} else if (batterySoC < thresholdLow) {\n relayPayload.status = "OFF"; // Turn relay OFF\n} else {\n return null; // No action within thresholds\n}\n\n// Set the modified payload to the message\nmsg.payload = relayPayload;\n\nreturn msg;\n”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: ,
“x”: 540,
“y”: 140,
“wires”: [
[
“ad88452418c97949”,
“afe9f41a43ce2d3c”
]
]
},
{
“id”: “c3b0bc2264a4102f”,
“type”: “mqtt out”,
“z”: “45c7bb2e1d9f9984”,
“name”: “Linx Shunt/State of charge(%)”,
“topic”: “Linx Shunt/State of charge(%)”,
“qos”: “1”,
“retain”: “”,
“respTopic”: “”,
“contentType”: “text/plain”,
“userProps”: “”,
“correl”: “”,
“expiry”: “20”,
“broker”: “f03fb7c9c66fd70b”,
“x”: 810,
“y”: 60,
“wires”:
},
{
“id”: “abaacd16a1156b6a”,
“type”: “victron-input-battery”,
“z”: “45c7bb2e1d9f9984”,
“service”: “com.victronenergy.battery/0”,
“path”: “/Soc”,
“serviceObj”: {
“service”: “com.victronenergy.battery/0”,
“name”: “Lynx Shunt”
},
“pathObj”: {
“path”: “/Soc”,
“type”: “float”,
“name”: “State of charge (%)”
},
“name”: “”,
“onlyChanges”: true,
“roundValues”: “0”,
“x”: 210,
“y”: 60,
“wires”: [
[
“c3b0bc2264a4102f”,
“eb970760d3b5d0c1”
]
],
“info”: “This node detects the Battery SOC”
},
{
“id”: “f03fb7c9c66fd70b”,
“type”: “mqtt-broker”,
“name”: “Venus Broker”,
“broker”: “mqtt://192.168.1.104:1883”,
“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”: “”
}
]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.