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

Option to not advertise upon startup

Open Rudd-O opened this issue 1 year ago • 3 comments

With some devices, it is preferable simply not to advertise at all the return of the ESP keyboard once it restarts.

This option enables users to choose that.

They can create a switch to turn advertisements off in this way:

globals:
  - id: keyboard_enabled
    type: bool
    restore_value: no
    initial_value: "false"

switch:
  - platform: template
    name: Enabled
    icon: mdi:power
    lambda: |-
      if (id(keyboard_enabled)) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - ble_keyboard.start: le_keyboard
      - lambda: |-
          id(keyboard_enabled) = true;
      - logger.log:
          format: "The keyboard has been enabled."
          level: INFO
    turn_off_action:
      - ble_keyboard.stop: le_keyboard
      - lambda: |-
          id(keyboard_enabled) = false;
      - logger.log:
          format: "The keyboard has been disabled."
          level: INFO

Rudd-O avatar Mar 12 '23 20:03 Rudd-O