mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Fix bluetooth tracker source (#11469)
* Add new sources for bluetooth and bluetooth_le trackers (rather than just using the generic 'gps' catch-all). * Fix lint issues
This commit is contained in:
parent
3bc6a7da32
commit
a23f60315f
@ -80,6 +80,8 @@ ATTR_VENDOR = 'vendor'
|
||||
|
||||
SOURCE_TYPE_GPS = 'gps'
|
||||
SOURCE_TYPE_ROUTER = 'router'
|
||||
SOURCE_TYPE_BLUETOOTH = 'bluetooth'
|
||||
SOURCE_TYPE_BLUETOOTH_LE = 'bluetooth_le'
|
||||
|
||||
NEW_DEVICE_DEFAULTS_SCHEMA = vol.Any(None, vol.Schema({
|
||||
vol.Optional(CONF_TRACK_NEW, default=DEFAULT_TRACK_NEW): cv.boolean,
|
||||
|
@ -10,7 +10,7 @@ import voluptuous as vol
|
||||
from homeassistant.helpers.event import track_point_in_utc_time
|
||||
from homeassistant.components.device_tracker import (
|
||||
YAML_DEVICES, CONF_TRACK_NEW, CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL,
|
||||
PLATFORM_SCHEMA, load_config
|
||||
PLATFORM_SCHEMA, load_config, SOURCE_TYPE_BLUETOOTH_LE
|
||||
)
|
||||
import homeassistant.util.dt as dt_util
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
@ -54,7 +54,8 @@ def setup_scanner(hass, config, see, discovery_info=None):
|
||||
new_devices[address] = 1
|
||||
return
|
||||
|
||||
see(mac=BLE_PREFIX + address, host_name=name.strip("\x00"))
|
||||
see(mac=BLE_PREFIX + address, host_name=name.strip("\x00"),
|
||||
source_type=SOURCE_TYPE_BLUETOOTH_LE)
|
||||
|
||||
def discover_ble_devices():
|
||||
"""Discover Bluetooth LE devices."""
|
||||
|
@ -12,7 +12,7 @@ import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.event import track_point_in_utc_time
|
||||
from homeassistant.components.device_tracker import (
|
||||
YAML_DEVICES, CONF_TRACK_NEW, CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL,
|
||||
load_config, PLATFORM_SCHEMA, DEFAULT_TRACK_NEW)
|
||||
load_config, PLATFORM_SCHEMA, DEFAULT_TRACK_NEW, SOURCE_TYPE_BLUETOOTH)
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -33,7 +33,8 @@ def setup_scanner(hass, config, see, discovery_info=None):
|
||||
|
||||
def see_device(device):
|
||||
"""Mark a device as seen."""
|
||||
see(mac=BT_PREFIX + device[0], host_name=device[1])
|
||||
see(mac=BT_PREFIX + device[0], host_name=device[1],
|
||||
source_type=SOURCE_TYPE_BLUETOOTH)
|
||||
|
||||
def discover_devices():
|
||||
"""Discover Bluetooth devices."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user