esphome-blekeyboard icon indicating copy to clipboard operation
esphome-blekeyboard copied to clipboard

[BUG] can connect to android, but not to (linux) pc

Open prankousky opened this issue 3 months ago • 1 comments

Hi,

I was hoping to control my linux PC with this project. I flashed an ESP32, connected it to Home Assistant. I can find the device with two different android devices and connect to it. Some buttons will work, others won't. But connection and at least some buttons work.

But the device won't connect to my PC / my PC won't connect to it. It won't even discover it. It is discoverable, I made sure by testing if "start/stop advertising" works by pressing those buttons, then checking my android phones. When I do, the desired action will happen. So it should be discoverable when I click "start advertising".

However, it won't show. Since I know the MAC, I tried manually connecting and pairing it (via bluetoothctl and bluetuith), but am only getting "Device not available".

What can be done to fix this?

My entire configuration is attached below.

Please complete the following information:

  • ESPHome version: 2024.3.1
  • Component version: not sure how to find this; I included the lines below in my yaml, so I assume it is the most current, stable version..?
external_components:
  - source: github://dmamontov/esphome-blekeyboard


esphome:
  name: blekeyboard
  friendly_name: BLEKeyboard

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:
  level: VERY_VERBOSE
  
# Enable Home Assistant API
api:
  encryption:
    key: "yes"

ota:
  password: "indeed"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password


  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Blekeyboard Fallback Hotspot"
    password: "himom"

captive_portal:
    
external_components:
  - source: github://dmamontov/esphome-blekeyboard

ble_keyboard:
  id: my_ble_keyboard
  name: "MamonTechKeyboard"
  manufacturer_id: "MamonTech"
  battery_level: 50
  reconnect: true
  buttons: true
  use_default_libs: false

text_sensor:
  - platform: homeassistant
    id: input_text
    entity_id: input_text.global_fritzbox_letzter_anruf
    internal: true

sensor:
  - platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 60s

button:
  - platform: restart
    entity_category: "config"
    name: "Restart"

  - platform: template
    name: "Release"
    id: key_release
    icon: "mdi:send"
    on_press:
      then:
        - ble_keyboard.print:
            id: my_ble_keyboard
            text: !lambda "return id(input_text).state;"
        - ble_keyboard.release: my_ble_keyboard

  - platform: template
    name: "Ctrl + A"
    id: key_ctrl_a
    icon: "mdi:vector-combine"
    on_press:
      then:
        - ble_keyboard.combination:
            id: my_ble_keyboard
            delay: 8
            keys:
              - 0x80
              - "a"

  - platform: template
    name: "Calc"
    id: key_calc
    icon: "mdi:calculator"
    on_press:
      then:
        - ble_keyboard.press:
            id: my_ble_keyboard
            code:
              - 0
              - 2

  - platform: template
    name: "Start advertising"
    id: start_advertising
    icon: "mdi:play"
    on_press:
      then:
        - ble_keyboard.start: my_ble_keyboard

  - platform: template
    name: "Stop advertising"
    id: stop_advertising
    icon: "mdi:stop"
    on_press:
      then:
        - ble_keyboard.stop: my_ble_keyboard

prankousky avatar Mar 27 '24 14:03 prankousky