Keyboard repeat behavior

I'm making a flow that takes user input (in this case from an IR remote ultimately). I can get about 10 events per second from holding down a button on the remote, so what I want to do is implement some kind of hold down detection.

In other words, I want to send one event immediately, and then wait say 500ms to start sending the next events if and only if the input event doesn't change. So sort of like an RBE that stops blocking events after 500ms. I didn't see an easy way to do that with the RBE node, so I'm thinking I'll have to code it up in a function node, but was wondering if there was something already existing that would be able to do it directly already.

You could use a combination of trigger nodes and possibly a delay node.
e.g.

[{"id":"7b2477e1.1cad2","type":"delay","z":"c74669a0.6a34f8","name":"","pauseType":"rate","timeout":"3","timeoutUnits":"seconds","rate":"10","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":330,"y":2960,"wires":[["4d79e519.e0686c","d4497007.bf66e"]]},{"id":"99d0b13d.4e6c68","type":"split","z":"c74669a0.6a34f8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":170,"y":2960,"wires":[["7b2477e1.1cad2"]]},{"id":"4d79e519.e0686c","type":"trigger","z":"c74669a0.6a34f8","name":"","op1":"","op2":"reset","op1type":"nul","op2type":"str","duration":"350","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":450,"y":2880,"wires":[["d4497007.bf66e"]]},{"id":"d4497007.bf66e","type":"trigger","z":"c74669a0.6a34f8","name":"","op1":"","op2":"held down","op1type":"pay","op2type":"str","duration":"500","extend":false,"overrideDelay":false,"units":"ms","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":630,"y":2920,"wires":[["88d1c3acdc0c6f43"]]},{"id":"bc97dbc59e7fba8b","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1]","payloadType":"json","x":90,"y":3000,"wires":[["99d0b13d.4e6c68"]]},{"id":"2bfa29fc.b5ad86","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4,5]","payloadType":"json","x":90,"y":3080,"wires":[["99d0b13d.4e6c68"]]},{"id":"bc672e6f.f1b1f8","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2]","payloadType":"json","x":90,"y":3040,"wires":[["99d0b13d.4e6c68"]]},{"id":"88d1c3acdc0c6f43","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":2900,"wires":[]}]

Play with the timing to adjust how long you must hold down the remote button.
The inject and split are just to simulate repeated messages.

1 Like

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