ESPHome BLE Keyboard

@adesanto84 Hi. All the buttons work as expected, but advertising doesn’t work in esp-idf. Is it possible to configure advertising? I can’t get it to work. In older builds, you could set the keyboard to automatically turn off, which was very useful. Now it’s always connected to my phone even when I don’t need it.

I made my own fork with the help of Claude. My version is focused mainly on controlling multimedia functions of smartphones and other devices. These devices must support Bluetooth keyboard connection and understand standard multimedia codes.

My version is different from alesanto84’s version. It has two features:

  1. Auto-connect. The connection starts automatically when Home Assistant sends a command.
  2. Auto-disconnect. The connection closes automatically 30 seconds after the command is done.

This means the connection is not kept active all the time. This saves battery power.

Some bugs may happen when using other keys (not multimedia keys). But multimedia buttons work in a stable way.

Unfortunately, the stability of the ESP device can be affected by the smartphone’s own operating system logic. The OS may handle commands differently.

I tried to make the examples as clear as possible. This is for people who do not have much experience with ESPHome yet. All templates are in the “examples” folder.

PS Why did I even need this? To expose these buttons to the voice assistant and skip tracks on Chromecast using voice commands. By default, only the device that started the cast can switch tracks. :face_with_symbols_on_mouth: