mirror of
https://github.com/home-assistant/core.git
synced 2025-05-23 07:17:07 +00:00
Allow selection of bluetooth device to use (#5104)
Adding the device_id key to the bevice tracker component allows selecting the bluetooth device to use in case the default device does not have BLE Capabilities
This commit is contained in:
parent
c14a5fa7c1
commit
67b74abf8d
@ -19,9 +19,11 @@ REQUIREMENTS = ['gattlib==0.20150805']
|
|||||||
BLE_PREFIX = 'BLE_'
|
BLE_PREFIX = 'BLE_'
|
||||||
MIN_SEEN_NEW = 5
|
MIN_SEEN_NEW = 5
|
||||||
CONF_SCAN_DURATION = "scan_duration"
|
CONF_SCAN_DURATION = "scan_duration"
|
||||||
|
CONF_BLUETOOTH_DEVICE = "device_id"
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_SCAN_DURATION, default=10): cv.positive_int
|
vol.Optional(CONF_SCAN_DURATION, default=10): cv.positive_int,
|
||||||
|
vol.Optional(CONF_BLUETOOTH_DEVICE, default="hci0"): cv.string
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ def setup_scanner(hass, config, see):
|
|||||||
"""Discover Bluetooth LE devices."""
|
"""Discover Bluetooth LE devices."""
|
||||||
_LOGGER.debug("Discovering Bluetooth LE devices")
|
_LOGGER.debug("Discovering Bluetooth LE devices")
|
||||||
try:
|
try:
|
||||||
service = DiscoveryService()
|
service = DiscoveryService(ble_dev_id)
|
||||||
devices = service.discover(duration)
|
devices = service.discover(duration)
|
||||||
_LOGGER.debug("Bluetooth LE devices discovered = %s", devices)
|
_LOGGER.debug("Bluetooth LE devices discovered = %s", devices)
|
||||||
except RuntimeError as error:
|
except RuntimeError as error:
|
||||||
@ -65,6 +67,7 @@ def setup_scanner(hass, config, see):
|
|||||||
|
|
||||||
yaml_path = hass.config.path(YAML_DEVICES)
|
yaml_path = hass.config.path(YAML_DEVICES)
|
||||||
duration = config.get(CONF_SCAN_DURATION)
|
duration = config.get(CONF_SCAN_DURATION)
|
||||||
|
ble_dev_id = config.get(CONF_BLUETOOTH_DEVICE)
|
||||||
devs_to_track = []
|
devs_to_track = []
|
||||||
devs_donot_track = []
|
devs_donot_track = []
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user