fsievers22 / esphome-ble-remote

ESPHome external component for a BLE HID client
MIT License
25 stars 10 forks source link
amazon-remote ble ble-client ble-hid esp-idf esp32 esphome firetv firetv-remote hid hid-host remote shield-remote

ESPHome external component to read hid events from a ble client

The ble_client_hid external component foor ESPHome can be used to capture hid events like key presses from a hid device connected via Bluetooth LE. Boards without internal PSRAM seem to be not compatible

Tested working with:

How to Use

Add as external component:

See External Components:

external_components:
  # use ble_client_hid from this master branch in GitHub
  - source: github://fsievers22/esphome-ble-remote@master
    components: [ ble_client_hid ]

Component:

Multiple ble_client_hid components can be configured, but at max three. (See BLE Client notes for more info).

The device has to use the esp-idf framework:

esp32:
  board: az-delivery-devkit-v4  #modify to fit your board
  framework:                    #only works n esp-idf framework
    type: esp-idf

Each ble_client_hid component requires a ble_client.

esp32_ble_tracker:            

ble_client:
  - id: ble_client_1
    mac_address: "FF:FF:20:00:0F:15"    #modify to fit your ble device

ble_client_hid:
  - id: ble_client_hid_1
    ble_client_id: ble_client_1

Configuration variables:

Battery sensor:

The ble_client_hid sensor lets you track the battery level of the BLE HID client.

esp32_ble_tracker:            

ble_client:
  - id: ble_client_1
    mac_address: "48:B0:2D:52:29:C6"    #modify to fit your ble device

ble_client_hid:
  - id: ble_client_hid_1
    ble_client_id: ble_client_1

sensor:
  - platform: ble_client_hid
    ble_client_hid_id: ble_client_hid_1
    name: "Battery"

Configuration variables:

last event sensors:

The component can expose the last received event through a combination of a sensor and a text sensor.

sensor:
  - platform: ble_client_hid
    type: last_event_value
    name: "Last Event Value"

text_sensor:
  - platform: ble_client_hid
    name: "Last Event Usage"

Configuration variables:

Example device configuration:

esp32:
  board: az-delivery-devkit-v4  #modify to fit your board
  framework:                    #only works n esp-idf framework
    type: esp-idf

esphome:
  name: example-ble-hid         

external_components:
  # use ble_client_hid from this master branch in GitHub
  - source: github://fsievers22/esphome-ble-remote@master
    components: [ ble_client_hid ]

# Enable logging
logger:
  level: INFO

# Enable Home Assistant API
api:

ota:
  password: !secret ota_password

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

esp32_ble_tracker:            

ble_client:
  - id: ble_client_1
    mac_address: "48:B0:2D:52:29:C6"    #modify to fit your ble device

ble_client_hid:
  - id: ble_client_hid_1
    ble_client_id: ble_client_1

sensor:
  - platform: ble_client_hid
    type: battery
    ble_client_hid_id: ble_client_hid_1
    name: "Battery"
  - platform: ble_client_hid
    type: last_event_value
    ble_client_hid_id: ble_client_hid_1
    name: "Last Event Value"

text_sensor:
  - platform: ble_client_hid
    ble_client_hid_id: ble_client_hid_1
    name: "Last Event Usage"