Binding for USB Input

Hi,
I would like to use my small wireless USB Keyboard (attached with a magnet to the wall) as a lightswitch & more for my openhab smart home system on a RPi 3 B+.

I couldn´t find the according binding which listens to USB input in order to trigger rules with a single keypress.

Am I missing something?

You won’t find a binding that supports this AFAIK, and to be honest it sounds a bit too “special-purpose” to fit with a binding.

Depending on exactly what you are trying to achieve, however, there may be others ways to solve this. A bit more detail would be necessary in that case.

Are you really trying to use specific keys on a keyboard as dedicated light switches? Or are you looking for a more general way of navigating a UI for your openHAB-based lighting system?

Thanks for your response.

Indeed I want to achieve dedicated light switches, as well as to stop/snooze the morning alarm and similar things with a single keypress.

Hopefully there´s a solution.

Input devices are not treated like other USB type devices. There is no file under /dev that I know of that you can watch to get keyboard entries (I could be wrong).

So what you will need to find is a Linux based keylogger that can be compiled on an ARM processor and modify it to publish messages to OH (REST API calls, MQTT, etc) when certain keys are pressed.

Good luck!

I would have hoped for a binding that can read evdev events from /dev/input/ (https://www.kernel.org/doc/html/latest/input/input.html#event-interface) and trigger OH events from that.
This should be possible with native or java logic. This would only give raw keycodes though.
Maybe somebody here has already worked on that?

I wrote something like this here: https://github.com/t-8ch/binding-linuxinput

Thank you, that’s exactly what I’m looking for. Could you please share a precompiled .jar file here since I don’t know how to do that. Thank you very much in advance.

You can download a .jar from this page: https://github.com/t-8ch/binding-linuxinput/releases/tag/v1.0-rc1
In case of issues, please open a ticket on GitHub.

Works like a charm,
thank you for your work :slight_smile: