From 7def587c9305646f46ca5f8474bb6d46c7aebfb4 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Tue, 23 Oct 2018 11:33:56 +0100 Subject: [PATCH] Only strip from the bluetooth name if it isn't None (#17719) This prevents the following traceback that will otherwise occur. Traceback (most recent call last): File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/bluetooth_le_tracker.py", line 107, in update_ble see_device(address, devs[address], new_device=True) File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/bluetooth_le_tracker.py", line 47, in see_device see(mac=BLE_PREFIX + address, host_name=name.strip("\x00"), AttributeError: 'NoneType' object has no attribute 'strip' --- .../components/device_tracker/bluetooth_le_tracker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/device_tracker/bluetooth_le_tracker.py b/homeassistant/components/device_tracker/bluetooth_le_tracker.py index 47b86ab9ab2..a07fdfdcf81 100644 --- a/homeassistant/components/device_tracker/bluetooth_le_tracker.py +++ b/homeassistant/components/device_tracker/bluetooth_le_tracker.py @@ -44,7 +44,10 @@ def setup_scanner(hass, config, see, discovery_info=None): new_devices[address] = 1 return - see(mac=BLE_PREFIX + address, host_name=name.strip("\x00"), + if name is not None: + name = name.strip("\x00") + + see(mac=BLE_PREFIX + address, host_name=name, source_type=SOURCE_TYPE_BLUETOOTH_LE) def discover_ble_devices():