mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Always include platform in config/entity_registry/list_for_display
(#88601)
Always include platform in config/entity_registry/list_for_display
This commit is contained in:
parent
cab8a59be4
commit
1f34fa63ab
@ -173,12 +173,10 @@ class RegistryEntry:
|
|||||||
This version only includes what's needed for display.
|
This version only includes what's needed for display.
|
||||||
Returns None if there's no data needed for display.
|
Returns None if there's no data needed for display.
|
||||||
"""
|
"""
|
||||||
display_dict: dict[str, Any] = {}
|
display_dict: dict[str, Any] = {"ei": self.entity_id, "pl": self.platform}
|
||||||
for key, attr_name in DISLAY_DICT_OPTIONAL:
|
for key, attr_name in DISLAY_DICT_OPTIONAL:
|
||||||
if (attr_val := getattr(self, attr_name)) is not None:
|
if (attr_val := getattr(self, attr_name)) is not None:
|
||||||
display_dict[key] = attr_val
|
display_dict[key] = attr_val
|
||||||
if "tk" in display_dict:
|
|
||||||
display_dict["pl"] = self.platform
|
|
||||||
if (category := self.entity_category) is not None:
|
if (category := self.entity_category) is not None:
|
||||||
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:
|
||||||
@ -192,10 +190,6 @@ class RegistryEntry:
|
|||||||
precision := sensor_options.get("suggested_display_precision")
|
precision := sensor_options.get("suggested_display_precision")
|
||||||
) is not None:
|
) is not None:
|
||||||
display_dict["dp"] = precision
|
display_dict["dp"] = precision
|
||||||
if not display_dict:
|
|
||||||
# We didn't gather any data needed for display
|
|
||||||
return None
|
|
||||||
display_dict["ei"] = self.entity_id
|
|
||||||
return display_dict
|
return display_dict
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -239,23 +239,32 @@ async def test_list_entities_for_display(
|
|||||||
"di": "device123",
|
"di": "device123",
|
||||||
"ei": "test_domain.nameless",
|
"ei": "test_domain.nameless",
|
||||||
"en": None,
|
"en": None,
|
||||||
|
"pl": "test_platform",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ai": "area52",
|
"ai": "area52",
|
||||||
"di": "device123",
|
"di": "device123",
|
||||||
"ei": "test_domain.renamed",
|
"ei": "test_domain.renamed",
|
||||||
|
"pl": "test_platform",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ei": "test_domain.boring",
|
||||||
|
"pl": "test_platform",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ei": "test_domain.hidden",
|
"ei": "test_domain.hidden",
|
||||||
"hb": True,
|
"hb": True,
|
||||||
|
"pl": "test_platform",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"dp": 0,
|
"dp": 0,
|
||||||
"ei": "sensor.default_precision",
|
"ei": "sensor.default_precision",
|
||||||
|
"pl": "test_platform",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"dp": 0,
|
"dp": 0,
|
||||||
"ei": "sensor.user_precision",
|
"ei": "sensor.user_precision",
|
||||||
|
"pl": "test_platform",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@ -296,6 +305,7 @@ async def test_list_entities_for_display(
|
|||||||
"di": "device123",
|
"di": "device123",
|
||||||
"ei": "test_domain.test",
|
"ei": "test_domain.test",
|
||||||
"en": "Hello World",
|
"en": "Hello World",
|
||||||
|
"pl": "test_platform",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user