Keyboard remote does not automatically reconnect

I am using the “Namando Keypad” which is a Bluetooth numeric keyboard. It is working perfectly through the below configuration and using some automations on the buttons:
I am using Hassio installed on buster - RPI 4B

keyboard_remote:
  device_descriptor: "/dev/input/event0"
  type: 'key_up'

Issue:
Since the device disconnects automatically after some period of unuse, the reconnection does not seem to register in Home Assistant. I have checked through ‘bluetoothctl’ and the device is reconnected fine (see below) but the HA does not detect it. Even the Automation script for disconnection also does not trigger during this period. This is only restored when I restart the Home Assistant

bluetoothctl output in RPI


        Name: Namando Keypad
        Alias: Namando Keypad
        Class: 0x00000540
        Icon: input-keyboard
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: yes
        LegacyPairing: no

Automation Script

- alias: Keyboard Connected
  trigger:
    platform: event
    event_type: keyboard_remote_connected
  action:
  - service: notify.telenotify
    data_template:
      message: Bluetooth keyboard connected
  
- alias: Bluetooth Keyboard Disconnected
  trigger:
    platform: event
    event_type: keyboard_remote_disconnected
    event_data:
      device_descriptor: "/dev/input/event0"
  action:
  - service: notify.telenotify
    data_template:
      message: Bluetooth keyboard Diconnected
1 Like

Update to the above:
Issue still consistently occurring,
The device does disappear and reappear as expected when it goes to sleep and reactivated respectively. I could see the details of the connectivity in the linux console. Also confirmed from LED as there is a small led in keyboard which turns red and green as expected.

I found out that the actual input files I think get changed everytime a reconnect is made. The below is the output of cat /proc/bus/input/devices
The input# in the below S:…/input/input0 always gets a new number. Is this the source of the problem? If yes, the device_descriptor: “/dev/input/event0” should have automatically referred to the right files - unable to understand why does it now work

I: Bus=0005 Vendor=xxxx Product=1234 Version=011b
N: Name="Namando Keypad Keyboard"
P: Phys=xx:xx:xx:xx:xx:xx
S: Sysfs=/devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:11/xxxx:xxxx:xxxx.xxxx/input/input0
U: Uniq=xx:xx:xx:xx:xx:xx
H: Handlers=sysrq kbd leds event0
B: PROP=0
B: EV=120013
B: MSC=10
B: LED=1f
1 Like

I have investigated further, I got another similar remote. And this remote somehow reconnects properly and promptly to HA. I am able to get consitent notification even after prolonged sleep. So I guess, it is to do with the device rather than the HA or RPI. The device I used is similar to this:

[https://www.amazon.com/Onewell-Bluetooth-Adapter-Steering-Compatible/dp/B07ZYRWZGY/ref=sr_1_6?keywords=car+bluetooth+audio+remote&qid=1577090510&sr=8-6]

This issue is still persisting in latest 109.2 release. Although I have successfully paired my old Amazon Fire TV remote still it doesn’t reconnect automatically. I need to restart HA every time. Guys please help me resolve this issue. Shall we re-post this issue into Github ?

1 Like

Any updates? I am getting the same issue. :-/

As I stated above, don’t think the issue is with HA. I believe it is the device which does not retain the info to reconnect after sleep. Some devices do and connect properly. You might want to go via a BLE mode

Hmm. When watching bluetoothctl it reconnects and the device info shows „connected“ but HA does not recognize it. Is there an event missing?

What do you mean with BLE? Do you have a solution in your mind? Please share it :slight_smile:

If the keypads were on BLE, we could use the chips like esp32 to record keystrokes for each ble event. Currently the cheap iTag that has 1 button can easily be connected to esp32 and their actions captured and sent to HA