Skip to content

Commit 405ace7

Browse files
glenn20balloob
authored andcommitted
Use device information in keyboard_remote automation (home-assistant#5443)
Document proposed feature to publish device_descriptor and device_name in keyboard_remote events. This information can be used in automation triggers so that different bluetooth remotes can control different devices/automations. Pending acceptance of proposed change.
1 parent e81c692 commit 405ace7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

source/_components/keyboard_remote.markdown

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ha_iot_class: "Local Push"
1515

1616
Receive signals from a keyboard and use it as a remote control.
1717

18-
This component allows you to use a keyboard as remote control. It will fire `keyboard_remote_command_received` events which can then be used in automation rules.
18+
This component allows you to use one or more keyboards as remote controls. It will fire `keyboard_remote_command_received` events which can then be used in automation rules.
1919

2020
The `evdev` package is used to interface with the keyboard and thus this is Linux only. It also means you can't use your normal keyboard for this because `evdev` will block it.
2121

@@ -37,15 +37,17 @@ In case of presence of multiple devices of the same model, `device_descriptor` m
3737

3838
A list of possible device descriptors and names is reported in the debug log at startup when the device indicated in the configuration entry could not be found.
3939

40-
A full configuration for Keyboard Remote could look like the one below:
40+
A full configuration for two Keyboard Remotes could look like the one below:
4141

4242
```yaml
4343
keyboard_remote:
44-
device_descriptor: '/dev/input/by-id/bluetooth-keyboard'
44+
- device_descriptor: '/dev/input/by-id/bluetooth-keyboard'
45+
type: 'key_up'
46+
- device_descriptor: '/dev/input/event0'
4547
type: 'key_up'
4648
```
4749

48-
or like the following:
50+
or like the following for one keyboard:
4951

5052
```yaml
5153
keyboard_remote:
@@ -62,11 +64,13 @@ automation:
6264
platform: event
6365
event_type: keyboard_remote_command_received
6466
event_data:
67+
device_descriptor: "/dev/input/event0"
6568
key_code: 107 # inspect log to obtain desired keycode
6669
action:
6770
service: light.turn_on
6871
entity_id: light.all
6972
```
73+
`device_descriptor` or `device_name` may be specificed in the trigger so the automation will be fired only for that keyboard. This is especially useful if you wish to use several bluetooth remotes to control different devices. Omit them to ensure the same key triggers the automation for all keyboards/remotes.
7074

7175
## {% linkable_title Disconnections %}
7276
This component manages disconnections and re-connections of the keyboard, for example in the case of a Bluetooth device that turns off automatically to preserve battery.

0 commit comments

Comments
 (0)