Easy way to send 4-bit string to 4 separate GPIO out pins

I have one of the old Energenie transmitter boards (which is not supported by contrib-energenie-ener314rt). The board has 6 inputs: protocol OOK/FSK, modulator enable and 4 data pins for setting a 4-bit sata string. There's a Python example script that works this way: set state of 4 GPIO pins, set modulator to high, pause, set modulator to low.

There are 10 combinations of the 4-bit string that it will accept. (socket #1 on, socket #1 off, #2 on, #2 off, ...all on, all off.)

I'm looking for an easy way to send each of those 4-bit strings.

I found a flow which allows you to send multi-line exec node commands and set it up for that purpose, but I think it's not working correctly (or the sockets have a problem? Hence the debugging), so I was trying to find a way to see the state of the 4 GPIO out pins.

If anyone knows of a better way to do this, where a code can be transmitted when triggered via button or a timer in another part of the flow, I'd be grateful to hear about it.

All the best,
Dax.

[
    {
        "id": "1a73c740.e06d79",
        "type": "subflow",
        "name": "Execute Shell Script",
        "info": "",
        "in": [
            {
                "x": 100,
                "y": 200,
                "wires": [
                    {
                        "id": "662c3c62.43d624"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 960,
                "y": 280,
                "wires": [
                    {
                        "id": "9e92978.d8d0868",
                        "port": 0
                    }
                ]
            },
            {
                "x": 960,
                "y": 340,
                "wires": [
                    {
                        "id": "9e92978.d8d0868",
                        "port": 1
                    }
                ]
            },
            {
                "x": 960,
                "y": 400,
                "wires": [
                    {
                        "id": "9e92978.d8d0868",
                        "port": 2
                    }
                ]
            }
        ]
    },
    {
        "id": "dda86e6b.3b362",
        "type": "file",
        "z": "1a73c740.e06d79",
        "name": "Write script file",
        "filename": "filename",
        "filenameType": "msg",
        "appendNewline": true,
        "createDir": false,
        "overwriteFile": "false",
        "x": 860,
        "y": 140,
        "wires": [
            []
        ]
    },
    {
        "id": "7a2a96f.a52b268",
        "type": "exec",
        "z": "1a73c740.e06d79",
        "command": "mktemp",
        "addpay": false,
        "append": "",
        "useSpawn": "",
        "timer": "",
        "name": "",
        "x": 420,
        "y": 200,
        "wires": [
            [
                "9131a546.667eb8"
            ],
            [],
            []
        ]
    },
    {
        "id": "c9fb5364.0becc",
        "type": "file",
        "z": "1a73c740.e06d79",
        "name": "Delete script file",
        "filename": "filename",
        "filenameType": "msg",
        "appendNewline": true,
        "createDir": false,
        "overwriteFile": "delete",
        "x": 1020,
        "y": 480,
        "wires": [
            []
        ]
    },
    {
        "id": "9e92978.d8d0868",
        "type": "exec",
        "z": "1a73c740.e06d79",
        "command": " sh ",
        "addpay": true,
        "append": "",
        "useSpawn": "",
        "timer": "",
        "name": "Execute the shell script",
        "x": 690,
        "y": 340,
        "wires": [
            [
                "c9fb5364.0becc"
            ],
            [],
            []
        ]
    },
    {
        "id": "36f470a4.a6a84",
        "type": "exec",
        "z": "1a73c740.e06d79",
        "command": "chmod +x ",
        "addpay": true,
        "append": "",
        "useSpawn": "",
        "timer": "",
        "name": "",
        "x": 1040,
        "y": 200,
        "wires": [
            [
                "6ba1dbc1.d547b4"
            ],
            [],
            []
        ]
    },
    {
        "id": "662c3c62.43d624",
        "type": "change",
        "z": "1a73c740.e06d79",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "command",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 230,
        "y": 200,
        "wires": [
            [
                "7a2a96f.a52b268"
            ]
        ]
    },
    {
        "id": "a61c48a5.e5dc88",
        "type": "change",
        "z": "1a73c740.e06d79",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "filename",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 860,
        "y": 200,
        "wires": [
            [
                "36f470a4.a6a84"
            ]
        ]
    },
    {
        "id": "9131a546.667eb8",
        "type": "function",
        "z": "1a73c740.e06d79",
        "name": "",
        "func": "msg.filename = msg.payload.trim();\nmsg.payload = msg.command;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 590,
        "y": 180,
        "wires": [
            [
                "dda86e6b.3b362",
                "a61c48a5.e5dc88"
            ]
        ]
    },
    {
        "id": "6ba1dbc1.d547b4",
        "type": "change",
        "z": "1a73c740.e06d79",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "filename",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 480,
        "y": 340,
        "wires": [
            [
                "9e92978.d8d0868"
            ]
        ]
    },
    {
        "id": "f21f0fb8.12361",
        "type": "comment",
        "z": "1a73c740.e06d79",
        "name": "Execute shell script",
        "info": "Execute the shell script in msg.payload.",
        "x": 130,
        "y": 40,
        "wires": []
    },
    {
        "id": "3c6751f317a368c2",
        "type": "rpi-gpio out",
        "z": "e7bc54457b5634db",
        "name": "Enable modulator output",
        "pin": "25",
        "set": true,
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 730,
        "y": 380,
        "wires": []
    },
    {
        "id": "dff785c9299e71e8",
        "type": "trigger",
        "z": "e7bc54457b5634db",
        "name": "",
        "op1": "1",
        "op2": "0",
        "op1type": "str",
        "op2type": "str",
        "duration": "500",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 730,
        "y": 340,
        "wires": [
            [
                "3c6751f317a368c2"
            ]
        ]
    },
    {
        "id": "743f5337.595bcc",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "All on",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 260,
        "wires": [
            [
                "92fd8149.b5867"
            ]
        ]
    },
    {
        "id": "92fd8149.b5867",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dh\nraspi-gpio set 23 dl\nraspi-gpio set 22 dh\nraspi-gpio set 17 dh",
        "x": 290,
        "y": 260,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "5b242947.2d4ac8",
        "type": "subflow:1a73c740.e06d79",
        "z": "e7bc54457b5634db",
        "x": 520,
        "y": 260,
        "wires": [
            [
                "24c6f0cd.3edaa",
                "dff785c9299e71e8"
            ],
            [
                "24c6f0cd.3edaa"
            ],
            [
                "24c6f0cd.3edaa"
            ]
        ]
    },
    {
        "id": "24c6f0cd.3edaa",
        "type": "debug",
        "z": "e7bc54457b5634db",
        "name": "Log the result",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 730,
        "y": 260,
        "wires": []
    },
    {
        "id": "eee8acd1c89496ad",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "All off",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 300,
        "wires": [
            [
                "5e2bcc0248a55f0d"
            ]
        ]
    },
    {
        "id": "5e2bcc0248a55f0d",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dl\nraspi-gpio set 23 dl\nraspi-gpio set 22 dh\nraspi-gpio set 17 dh",
        "x": 290,
        "y": 300,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "bc77d2e0b2603b01",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "#1 on",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 400,
        "wires": [
            [
                "3d091aadbf38796d"
            ]
        ]
    },
    {
        "id": "3d091aadbf38796d",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dh\nraspi-gpio set 23 dh\nraspi-gpio set 22 dh\nraspi-gpio set 17 dh",
        "x": 290,
        "y": 400,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "ad626ceb7ae18c8e",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "#1 off",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 440,
        "wires": [
            [
                "e873eb2022ddbd9d"
            ]
        ]
    },
    {
        "id": "e873eb2022ddbd9d",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dl\nraspi-gpio set 23 dh\nraspi-gpio set 22 dh\nraspi-gpio set 17 dh",
        "x": 290,
        "y": 440,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "141fd9d02b7bc8b9",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "#2 on",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 540,
        "wires": [
            [
                "09a3bcf4de29f672"
            ]
        ]
    },
    {
        "id": "09a3bcf4de29f672",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dh\nraspi-gpio set 23 dh\nraspi-gpio set 22 dh\nraspi-gpio set 17 dl",
        "x": 290,
        "y": 540,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "1ecfd6479683fda5",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "#2 off",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 580,
        "wires": [
            [
                "2ad3b650166322a9"
            ]
        ]
    },
    {
        "id": "2ad3b650166322a9",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dl\nraspi-gpio set 23 dh\nraspi-gpio set 22 dh\nraspi-gpio set 17 dl",
        "x": 290,
        "y": 580,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "8ce0bbd7c247d537",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "#3 on",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 680,
        "wires": [
            [
                "2c22ed0d305ed154"
            ]
        ]
    },
    {
        "id": "2c22ed0d305ed154",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dh\nraspi-gpio set 23 dh\nraspi-gpio set 22 dl\nraspi-gpio set 17 dh",
        "x": 290,
        "y": 680,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "8c72f9e4c1110c9a",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "#3 off",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 720,
        "wires": [
            [
                "84f85a0077601162"
            ]
        ]
    },
    {
        "id": "84f85a0077601162",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dl\nraspi-gpio set 23 dh\nraspi-gpio set 22 dl\nraspi-gpio set 17 dh",
        "x": 290,
        "y": 720,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "bb33a1809c185051",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "#4 on",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 820,
        "wires": [
            [
                "b22e378094eae18f"
            ]
        ]
    },
    {
        "id": "b22e378094eae18f",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dh\nraspi-gpio set 23 dh\nraspi-gpio set 22 dl\nraspi-gpio set 17 dl",
        "x": 290,
        "y": 820,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "5a41aa51f7763f87",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "#4 off",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 860,
        "wires": [
            [
                "007e7ae68c43a940"
            ]
        ]
    },
    {
        "id": "007e7ae68c43a940",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 27 dl\nraspi-gpio set 23 dh\nraspi-gpio set 22 dl\nraspi-gpio set 17 dl",
        "x": 290,
        "y": 860,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "fc18859c1f981288",
        "type": "comment",
        "z": "e7bc54457b5634db",
        "name": "Appliance name",
        "info": "",
        "x": 140,
        "y": 360,
        "wires": []
    },
    {
        "id": "3dc0b1a7180c0932",
        "type": "comment",
        "z": "e7bc54457b5634db",
        "name": "Appliance name",
        "info": "",
        "x": 140,
        "y": 500,
        "wires": []
    },
    {
        "id": "9f6a602cff0436db",
        "type": "comment",
        "z": "e7bc54457b5634db",
        "name": "Appliance name",
        "info": "",
        "x": 140,
        "y": 640,
        "wires": []
    },
    {
        "id": "2c81906637eede98",
        "type": "comment",
        "z": "e7bc54457b5634db",
        "name": "Appliance name",
        "info": "",
        "x": 140,
        "y": 780,
        "wires": []
    },
    {
        "id": "6979794cf1afb8c2",
        "type": "inject",
        "z": "e7bc54457b5634db",
        "name": "Setup GPIOs",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 300,
        "y": 80,
        "wires": [
            [
                "7f87ef523d955b62"
            ]
        ]
    },
    {
        "id": "7f87ef523d955b62",
        "type": "template",
        "z": "e7bc54457b5634db",
        "name": "Shell Script",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#! /bin/sh\n\nraspi-gpio set 24 dl",
        "x": 290,
        "y": 140,
        "wires": [
            [
                "5b242947.2d4ac8"
            ]
        ]
    },
    {
        "id": "4275755d2bb2b92d",
        "type": "rpi-gpio out",
        "z": "e7bc54457b5634db",
        "d": true,
        "name": "Mode select (low=OOK mode)",
        "pin": "24",
        "set": true,
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 710,
        "y": 560,
        "wires": []
    },
    {
        "id": "02a1c830607dc6bc",
        "type": "rpi-gpio in",
        "z": "e7bc54457b5634db",
        "name": "GPIO 27",
        "pin": "27",
        "intype": "tri",
        "debounce": "25",
        "read": true,
        "bcm": true,
        "x": 920,
        "y": 260,
        "wires": [
            [
                "68edf16c66b98012"
            ]
        ]
    },
    {
        "id": "ced24b84793e7187",
        "type": "rpi-gpio in",
        "z": "e7bc54457b5634db",
        "name": "GPIO23",
        "pin": "23",
        "intype": "tri",
        "debounce": "25",
        "read": true,
        "bcm": true,
        "x": 920,
        "y": 320,
        "wires": [
            [
                "5a66232ebdaab619"
            ]
        ]
    },
    {
        "id": "b3d901a3379f899c",
        "type": "rpi-gpio in",
        "z": "e7bc54457b5634db",
        "name": "GPIO22",
        "pin": "22",
        "intype": "tri",
        "debounce": "25",
        "read": true,
        "bcm": true,
        "x": 920,
        "y": 380,
        "wires": [
            [
                "743fba18cff09729"
            ]
        ]
    },
    {
        "id": "fed780bb4417682e",
        "type": "rpi-gpio in",
        "z": "e7bc54457b5634db",
        "name": "GPIO17",
        "pin": "17",
        "intype": "tri",
        "debounce": "25",
        "read": true,
        "bcm": true,
        "x": 920,
        "y": 440,
        "wires": [
            [
                "1fa7bcd106266a0d"
            ]
        ]
    },
    {
        "id": "68edf16c66b98012",
        "type": "debug",
        "z": "e7bc54457b5634db",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1060,
        "y": 260,
        "wires": []
    },
    {
        "id": "5a66232ebdaab619",
        "type": "debug",
        "z": "e7bc54457b5634db",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1060,
        "y": 320,
        "wires": []
    },
    {
        "id": "743fba18cff09729",
        "type": "debug",
        "z": "e7bc54457b5634db",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1060,
        "y": 380,
        "wires": []
    },
    {
        "id": "1fa7bcd106266a0d",
        "type": "debug",
        "z": "e7bc54457b5634db",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1060,
        "y": 440,
        "wires": []
    }
]

As I said in your earlier thread, the GPIO Out node shows the current status underneath it.

Yes, but I don't know of an wasy way to send a 4-bit string to 4 separate GPIO nodes.

If only our GPIO-out node would accept topic, then you could send msg.topic=GPIO22 msg.payload=high

Do you already have this 4 bit string? If so feed it into a debug mode and show us what it looks like. The term 4 bit string is ambiguous.

If you do not already have it then an array would probably be the easiest way to handle it, then you can easily use a Change node in front of each GPIO to move the relevant bits into the payload.

D3 is GPIO27
D2 is GPIO23
D1 is GPIO22
D0 is GPIO17

Does something like this should do what you want? I have just coded up a few of the inputs. Note that in the array they are order D0 first.

[{"id":"43d30d5f05507eed","type":"inject","z":"bdd7be38.d3b55","name":"All On","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,1,0,1]","payloadType":"json","x":150,"y":3280,"wires":[["8cae4b4dc99e2022"]]},{"id":"48d6aa97c1e555c2","type":"inject","z":"bdd7be38.d3b55","name":"Socket 1 on","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,1,1,1]","payloadType":"json","x":170,"y":3320,"wires":[["8cae4b4dc99e2022"]]},{"id":"7f2c583a81dda415","type":"change","z":"bdd7be38.d3b55","name":"D0","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":3220,"wires":[["3df5efcbf9215046"]]},{"id":"ebbf54bf7bf74a56","type":"change","z":"bdd7be38.d3b55","name":"D1","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[1]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":3300,"wires":[["aa3b6e06c1ca5356"]]},{"id":"f1687ff5b8d1a00f","type":"change","z":"bdd7be38.d3b55","name":"D2","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[2]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":3380,"wires":[["8c459e0d1b711d04"]]},{"id":"eb39f2dc310ecacd","type":"change","z":"bdd7be38.d3b55","name":"D3","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[3]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":3460,"wires":[["0dd6dc86b522d6fc"]]},{"id":"a787b702163e4cea","type":"inject","z":"bdd7be38.d3b55","name":"Socket 2 on","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[0,1,1,1]","payloadType":"json","x":170,"y":3360,"wires":[["8cae4b4dc99e2022"]]},{"id":"3df5efcbf9215046","type":"debug","z":"bdd7be38.d3b55","name":"D0","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":3220,"wires":[]},{"id":"aa3b6e06c1ca5356","type":"debug","z":"bdd7be38.d3b55","name":"D1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":3300,"wires":[]},{"id":"8c459e0d1b711d04","type":"debug","z":"bdd7be38.d3b55","name":"D2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":3380,"wires":[]},{"id":"0dd6dc86b522d6fc","type":"debug","z":"bdd7be38.d3b55","name":"D3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":3460,"wires":[]},{"id":"a41e483be1638db0","type":"comment","z":"bdd7be38.d3b55","name":"The GPIO nodes go alongside these","info":"","x":640,"y":3180,"wires":[]},{"id":"8cae4b4dc99e2022","type":"junction","z":"bdd7be38.d3b55","x":300,"y":3320,"wires":[["7f2c583a81dda415","ebbf54bf7bf74a56","f1687ff5b8d1a00f","eb39f2dc310ecacd"]]}]

Ahh! Treat it as an array! I also didn't know about the msg.payload[index number] trick. That is really cool.

I swear, every time I pose a question on this forum, I learn a new technique that goes beyond the usefulness of just that particular situation. Thank you so much, Colin, I really appreciate it! :blush:

I'll re-set the index order, add the GPIOs and test this flow out.

Have a great evening.

1 Like

D0 should be element 0 of the array, otherwise you will get confused, or I would anyway.

Thanks so much, Colin, I've tested it and all sockets are now working as expected. Now I can turn my home-made nuclear reactor on and off remotely! Just kidding! :laughing:

D3 is the MSB, so makes sense to be the first and that's also how it is in the Energenie documentation.

All the best!
Dax.

1 Like

Suppose they updated the product and added D5. Then you would have to rework your flow. With D0 as element 0 in the array you could just add the extra bit.

They already have upgraded the product (ENER314-RT) and there's a whole contrib library for it. :slight_smile:

I was attempting to point out that using element 0 as D0 is a better way for the general case. It is always a good idea to think about the general case when coding, so that the code can either be extended more easily or reused the next time you have some similar problems.

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