Keyboard Remote

Hey there,

I’m using a usb dongle flirc to hopefully emulate keyboard buttons:

I’m using the keyboard remote integration but caught up with getting the automations to fire

Here is my sample automation:

  • id: key_up
    initial_state: 'on
    alias: Key Up
    trigger:
    platform: event
    event_type: keyboard_remote_command_received
    event_data:
    key_code: 38
    action:
    service: script.turn_on
    entity_id:
    - script.press_up

I have checked my hardware using the has command:

hassio host hardware

The inquiry says there is an input called “flirc.tv flirc”

I am using the following configuration here for the remote input:

keyboard_remote:
  type: 'key_down'
  #  device_descriptor: '/dev/input/event0'
  device_descriptor: '/dev/input/event'
  #  device_descriptor: '/dev/input/by-id/flirc.tv_flirc'

I’ve had some trial and error but no results just yet. You’ll seem my commented lines above trying different inputs.

Could anyone give me hand? Is this related to a user issue with hassio?

Thank you

Im on the same boat, trying to do the same.

Any luck?

I just managed to get this working myself with a bluetooth keyboard on a rpi3, but I’m not using hassio.

It required a restart of my pi in order for it to work. The device_descriptor for mine /dev/input/event0 .

I would implement the automations for connection and disconnection, if you don’t have them, so you at least know that is working.

Also, make sure to tail /var/log/syslog for the correct key codes. I found my keyboard isn’t using standard key codes.

tail /var/log/syslog won’t show me the key-codes
so i use a small python script i found here:

another Great trick is to make an automation like this:

- alias: find out Key codes
  trigger:
    platform: event
    event_type: keyboard_remote_command_received
    event_data:
      device_descriptor: /dev/input/event0
  action:
  - service: input_text.set_value
    data_template:
      entity_id: input_text.mykeycode
      value: '{{ trigger.event.data.key_code }}'

any key press will output the key code to the frontend HA site
Cheers

2 Likes

Keyboard not working anymore since 0.92… Sad!

1 Like

i can see a commit done today


maybe its working now?

i am curios :slight_smile:

working again!

####################################################################
###### TEST keys code from Wireless Numpad #########################
- alias: find out Key codes
  trigger:
    platform: event
    event_type: keyboard_remote_command_received
    event_data:
#      device_descriptor: /dev/input/event
      device_descriptor: "/dev/input/event0"
  action:
  - service: input_text.set_value
    data_template:
      entity_id: input_text.mykeycode
      value: '{{ trigger.event.data.key_code }}'
######################################################################
##### wireless numpad ENTER 96 code ##################################
- alias: USBkeyb 96 Mi lamp
  initial_state: 'on'
  trigger:
    platform: event
    event_type: keyboard_remote_command_received
    event_data:
      device_descriptor: "/dev/input/event0"
      key_code: 96 # inspect log to obtain desired keycode
  action:
    service: light.toggle
    entity_id: light.desk_working_mi_lamp

config.yaml

keyboard_remote:
- device_descriptor: '/dev/input/event0'
  type: 'key_down'
1 Like

Some cheap stickers and keyboard from Aliexpress - and Fun is here:

Hi,

I finally got my Flirc working with Hassio, so thought I’d share my findings hoping it will save time for others.

I did all the things the op and others mentioned doing, but no matter what, I couldn’t get my Flirc working. Because others reported they got their Flirc working, it motivated me to put some extra effort into this.

My Docker BaseOS is Debian10 so I installed ‘evtest’ on it. I ran evtest and it showed my flirc device on serial event3. I selected event3 for evtest to monitor traffic from that device. When I tried it gave me an error that my flirc was already grabbed by another process.

This took me quite awhile, but finally figured out it was being grabbed by libinput at startup. I found that this is done in a configuration file for libinput. The config file is /usr/share/x11/xorg.conf.d/40-libinput.conf. Flirc is a keybord device so in the configuration file this section is causing libinput to grab my flirc at startup:

Section "InputClass"
        Identifier "libinput keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

To tell libinput to ignore my fllirc, I added this section to the libinput config file and rebooted:

Section "InputClass"
        Identifier "Ignore Fllirc USB Keyboard"
        MatchDevicePath "/dev/input/event3"
        Option   "Ignore" "on"
EndSection

After rebooting I ran evtest and this time successfully entered monitor mode!! So I grabbed my remote and started pressing buttons expecting evtest to display them on the terminal. But nothing… nada. :frowning:

After yet more google research, I found that the Flirc was designed years ago to support a Windows MCE (media center entertainment) remote. The flirc has a built-in key map matrix. If a valid Windows MCE remote key is not received, it tosses it away to bit landia.

If your remote is not MCE compatible, you’ll need to remap the flirc to recognize your remote. To to this I had to install the flirc_utility for linux program, and use the record function to create the new key map.

After doing that I ran evtest again, this time evtest displayed every key I pressed!! Yay

So then I added to my configuration.yaml file:

keyboard_remote:
  device_name: 'flirc.tv flirc Keyboard'
  type: 'key_down'

Then I went to the developers tools panel for events and started the event listener for the event: ‘keyboard_remote_command_received’

Now when I press a key on my remote, I get an event found reply for each key, like so:

Event 0 fired 8:33 PM:
{
    "event_type": "keyboard_remote_command_received",
    "data": {
        "key_code": 3,
        "device_descriptor": null,
        "device_name": "flirc.tv flirc Keyboard"
    },
    "origin": "LOCAL",
    "time_fired": "2019-09-20T03:33:03.796183+00:00",
    "context": {
        "id": "a23c89777ab64db1b3d8797270c1a702",
        "parent_id": null,
        "user_id": null
    }
}

HOORAY, my Flirc now works!!!

2 Likes

I don’t know why but I don’t see the /dev/input folder in my container hassio supervisor or homeassistant. In the hadware section of hassio an input entry ‘flirc.tv flirc’ appears but when I navigate to the dev folder there is no input folder inside

Some help?

I have the docker in a synology nas. Maybe I have to install flirc’s drivers in the synology nas?

Thank you… this is precisely what worked for me. Running Hass.io on a Pi3+, and was confused about why I wasn’t seeing any /dev/input/* device files, while Supervisor -> System -> Host System -> Hardware was showing:

input:
  - flirc.tv flirc Keyboard
  - flirc.tv flirc System Control
  - flirc.tv flirc Consumer Control
1 Like

Velly,
I have followed your instructions but nothing is coming up in the dashboard for the key presses. The automation is firing everytime a press a button, but it wont give me the actual numerical code. Sorry, this is my first time using Home Assistant. Please let me know if I missed anything.

Hello. I somewhat had similar problem and it turned out it is because I am running my Home Assistant with user different than root (I am using the docker container and set my own PUID and GUID). the /dev/input devices have permissions to be only used by root so you have to add your own user as well.

  1. in docker container execute apk add evtest then select your flirc device and try to press buttons to see if it works.
  2. Go to this site and follow the Permissions section Keyboard Remote - Home Assistant

for example my case:
apk add acl
getfacl /dev/input/event* → you will see only root has access
echo $PUID → see your user id
setfacl -m u:HASS_USER:rw /dev/input/event* → replace HASS_USER with your PUID
getfacl /dev/input/event* → now you will see your user there as well

now when you go to Developer Tools in Home assistant and listen to keyboard_remote_command_received event it will show your inputs.

1 Like