esphome-blekeyboard
esphome-blekeyboard copied to clipboard
Option to not advertise upon startup
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