diff --git a/homeassistant/components/esphome/__init__.py b/homeassistant/components/esphome/__init__.py index 47ef51087d2..e4dceb304b7 100644 --- a/homeassistant/components/esphome/__init__.py +++ b/homeassistant/components/esphome/__init__.py @@ -380,7 +380,7 @@ def _async_setup_device_registry( config_entry_id=entry.entry_id, configuration_url=configuration_url, connections={(dr.CONNECTION_NETWORK_MAC, device_info.mac_address)}, - name=device_info.name, + name=device_info.friendly_name or device_info.name, manufacturer=manufacturer, model=model, sw_version=sw_version, @@ -705,6 +705,8 @@ class EsphomeEntity(Entity, Generic[_InfoT, _StateT]): self._component_key = component_key self._key = key self._state_type = state_type + if entry_data.device_info is not None and entry_data.device_info.friendly_name: + self._attr_has_entity_name = True async def async_added_to_hass(self) -> None: """Register callbacks.""" diff --git a/homeassistant/components/esphome/config_flow.py b/homeassistant/components/esphome/config_flow.py index 0108b723276..4b6e8ccb9ab 100644 --- a/homeassistant/components/esphome/config_flow.py +++ b/homeassistant/components/esphome/config_flow.py @@ -179,8 +179,10 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN): mac_address = format_mac(mac_address) # Hostname is format: livingroom.local. - self._name = discovery_info.hostname.removesuffix(".local.") - self._device_name = self._name + device_name = discovery_info.hostname.removesuffix(".local.") + + self._name = discovery_info.properties.get("friendly_name", device_name) + self._device_name = device_name self._host = discovery_info.host self._port = discovery_info.port @@ -306,7 +308,8 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN): finally: await cli.disconnect(force=True) - self._name = self._device_name = self._device_info.name + self._name = self._device_info.friendly_name or self._device_info.name + self._device_name = self._device_info.name await self.async_set_unique_id( self._device_info.mac_address, raise_on_progress=False ) diff --git a/homeassistant/components/esphome/entry_data.py b/homeassistant/components/esphome/entry_data.py index c677effbcb0..24322fdac47 100644 --- a/homeassistant/components/esphome/entry_data.py +++ b/homeassistant/components/esphome/entry_data.py @@ -100,6 +100,13 @@ class RuntimeEntryData: """Return the name of the device.""" return self.device_info.name if self.device_info else self.entry_id + @property + def friendly_name(self) -> str: + """Return the friendly name of the device.""" + if self.device_info and self.device_info.friendly_name: + return self.device_info.friendly_name + return self.name + @callback def async_update_ble_connection_limits(self, free: int, limit: int) -> None: """Update the BLE connection limits.""" diff --git a/homeassistant/components/esphome/manifest.json b/homeassistant/components/esphome/manifest.json index 014b6d6d6e0..3e92f5a515c 100644 --- a/homeassistant/components/esphome/manifest.json +++ b/homeassistant/components/esphome/manifest.json @@ -3,7 +3,7 @@ "name": "ESPHome", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/esphome", - "requirements": ["aioesphomeapi==13.0.4", "esphome-dashboard-api==1.1"], + "requirements": ["aioesphomeapi==13.1.0", "esphome-dashboard-api==1.1"], "zeroconf": ["_esphomelib._tcp.local."], "dhcp": [{ "registered_devices": true }], "codeowners": ["@OttoWinter", "@jesserockz"], diff --git a/requirements_all.txt b/requirements_all.txt index ddc84a9ca7a..5970eca0153 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -159,7 +159,7 @@ aioecowitt==2022.11.0 aioemonitor==1.0.5 # homeassistant.components.esphome -aioesphomeapi==13.0.4 +aioesphomeapi==13.1.0 # homeassistant.components.flo aioflo==2021.11.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 8a00296fe9f..8c0d61eb173 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -146,7 +146,7 @@ aioecowitt==2022.11.0 aioemonitor==1.0.5 # homeassistant.components.esphome -aioesphomeapi==13.0.4 +aioesphomeapi==13.1.0 # homeassistant.components.flo aioflo==2021.11.0