mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Add has_entity_name to entity display dict and fix name (#125832)
* Add has_entity_name to entity display dict and fix name * Fix tests
This commit is contained in:
parent
d90cdf24f5
commit
b471a6e519
@ -235,8 +235,11 @@ class RegistryEntry:
|
|||||||
display_dict["ec"] = ENTITY_CATEGORY_VALUE_TO_INDEX[category]
|
display_dict["ec"] = ENTITY_CATEGORY_VALUE_TO_INDEX[category]
|
||||||
if self.hidden_by is not None:
|
if self.hidden_by is not None:
|
||||||
display_dict["hb"] = True
|
display_dict["hb"] = True
|
||||||
if not self.name and self.has_entity_name:
|
if self.has_entity_name:
|
||||||
display_dict["en"] = self.original_name
|
display_dict["hn"] = True
|
||||||
|
name = self.name or self.original_name
|
||||||
|
if name is not None:
|
||||||
|
display_dict["en"] = name
|
||||||
if self.domain == "sensor" and (sensor_options := self.options.get("sensor")):
|
if self.domain == "sensor" and (sensor_options := self.options.get("sensor")):
|
||||||
if (precision := sensor_options.get("display_precision")) is not None or (
|
if (precision := sensor_options.get("display_precision")) is not None or (
|
||||||
precision := sensor_options.get("suggested_display_precision")
|
precision := sensor_options.get("suggested_display_precision")
|
||||||
|
@ -245,6 +245,7 @@ async def test_list_entities_for_display(
|
|||||||
"ec": 1,
|
"ec": 1,
|
||||||
"ei": "test_domain.test",
|
"ei": "test_domain.test",
|
||||||
"en": "Hello World",
|
"en": "Hello World",
|
||||||
|
"hn": True,
|
||||||
"ic": "mdi:icon",
|
"ic": "mdi:icon",
|
||||||
"lb": [],
|
"lb": [],
|
||||||
"pl": "test_platform",
|
"pl": "test_platform",
|
||||||
@ -254,7 +255,7 @@ async def test_list_entities_for_display(
|
|||||||
"ai": "area52",
|
"ai": "area52",
|
||||||
"di": "device123",
|
"di": "device123",
|
||||||
"ei": "test_domain.nameless",
|
"ei": "test_domain.nameless",
|
||||||
"en": None,
|
"hn": True,
|
||||||
"lb": [],
|
"lb": [],
|
||||||
"pl": "test_platform",
|
"pl": "test_platform",
|
||||||
},
|
},
|
||||||
@ -262,6 +263,8 @@ async def test_list_entities_for_display(
|
|||||||
"ai": "area52",
|
"ai": "area52",
|
||||||
"di": "device123",
|
"di": "device123",
|
||||||
"ei": "test_domain.renamed",
|
"ei": "test_domain.renamed",
|
||||||
|
"en": "User name",
|
||||||
|
"hn": True,
|
||||||
"lb": [],
|
"lb": [],
|
||||||
"pl": "test_platform",
|
"pl": "test_platform",
|
||||||
},
|
},
|
||||||
@ -326,6 +329,7 @@ async def test_list_entities_for_display(
|
|||||||
"ai": "area52",
|
"ai": "area52",
|
||||||
"di": "device123",
|
"di": "device123",
|
||||||
"ei": "test_domain.test",
|
"ei": "test_domain.test",
|
||||||
|
"hn": True,
|
||||||
"lb": [],
|
"lb": [],
|
||||||
"en": "Hello World",
|
"en": "Hello World",
|
||||||
"pl": "test_platform",
|
"pl": "test_platform",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user