mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Add friendly name support for ESPHome (#85976)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
8c235357a4
commit
d3c41bc31c
@ -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."""
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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."""
|
||||
|
@ -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"],
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user