diff --git a/homeassistant/components/unifi/device_tracker.py b/homeassistant/components/unifi/device_tracker.py index 8ab5140dc48..d0c2684ff53 100644 --- a/homeassistant/components/unifi/device_tracker.py +++ b/homeassistant/components/unifi/device_tracker.py @@ -188,7 +188,9 @@ def update_items(controller, async_add_entities, tracked): tracked[client_id] = UniFiClientTracker(client, controller) new_tracked.append(tracked[client_id]) LOGGER.debug( - "New UniFi client tracker %s (%s)", client.hostname, client.mac + "New UniFi client tracker %s (%s)", + client.name or client.hostname, + client.mac, ) if not controller.unifi_config.get(CONF_DONT_TRACK_DEVICES, False): @@ -208,7 +210,11 @@ def update_items(controller, async_add_entities, tracked): tracked[device_id] = UniFiDeviceTracker(device, controller) new_tracked.append(tracked[device_id]) - LOGGER.debug("New UniFi device tracker %s (%s)", device.name, device.mac) + LOGGER.debug( + "New UniFi device tracker %s (%s)", + device.name or device.model, + device.mac, + ) if new_tracked: async_add_entities(new_tracked) @@ -311,7 +317,7 @@ class UniFiDeviceTracker(ScannerEntity): @property def name(self) -> str: """Return the name of the device.""" - return self.device.name + return self.device.name or self.device.model @property def unique_id(self) -> str: @@ -326,14 +332,18 @@ class UniFiDeviceTracker(ScannerEntity): @property def device_info(self): """Return a device description for device registry.""" - return { + info = { "connections": {(CONNECTION_NETWORK_MAC, self.device.mac)}, "manufacturer": ATTR_MANUFACTURER, "model": self.device.model, - "name": self.device.name, "sw_version": self.device.version, } + if self.device.name: + info["name"] = self.device.name + + return info + @property def device_state_attributes(self): """Return the device state attributes.""" diff --git a/homeassistant/components/unifi/manifest.json b/homeassistant/components/unifi/manifest.json index e849fd34d25..bcee022e1c4 100644 --- a/homeassistant/components/unifi/manifest.json +++ b/homeassistant/components/unifi/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/components/unifi", "requirements": [ - "aiounifi==9" + "aiounifi==10" ], "dependencies": [], "codeowners": [ diff --git a/requirements_all.txt b/requirements_all.txt index 4019393cf16..7ce12cf63f8 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -170,7 +170,7 @@ aiopvapi==1.6.14 aioswitcher==2019.4.26 # homeassistant.components.unifi -aiounifi==9 +aiounifi==10 # homeassistant.components.wwlln aiowwlln==1.0.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 23e6896d890..6cd7c3e398c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -68,7 +68,7 @@ aionotion==1.1.0 aioswitcher==2019.4.26 # homeassistant.components.unifi -aiounifi==9 +aiounifi==10 # homeassistant.components.wwlln aiowwlln==1.0.0