Machine alarm email notification using a flashing light

Hello, I am new to Node-RED and Raspberry Pi's. I am trying to get a Raspberry Pi to email a notification using an alarm light on our machine that flashes. I have figured out how to get an email once it starts to flash and ignore all of the flashes after that so I don't get an email for every flash. What I am trying to add now is a second email after 10 min of flashing and not send an email if the alarm is cleared in that time frame. Thanks.

Welcome to the forum @OrluckIndBJ.

You can configure a Trigger node to send the first email message immediately then wait for a defined period and then send the second email message. If the alarm is cleared then send the Trigger node a message with msg.reset set, which will clear the pending message.

Thanks Colin, How do I get the trigger to know it is cleared when it is flashing, I get a 1 for on and a 0 for off. I will need some sort of check to see the light is off for more that say 5 seconds.

With another Trigger node set to Send Nothing then after 5 seconds (or whatever) send the reset to the email Trigger node, but with Extend Delay set, so all the time it keeps flashing it will send nothing, but if the flashing stops then it will send the reset.

How are you preventing it from sending multiple messages? I think you can do the whole thing just with the two trigger nodes.

For only sending one email I have a trigger node to send "Machine Alarmed Out" then it waits for 5 seconds and has the "extend delay if new message arrives" checked. So as it is flashing it ignores all of the 1's and 0's after the first one.

On the second trigger how does it know the 10 minutes has past to allow the message to go through. Maybe this wouldn't be on the second trigger?

Thank you for the quick responses.

Try this test flow

The inject nodes simulate the LED input. If you click On then Off and nothing else then it will send email message 1 out of the second trigger and then after 5 seconds the second one will be reset so nothing else will happen.
If you alternately click the inject buttons for 15 seconds then it will initially send email message 1 then after 15 seconds (which you would change to 10 minutes in practice) it will send message 2 then do nothing else unless you stop clicking for 5 seconds and then later start clicking again.

[{"id":"527db018.6efdf","type":"inject","z":"bdd7be38.d3b55","name":"LED On","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":130,"y":4860,"wires":[["734b780.6978c08"]]},{"id":"68d1727c.358dac","type":"inject","z":"bdd7be38.d3b55","name":"LED Off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":130,"y":4900,"wires":[["734b780.6978c08"]]},{"id":"734b780.6978c08","type":"trigger","z":"bdd7be38.d3b55","name":"","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"5","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":300,"y":4880,"wires":[["b007b8ab.290ce8"],["6e64dc7f.9ed2dc"]]},{"id":"8c515ab0.8582b","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":4820,"wires":[]},{"id":"b007b8ab.290ce8","type":"trigger","z":"bdd7be38.d3b55","name":"","op1":"First email message","op2":"Second email message","op1type":"str","op2type":"str","duration":"15","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":640,"y":4880,"wires":[["8c515ab0.8582b"]]},{"id":"6e64dc7f.9ed2dc","type":"change","z":"bdd7be38.d3b55","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":4920,"wires":[["b007b8ab.290ce8"]]}]

[Edit] You can make the second trigger send the second message to a separate output if it makes the email handling easier, for example if you need a different subject or To or something.

Thank you Colin. That worked just as I needed. It took me a while to understand the logic behind it, but now it all makes sense to this newbie.

Hello, Looking for some help again. My switch node is not doing what I want it to do. I want it to filter out pin 7 message if either of the pin 13 or 15 are going to send a message. On our machine the pin 7 light flashes when pin 13 or pin 15 lights are flashing, pin 7 also flashes at the end of the program M30. I added my flow below, hopefully it comes through correct.

    {
        "id": "dfa66ed2.a24ba",
        "type": "rpi-gpio in",
        "z": "28754085.99b7d",
        "name": "Top Light Pin 7",
        "pin": "7",
        "intype": "tri",
        "debounce": "500",
        "read": false,
        "x": 80,
        "y": 420,
        "wires": [
            [
                "bffab6b6.7bb4b8",
                "f40369ad.d643e8"
            ]
        ]
    },
    {
        "id": "747a304a.5c10f",
        "type": "rpi-gpio in",
        "z": "28754085.99b7d",
        "name": "Cycle Start Light Pin 11",
        "pin": "11",
        "intype": "tri",
        "debounce": "500",
        "read": false,
        "x": 100,
        "y": 60,
        "wires": [
            [
                "381bdbb8.c0b854"
            ]
        ]
    },
    {
        "id": "dbf5ab36.c85078",
        "type": "rpi-gpio in",
        "z": "28754085.99b7d",
        "name": "Alarm Light Pin 13",
        "pin": "13",
        "intype": "tri",
        "debounce": "500",
        "read": false,
        "x": 90,
        "y": 240,
        "wires": [
            [
                "bf35e40a.ac7b98",
                "7a8ec6dc.eb8bf8"
            ]
        ]
    },
    {
        "id": "d7153cf1.5ecbb",
        "type": "rpi-gpio in",
        "z": "28754085.99b7d",
        "name": "Pallet Movable Light Pin 15",
        "pin": "15",
        "intype": "tri",
        "debounce": "500",
        "read": false,
        "x": 110,
        "y": 660,
        "wires": [
            [
                "17897b15.939f75",
                "9d44c456.2f6e18"
            ]
        ]
    },
    {
        "id": "bf35e40a.ac7b98",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "",
        "op1": "",
        "op2": "",
        "op1type": "pay",
        "op2type": "payl",
        "duration": "5",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 2,
        "x": 300,
        "y": 240,
        "wires": [
            [
                "4ac251ce.3744d",
                "3bd2f706.f23648"
            ],
            [
                "d758991d.80b038",
                "c782707f.2ae7f"
            ]
        ]
    },
    {
        "id": "1336e054.4569b",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "pin 13 msg",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 870,
        "y": 220,
        "wires": []
    },
    {
        "id": "4ac251ce.3744d",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "",
        "op1": "Machine Alarmed Out",
        "op2": "Machine Still Alarmed Out",
        "op1type": "str",
        "op2type": "str",
        "duration": "10",
        "extend": false,
        "overrideDelay": false,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 690,
        "y": 240,
        "wires": [
            [
                "1336e054.4569b",
                "f7d9ba7b.a94c38"
            ]
        ]
    },
    {
        "id": "d758991d.80b038",
        "type": "change",
        "z": "28754085.99b7d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 500,
        "y": 280,
        "wires": [
            [
                "4ac251ce.3744d"
            ]
        ]
    },
    {
        "id": "381bdbb8.c0b854",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "CS trigger",
        "op1": "flashing",
        "op2": "on or off",
        "op1type": "str",
        "op2type": "str",
        "duration": "5",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 360,
        "y": 60,
        "wires": [
            [
                "bb5958dc.4e4bb8",
                "ff054d24.01117",
                "430030ee.72dc8"
            ]
        ]
    },
    {
        "id": "ed463b72.1f9188",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "message",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 980,
        "y": 20,
        "wires": []
    },
    {
        "id": "bb5958dc.4e4bb8",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "",
        "op1": "",
        "op2": "1",
        "op1type": "nul",
        "op2type": "str",
        "duration": "10",
        "extend": false,
        "overrideDelay": false,
        "units": "s",
        "reset": "on or off",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 770,
        "y": 60,
        "wires": [
            [
                "ed463b72.1f9188",
                "f03ddbf6.129f88"
            ]
        ]
    },
    {
        "id": "ff054d24.01117",
        "type": "change",
        "z": "28754085.99b7d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "on or off",
                "pt": "msg",
                "to": "reset",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 100,
        "wires": [
            [
                "bb5958dc.4e4bb8",
                "7a5cf8ea.790978"
            ]
        ]
    },
    {
        "id": "f03ddbf6.129f88",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "",
        "op1": "Waiting for Cycle Start M0 or M1",
        "op2": "Still waiting for Cycle Start M0 or M1",
        "op1type": "str",
        "op2type": "str",
        "duration": "10",
        "extend": false,
        "overrideDelay": false,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1110,
        "y": 60,
        "wires": [
            [
                "1e587619.82635a"
            ]
        ]
    },
    {
        "id": "7a5cf8ea.790978",
        "type": "change",
        "z": "28754085.99b7d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 900,
        "y": 100,
        "wires": [
            [
                "f03ddbf6.129f88"
            ]
        ]
    },
    {
        "id": "17897b15.939f75",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "Pallet trigger",
        "op1": "flashing",
        "op2": "on or off",
        "op1type": "str",
        "op2type": "str",
        "duration": "5",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 470,
        "y": 660,
        "wires": [
            [
                "92e5e99b.444248",
                "ecfee490.21f788",
                "184b68cd.886a67"
            ]
        ]
    },
    {
        "id": "b370b6ef.503628",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "Pallet message",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 940,
        "y": 620,
        "wires": []
    },
    {
        "id": "ecfee490.21f788",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "",
        "op1": "",
        "op2": "1",
        "op1type": "nul",
        "op2type": "str",
        "duration": "10",
        "extend": false,
        "overrideDelay": false,
        "units": "s",
        "reset": "on or off",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 710,
        "y": 660,
        "wires": [
            [
                "b370b6ef.503628",
                "9e4ee62a.21f568"
            ]
        ]
    },
    {
        "id": "92e5e99b.444248",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "Pallet trigger 1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 680,
        "y": 620,
        "wires": []
    },
    {
        "id": "184b68cd.886a67",
        "type": "change",
        "z": "28754085.99b7d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "on or off",
                "pt": "msg",
                "to": "reset",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 490,
        "y": 700,
        "wires": [
            [
                "ecfee490.21f788",
                "66e919c2.72bee8"
            ]
        ]
    },
    {
        "id": "9e4ee62a.21f568",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "",
        "op1": "Waiting for Pallet Button",
        "op2": "Still waiting for Pallet Botton",
        "op1type": "str",
        "op2type": "str",
        "duration": "10",
        "extend": false,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 970,
        "y": 660,
        "wires": [
            [
                "f7d9ba7b.a94c38",
                "d3c4296.70854d8"
            ]
        ]
    },
    {
        "id": "66e919c2.72bee8",
        "type": "change",
        "z": "28754085.99b7d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 700,
        "wires": [
            [
                "9e4ee62a.21f568"
            ]
        ]
    },
    {
        "id": "f40369ad.d643e8",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "Top Light trigger",
        "op1": "flashing",
        "op2": "on or off",
        "op1type": "str",
        "op2type": "str",
        "duration": "5",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 320,
        "y": 420,
        "wires": [
            [
                "ee49817d.da3e5",
                "1f0aa54a.3eb2ab",
                "c4905a6b.e17d28"
            ]
        ]
    },
    {
        "id": "4fa74f8d.30b25",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "Top Light message",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 890,
        "y": 380,
        "wires": []
    },
    {
        "id": "1f0aa54a.3eb2ab",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "",
        "op1": "",
        "op2": "1",
        "op1type": "nul",
        "op2type": "str",
        "duration": "10",
        "extend": false,
        "overrideDelay": false,
        "units": "s",
        "reset": "on or off",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 650,
        "y": 420,
        "wires": [
            [
                "4fa74f8d.30b25",
                "4a1e92c2.449a7c"
            ]
        ]
    },
    {
        "id": "ee49817d.da3e5",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "Top Light trigger 1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 550,
        "y": 380,
        "wires": []
    },
    {
        "id": "c4905a6b.e17d28",
        "type": "change",
        "z": "28754085.99b7d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "on or off",
                "pt": "msg",
                "to": "reset",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 450,
        "y": 460,
        "wires": [
            [
                "1f0aa54a.3eb2ab",
                "87e9f813.4705d8"
            ]
        ]
    },
    {
        "id": "4a1e92c2.449a7c",
        "type": "trigger",
        "z": "28754085.99b7d",
        "name": "",
        "op1": "Waiting for Top Light M30",
        "op2": "Still waiting for Top Light M0 or M1",
        "op1type": "str",
        "op2type": "str",
        "duration": "10",
        "extend": false,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 950,
        "y": 420,
        "wires": [
            [
                "f7d9ba7b.a94c38",
                "90300f15.42c25"
            ]
        ]
    },
    {
        "id": "87e9f813.4705d8",
        "type": "change",
        "z": "28754085.99b7d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 740,
        "y": 460,
        "wires": [
            [
                "4a1e92c2.449a7c"
            ]
        ]
    },
    {
        "id": "9d44c456.2f6e18",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "pin 15",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 290,
        "y": 620,
        "wires": []
    },
    {
        "id": "7a8ec6dc.eb8bf8",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "pin 13",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 270,
        "y": 200,
        "wires": []
    },
    {
        "id": "bffab6b6.7bb4b8",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "pin 7",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 230,
        "y": 380,
        "wires": []
    },
    {
        "id": "f7d9ba7b.a94c38",
        "type": "switch",
        "z": "28754085.99b7d",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Machine Alarmed Out",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "Waiting for Pallet Button",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "Waiting for Top Light M30",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 3,
        "x": 1270,
        "y": 380,
        "wires": [
            [
                "8d87b288.7404d",
                "1e587619.82635a"
            ],
            [
                "8d87b288.7404d",
                "1e587619.82635a"
            ],
            [
                "8d87b288.7404d",
                "1e587619.82635a"
            ]
        ]
    },
    {
        "id": "90300f15.42c25",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "pin 7 msg",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1020,
        "y": 480,
        "wires": []
    },
    {
        "id": "d3c4296.70854d8",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "pin 15 msg",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1150,
        "y": 680,
        "wires": []
    },
    {
        "id": "8d87b288.7404d",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "switch",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1410,
        "y": 320,
        "wires": []
    },
    {
        "id": "c782707f.2ae7f",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "trigger2",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 300,
        "y": 300,
        "wires": []
    },
    {
        "id": "3bd2f706.f23648",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "trigger1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 460,
        "y": 200,
        "wires": []
    },
    {
        "id": "430030ee.72dc8",
        "type": "debug",
        "z": "28754085.99b7d",
        "name": "CS trigger 1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 550,
        "y": 20,
        "wires": []
    }
]```

I have not attempted to fully understand your flow, but I suspect you need to put a Join node before the Switch in order to combine the messages on the individual wires into one message, so you can make decisions based on all the current states. Have a look at the node red cookbook example Joining Streams for how to do that. Import that example and play with it to understand how it works.

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