Skip to content

Commit

Permalink
Fixed automatic removal of non-existing datasets,fixes #153
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaae committed Apr 24, 2024
1 parent d4cd011 commit 4234ed7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/truenas/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ def get_dataset(self) -> None:
for device in device_registry.devices.values():
if (
self.config_entry.entry_id in device.config_entries
and device.name.endswith(" Datasets")
and device.name.endswith("Datasets")
):
self.datasets_hass_device_id = device.id
_LOGGER.debug(f"datasets device: {device.name}")
Expand All @@ -887,7 +887,10 @@ def get_dataset(self) -> None:
if (
entity.device_id == self.datasets_hass_device_id
and entity.unique_id.removeprefix(f"{self.name.lower()}-dataset-")
not in map(str.lower, self.ds["dataset"].keys())
not in map(
lambda x: str.replace(x, "/", "_"),
map(str.lower, self.ds["dataset"].keys()),
)
):
_LOGGER.debug(f"dataset to be removed: {entity.unique_id}")
entities_to_be_removed.append(entity.entity_id)
Expand Down

0 comments on commit 4234ed7

Please sign in to comment.