How to respond to keyboard events

I am running Home Assistant OS version 10.5 (core 2024.1.6) on an RPI 3. I want to trigger an action by typing a key on my USB keyboard. This is what I do:

I connect my keyboard to one of the USB ports and try to find the device name:
ls /dev/input/by-id
It gives me this line:
lrwxrwxrwx 1 root root 9 Apr 4 2023 usb_keyboard-event-kbd -> ../event0

So I should use the device /dev/input/event0. Someone wrote that it is possible to to read directly from the port (I am the “root” user):
cat /dev/input/event0
Then I get the message Operation is not permitted.

Maybe this is normal. I don’t know, so I continue to set upp the Keyboard Remote integration in configuration.yaml:

  device_descriptor: "/dev/input/event0"
  type: "key_down"

I go to Developer Tools > YAML and reload all yaml configuration

I go to Developer tools > Events and starts listening to the event
Nothing happens when I type a key on the keyboard

There is nothing connected to this in the log file.

What am I missing?

Although I don’t know how that would work on HAOS, you can try trough the device_name

$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      2.4G Composite Devic
/dev/input/event1:      2.4G Composite Devic Mouse
/dev/input/event2:      2.4G Composite Devic Consumer Control
/dev/input/event3:      2.4G Composite Devic System Control
/dev/input/event4:      Power Button
/dev/input/event5:      Power Button
/dev/input/event6:      PC Speaker
/dev/input/event7:      HDA Digital PCBeep
/dev/input/event8:      HDA Intel PCH Front Mic
/dev/input/event9:      HDA Intel PCH Rear Mic
/dev/input/event10:     HDA Intel PCH Line
/dev/input/event11:     HDA Intel PCH Line Out Front
/dev/input/event12:     HDA Intel PCH Line Out Surround
/dev/input/event13:     HDA Intel PCH Line Out CLFE
/dev/input/event14:     HDA Intel PCH Front Headphone
Select the device event number [0-14]: 
- device_name: '2.4G Composite Devic'
    - 'key_up'
    - 'key_down'
    - 'key_hold'
- device_name: '2.4G Composite Devic Consumer Control'
    - 'key_up'
    - 'key_down'
- device_name: '2.4G Composite Devic System Control'
    - 'key_up'
    - 'key_down'

There is no evtest utility in HASS OS, so I installed it by:
apk add evtest

When I run sudo evtest I get
evtest: Operation not permitted

Is there another way to find the device name?

Is there a problem with the HASS OS configuration? Is it running in a docker container? Does that change the way I have to address issues with USB ports?

It suddenly started working when I rebooted my RPI. My mistake was that I selected
Developer tools > YAML > YAML Configuration reloading > All YAML Configuration
after each change in the configuration.yaml file.

That was apparently not enough. I suspect that some information in the yaml files are only read when restarting the system.