The lady of the house asked me to install some LED strips in the house, but those also have to be controllable via physical hardware switches.
So I started looking around about reading a physical button from Node-RED. The only thing I found were some nice flows flows from @Trying_to_learn. However I was looking for a single node, to keep my flows simple. I must admit I was "very" surprised that I found none, in an active IOT community like this one. Perhaps it already exists, and I used the wrong keywords during my search...
Anyway I have now developed my own one now: node-red-contrib-button-events.
It can be wired to a GPIO-in node, and can detect all kind of button events:
- pressed: when a button is pressed and held down.
- clicked: when a button is pressed and released rapidly.
- clicked_pressed: when a click is quickly followed by pressing and holding the button.
- double_clicked: when a click is quickly followed with another click.
- released: when the pressed button is released.
I would like to thank Bryan Nielsen. I found his rpi-gpio-buttons and asked him whether I could have a separate button event detection library, without the gpio stuff (since we already have that inside the gpio nodes). The next day he offered me already his button-events library. What a support
It would be nice to get some 'constructive' feedback before I publish it on npm.
Have fun with it!!