diff --git a/homeassistant/components/device_tracker/__init__.py b/homeassistant/components/device_tracker/__init__.py index 05131a039cd..0b18cc72f6e 100644 --- a/homeassistant/components/device_tracker/__init__.py +++ b/homeassistant/components/device_tracker/__init__.py @@ -76,6 +76,7 @@ ATTR_LOCATION_NAME = 'location_name' ATTR_MAC = 'mac' ATTR_NAME = 'name' ATTR_SOURCE_TYPE = 'source_type' +ATTR_VENDOR = 'vendor' SOURCE_TYPE_GPS = 'gps' SOURCE_TYPE_ROUTER = 'router' @@ -285,11 +286,6 @@ class DeviceTracker(object): if device.track: yield from device.async_update_ha_state() - self.hass.bus.async_fire(EVENT_NEW_DEVICE, { - ATTR_ENTITY_ID: device.entity_id, - ATTR_HOST_NAME: device.host_name, - }) - # During init, we ignore the group if self.group and self.track_new: self.group.async_set_group( @@ -299,6 +295,13 @@ class DeviceTracker(object): # lookup mac vendor string to be stored in config yield from device.set_vendor_for_mac() + self.hass.bus.async_fire(EVENT_NEW_DEVICE, { + ATTR_ENTITY_ID: device.entity_id, + ATTR_HOST_NAME: device.host_name, + ATTR_MAC: device.mac, + ATTR_VENDOR: device.vendor, + }) + # update known_devices.yaml self.hass.async_add_job( self.async_update_config( diff --git a/tests/components/device_tracker/test_init.py b/tests/components/device_tracker/test_init.py index a8531e2aa69..704b2590f12 100644 --- a/tests/components/device_tracker/test_init.py +++ b/tests/components/device_tracker/test_init.py @@ -481,6 +481,8 @@ class TestComponentsDeviceTracker(unittest.TestCase): assert test_events[0].data == { 'entity_id': 'device_tracker.hello', 'host_name': 'hello', + 'mac': 'MAC_1', + 'vendor': 'unknown', } # pylint: disable=invalid-name