EndNode 4ch Relay Input Commands Node red

I am having trouble using the 4ch relay controller in node-red.

I simply want to push a 0 or 1 or 2 to control the relay in node-red with an inject node. Could someone please send a screen shot of what the setup should look like in node-red? I am not sure if I have the wrong topic, payload, or both.

Thanks

1 Like

Hi Christian,

The simplest way to do this is to use the Wireless input method on the Wireless Gateway node. Here is a flow that demonstrates Turing on relay 1:

[
    {
        "id": "2380fa94b7c3d5ef",
        "type": "tab",
        "label": "Flow 5",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "843e8e7c515a8234",
        "type": "ncd-gateway-node",
        "z": "2380fa94b7c3d5ef",
        "name": "",
        "connection": "982da71980664144",
        "unknown_devices": true,
        "outputs": 2,
        "x": 790,
        "y": 520,
        "wires": [
            [],
            [
                "50f028d1be0e2510"
            ]
        ]
    },
    {
        "id": "7d6bb2d7fd6ceae1",
        "type": "inject",
        "z": "2380fa94b7c3d5ef",
        "name": "",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 290,
        "y": 520,
        "wires": [
            [
                "fa2bd0a7cde0dca1"
            ]
        ]
    },
    {
        "id": "fa2bd0a7cde0dca1",
        "type": "function",
        "z": "2380fa94b7c3d5ef",
        "name": "",
        "func": "msg = {};\nmsg.payload = {};\nmsg.payload.address = \"00:13:a2:00:41:db:79:51\";\nmsg.payload.data = [0xAA,0x07,0xBD,0x01,0xFD,0x01,0x01,0x01,0x00,0x6F];\n// msg.payload.data = [0xAA,0x02,0xFE,0x21,0xCB];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 520,
        "y": 520,
        "wires": [
            [
                "843e8e7c515a8234"
            ]
        ]
    },
    {
        "id": "50f028d1be0e2510",
        "type": "debug",
        "z": "2380fa94b7c3d5ef",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1070,
        "y": 560,
        "wires": []
    },
    {
        "id": "982da71980664144",
        "type": "ncd-gateway-config",
        "name": "",
        "comm_type": "serial",
        "ip_address": "",
        "tcp_port": "2101",
        "port": "/dev/tty.usbserial-AC3VPU0N",
        "baudRate": "115200",
        "pan_id": "7fff",
        "rssi": false
    }
]

You will need to change the address variable in the function node to the address of your EndNode relay controller.

Full documentation for the command set to control EndNode devices can be found here:

Travis,

I used the flow with my gateway and managed to turn the relay on. I then switched the payload.data to turn the same relay off "[0xAA,0x07,0xBD,0x01,0xFD,0x00,0x01,0x01,0x00,0x6F], but it will not fire.

Anything I am missing?

You altered the command but you did not recalculate the checksum at the end(left it as 0x6F). To calculate the checksum add all prior bytes together then and them with 0xFF. This would result in a check sum of 0x6E so your command should be:
[0xAA,0x07,0xBD,0x01,0xFD,0x00,0x01,0x01,0x00,0x6E]

Here is an updated flow with a helper function that will append a checksum to the command:

[
    {
        "id": "2380fa94b7c3d5ef",
        "type": "tab",
        "label": "Flow 5",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "843e8e7c515a8234",
        "type": "ncd-gateway-node",
        "z": "2380fa94b7c3d5ef",
        "name": "",
        "connection": "982da71980664144",
        "unknown_devices": true,
        "outputs": 2,
        "x": 790,
        "y": 520,
        "wires": [
            [],
            [
                "50f028d1be0e2510"
            ]
        ]
    },
    {
        "id": "7d6bb2d7fd6ceae1",
        "type": "inject",
        "z": "2380fa94b7c3d5ef",
        "name": "",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 230,
        "y": 520,
        "wires": [
            [
                "fa2bd0a7cde0dca1"
            ]
        ]
    },
    {
        "id": "fa2bd0a7cde0dca1",
        "type": "function",
        "z": "2380fa94b7c3d5ef",
        "name": "",
        "func": "msg = {};\nmsg.payload = {};\nmsg.payload.address = \"00:13:a2:00:41:db:79:51\";\n//Command without checksum\nmsg.payload.data = [0xAA,0x07,0xBD,0x01,0xFD,0x01,0x01,0x01,0x00];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 520,
        "wires": [
            [
                "c860ad92b765a9f2"
            ]
        ]
    },
    {
        "id": "50f028d1be0e2510",
        "type": "debug",
        "z": "2380fa94b7c3d5ef",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1070,
        "y": 560,
        "wires": []
    },
    {
        "id": "c860ad92b765a9f2",
        "type": "function",
        "z": "2380fa94b7c3d5ef",
        "name": "Add Checksum",
        "func": "var command = msg.payload.data;\nvar sum = 0x00;\nfor(i = 0; i < command.length; i++){\n    sum+=command[i];\n}\ncommand.push(sum&0xFF);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 520,
        "wires": [
            [
                "843e8e7c515a8234",
                "21f8f5bb56e4aad1"
            ]
        ]
    },
    {
        "id": "21f8f5bb56e4aad1",
        "type": "debug",
        "z": "2380fa94b7c3d5ef",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 770,
        "y": 440,
        "wires": []
    },
    {
        "id": "982da71980664144",
        "type": "ncd-gateway-config",
        "name": "",
        "comm_type": "serial",
        "ip_address": "",
        "tcp_port": "2101",
        "port": "/dev/tty.usbserial-AC3VPU0N",
        "baudRate": "115200",
        "pan_id": "7fff",
        "rssi": false
    }
]