Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ async def async_inspect(self) -> None:
LOGGER.debug("Config for dashboard %s not found, skipping", url_path)
continue

extracted_entities = self.__async_extract_entities(config)
if unknown_entities := async_filter_known_entity_ids(
self.hass,
entity_ids=self.__async_extract_entities(config),
entity_ids=set(extracted_entities.keys()),
known_entity_ids=known_entity_ids,
):
# Get the view path of the first unknown entity
first_view_path = extracted_entities[next(iter(unknown_entities))]
title = "Overview"
if dashboard.config:
title = dashboard.config.get("title", url_path)
Expand All @@ -77,7 +80,7 @@ async def async_inspect(self) -> None:
f"- `{entity_id}`" for entity_id in unknown_entities
),
"dashboard": title,
"edit": f"/{url_path}/0?edit=1",
"edit": f"/{url_path}/{first_view_path}?edit=1",
},
)
LOGGER.debug(
Expand All @@ -90,12 +93,15 @@ async def async_inspect(self) -> None:
)

@callback
def __async_extract_entities(self, config: dict[str, Any]) -> set[str]:
def __async_extract_entities(self, config: dict[str, Any]) -> dict[str, int | str]:
"""Extract entities from a dashboard config."""
entities = set()
entities: dict[str, int | str] = {}
if isinstance(config, dict) and (views := config.get("views")):
for view in views:
entities.update(self.__async_extract_entities_from_view(view))
for view_index, view in enumerate(views):
view_path: int | str = view.get("path", view_index)
for entity_id in self.__async_extract_entities_from_view(view):
if entity_id not in entities:
entities[entity_id] = view_path
return entities

@callback
Expand Down