Skip to content

Commit

Permalink
Search for unknown entity inside sections
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Jul 19, 2024
1 parent 8580ec0 commit 55bb570
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ 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]) -> set[str]: # noqa: C901
"""Extract entities from a dashboard config."""
entities = set()
if isinstance(config, dict) and (views := config.get("views")):
Expand All @@ -101,6 +101,13 @@ def __async_extract_entities(self, config: dict[str, Any]) -> set[str]:
if cards := view.get("cards"):
for card in cards:
entities.update(self.__async_extract_entities_from_card(card))
if sections := view.get("sections"):
for section in sections:
if cards := section.get("cards"):
for card in cards:
entities.update(
self.__async_extract_entities_from_card(card)
)
return entities

@callback
Expand Down

0 comments on commit 55bb570

Please sign in to comment.