Detect the three (On, Off, Flashing) status of the status LED

I have a printer.
If someone is using it the status LED stays ON.
If the printer is idle status LED stays OFF.
If the printer needs human assistance the status LED start blinking.
I have all wiring is done with a RPi.
I could not find any answers in arduino sits. Some are couldn't understand the question also.
Could you please anyone help me with this.
Ps.
Am I the only one who trying to do this.
All the search results comes with blinking or flashing examples.
Nothing comes explaining how to detect blinking, on, off stages.

Do you mean you want to fit a photo detector over the led so you can monitor it in node red?

If not then how can node red know the led state?

Thank you Colin for your reply. I'm a fan. as I mention in the post I have soldered optocouplers to the printer. actually, it is not a printer, it is something else. if I mention the device people always go off-topic, try to advise me about the device. so little bit about me, I'm someone who looks after a charity organization thanks to Node-red and Arduino. The answer to this question helps to feed a couple of poor kids.

And I was able to make sure the status LED is not blinking by using the trigger node. because I know the blanking interval is close to 1 second and then I set the "wait for" duration for 3 seconds and put the check on " extend delay if a new message arrives". then I select " send the second message to separate output". no is the LED is blinking (every ~= 1 seconds) the trigger node will not send the second message.
so I can say if the input signal is a steady HIGH or LOW signal after 3 seconds. do whatever I want I just have to connect my next node to the second output of the trigger node. but this is not 100% correct because I can not get an output if the input signal is blinking. if the input signal is blinking the trigger node will not send any output on its second output unless the blinking is stopped. here is the flow if anyone is interested.
I'm not sure am I following the correct path.

[{"id":"d318095415d98909","type":"trigger","z":"1c5170b3014b5238","name":"","op1":"0","op2":"1","op1type":"str","op2type":"str","duration":"3","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":540,"y":260,"wires":[[],["6f3093058b476da1"]]},{"id":"6f3093058b476da1","type":"change","z":"1c5170b3014b5238","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"val","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":280,"wires":[["acfe2ff1f2c07060"]]},{"id":"acfe2ff1f2c07060","type":"debug","z":"1c5170b3014b5238","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":990,"y":280,"wires":[]},{"id":"118462504273a056","type":"inject","z":"1c5170b3014b5238","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":130,"y":260,"wires":[["d318095415d98909","1fad8a192dbb8577"]]},{"id":"3c2d5956255233f0","type":"inject","z":"1c5170b3014b5238","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":130,"y":320,"wires":[["d318095415d98909","1fad8a192dbb8577"]]},{"id":"1fad8a192dbb8577","type":"change","z":"1c5170b3014b5238","name":"","rules":[{"t":"set","p":"val","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":340,"wires":[[]]}]

OK, so is this a summary of the question you want answered?
There are input messages containing 1 or 0. You want to identify the following conditions
1: Value 1 for three or more seconds
2. Value 0 for three or more seconds
3. At least two transitions within three seconds (blinking)

I think this is a better way of identifying 1 and 2. I need to think about 3.

[{"id":"724f545fd7bf6e2e","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":1060,"wires":[["0088264d5ec043e0"]]},{"id":"d3afe5b4d2abf255","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":1120,"wires":[["0088264d5ec043e0"]]},{"id":"0088264d5ec043e0","type":"trigger","z":"bdd7be38.d3b55","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"3","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":300,"y":1080,"wires":[["564b9cb598191dd8"]]},{"id":"564b9cb598191dd8","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":470,"y":1080,"wires":[]}]

How about this. It generates 0 or 1 for the steady state, and 2 for flashing.

image

[{"id":"724f545fd7bf6e2e","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":1080,"wires":[["0088264d5ec043e0","b964430623f63f65"]]},{"id":"d3afe5b4d2abf255","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":1140,"wires":[["0088264d5ec043e0","b964430623f63f65"]]},{"id":"0088264d5ec043e0","type":"trigger","z":"bdd7be38.d3b55","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"3","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":300,"y":1080,"wires":[["15ac12ead560209c"]]},{"id":"564b9cb598191dd8","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":1100,"wires":[]},{"id":"b964430623f63f65","type":"function","z":"bdd7be38.d3b55","name":"","func":"let lastTime = context.get(\"lastTime\") || 0\nconst now = new Date().getTime()\n// is it more than three seconds since last transition?\nif (now - lastTime > 3000) {\n    // yes, not flashing so send nothing\n    msg = null\n} else {\n    // yes, send 2 to indicate flashing\n    msg.payload = 2\n}\ncontext.set(\"lastTime\", now)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":1140,"wires":[["15ac12ead560209c"]]},{"id":"15ac12ead560209c","type":"rbe","z":"bdd7be38.d3b55","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":450,"y":1100,"wires":[["564b9cb598191dd8"]]}]

I can't immediately see a simple way of doing it without a Function node. Likely someone else will suggest something.

Thank you, Colin. this is fantastic. I think no one will find a solution better than this.
so ill tell you what this printer is. it is a waste processing machine located in a 5-star hotel. I design it 20 - 15 years ago. it has a couple (Trash, Plastic, Paper, etc..) bins. so the hotel has several floors and each floor has a waste disposal door with a couple of buttons to select the type of waste you gonna throw. it was a 24v system, I used a PLC. now the problem is rich people staying in this hotel needs fancy things, they like touch screen. so, my good friend, the hotel owner needs a simple replacement. that's where the Raspberry pi with a Nextion touch display comes into play. if the machine is busy light is on. if the machine is idle light is off. if the bin is full, or any error, the light is blinking. I just have to detect this using the node-red. use a bunch of relays to send 24v signals. I am lucky he did not want a solution within the PLC. I haven't done any PLC work in ages thanks to Node-red.
I have tested your solution using this simple method. anyone interested can find it here.

[    {        "id": "66ca12d46e05c56b",        "type": "inject",        "z": "5381b2ca530d2f5b",        "name": "",        "props": [            {                "p": "payload"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "1",        "payloadType": "num",        "x": 270,        "y": 460,        "wires": [            [                "8e4810f0b80722d0",                "f40aa5e50b19a6e5"            ]        ]    },    {        "id": "cffda58a8f5bc8ea",        "type": "inject",        "z": "5381b2ca530d2f5b",        "name": "",        "props": [            {                "p": "payload"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "0",        "payloadType": "num",        "x": 270,        "y": 520,        "wires": [            [                "8e4810f0b80722d0",                "f40aa5e50b19a6e5"            ]        ]    },    {        "id": "8e4810f0b80722d0",        "type": "trigger",        "z": "5381b2ca530d2f5b",        "name": "",        "op1": "",        "op2": "",        "op1type": "nul",        "op2type": "payl",        "duration": "3",        "extend": true,        "overrideDelay": false,        "units": "s",        "reset": "",        "bytopic": "all",        "topic": "topic",        "outputs": 1,        "x": 440,        "y": 460,        "wires": [            [                "db2cef659100bfac"            ]        ]    },    {        "id": "4f7b9f965ae15b74",        "type": "debug",        "z": "5381b2ca530d2f5b",        "name": "",        "active": true,        "tosidebar": true,        "console": false,        "tostatus": false,        "complete": "false",        "statusVal": "",        "statusType": "auto",        "x": 770,        "y": 480,        "wires": []    },    {        "id": "f40aa5e50b19a6e5",        "type": "function",        "z": "5381b2ca530d2f5b",        "name": "",        "func": "let lastTime = context.get(\"lastTime\") || 0\nconst now = new Date().getTime()\n// is it more than three seconds since last transition?\nif (now - lastTime > 3000) {\n    // yes, not flashing so send nothing\n    msg = null\n} else {\n    // yes, send 2 to indicate flashing\n    msg.payload = 2\n}\ncontext.set(\"lastTime\", now)\nreturn msg;",        "outputs": 1,        "noerr": 0,        "initialize": "",        "finalize": "",        "libs": [],        "x": 440,        "y": 520,        "wires": [            [                "db2cef659100bfac"            ]        ]    },    {        "id": "db2cef659100bfac",        "type": "rbe",        "z": "5381b2ca530d2f5b",        "name": "",        "func": "rbe",        "gap": "",        "start": "",        "inout": "out",        "septopics": false,        "property": "payload",        "topi": "topic",        "x": 610,        "y": 480,        "wires": [            [                "4f7b9f965ae15b74"            ]        ]    },    {        "id": "e49a03e0698363c2",        "type": "inject",        "z": "5381b2ca530d2f5b",        "name": "Start Blink",        "props": [            {                "p": "payload"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "Blinking",        "payloadType": "str",        "x": 280,        "y": 600,        "wires": [            [                "d0aad311604f266a"            ]        ]    },    {        "id": "13a34d52e01d3da8",        "type": "inject",        "z": "5381b2ca530d2f5b",        "name": "Stop Blink",        "props": [            {                "p": "payload"            }        ],        "repeat": "",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "stopped",        "payloadType": "str",        "x": 280,        "y": 660,        "wires": [            [                "d0aad311604f266a"            ]        ]    },    {        "id": "d0aad311604f266a",        "type": "change",        "z": "5381b2ca530d2f5b",        "name": "",        "rules": [            {                "t": "set",                "p": "flag",                "pt": "global",                "to": "payload",                "tot": "msg"            }        ],        "action": "",        "property": "",        "from": "",        "to": "",        "reg": false,        "x": 460,        "y": 620,        "wires": [            [                "3a4b1105a58ec1e0"            ]        ]    },    {        "id": "fb58cc94152386ec",        "type": "inject",        "z": "5381b2ca530d2f5b",        "name": "",        "props": [            {                "p": "payload"            }        ],        "repeat": "2",        "crontab": "",        "once": false,        "onceDelay": 0.1,        "topic": "",        "payload": "0",        "payloadType": "num",        "x": 290,        "y": 280,        "wires": [            [                "ed42337fac677327"            ]        ]    },    {        "id": "ed42337fac677327",        "type": "trigger",        "z": "5381b2ca530d2f5b",        "name": "",        "op1": "0",        "op2": "1",        "op1type": "num",        "op2type": "num",        "duration": "1",        "extend": false,        "overrideDelay": false,        "units": "s",        "reset": "",        "bytopic": "all",        "topic": "topic",        "outputs": 1,        "x": 280,        "y": 320,        "wires": [            [                "f3d0e25f31fa052d"            ]        ]    },    {        "id": "f3d0e25f31fa052d",        "type": "function",        "z": "5381b2ca530d2f5b",        "name": "",        "func": "node.status({fill:\"blue\",shape:\"ring\",text: msg.payload});    \n\nreturn msg;",        "outputs": 1,        "noerr": 0,        "initialize": "",        "finalize": "",        "libs": [],        "x": 280,        "y": 360,        "wires": [            [                "06b8a5802bb97cc8"            ]        ]    },    {        "id": "06b8a5802bb97cc8",        "type": "switch",        "z": "5381b2ca530d2f5b",        "name": "",        "property": "flag",        "propertyType": "global",        "rules": [            {                "t": "neq",                "v": "stopped",                "vt": "str"            }        ],        "checkall": "true",        "repair": false,        "outputs": 1,        "x": 270,        "y": 400,        "wires": [            [                "8e4810f0b80722d0",                "f40aa5e50b19a6e5"            ]        ]    },    {        "id": "3a4b1105a58ec1e0",        "type": "function",        "z": "5381b2ca530d2f5b",        "name": "",        "func": "node.status({fill:\"blue\",shape:\"ring\",text: msg.payload});    \n\nreturn msg;",        "outputs": 1,        "noerr": 0,        "initialize": "",        "finalize": "",        "libs": [],        "x": 680,        "y": 620,        "wires": [            []        ]    }]

Dear Colin, Thanks again it was great. I have learned a couple of things thanks to your example. the hotel people have hired someone to do the installation. he does not like the 3-second delay. he does not like means the boss also. is it possible to do something about it? I am ok with the 3-second delay. but that is only me. is it okay if I PM a video sent by them? if it is not affecting your busy schedules.
Thanks.

If they just want a shorter delay you can reduce it to just over the max time for two transitions.

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