diff --git a/src/pyatmo/modules/base_class.py b/src/pyatmo/modules/base_class.py index 72e457e9..41701547 100644 --- a/src/pyatmo/modules/base_class.py +++ b/src/pyatmo/modules/base_class.py @@ -35,11 +35,12 @@ def default(key: str, val: Any) -> Any: return lambda x, _: x.get(key, val) -def deduplicate(data: str) -> str: +def update_name(name: str, pre_fix: str) -> str: """Remove duplicates from string.""" - seen: set[str] = set() - seen_add = seen.add - return " ".join([x for x in data.split() if not (x in seen or seen_add(x))]) + + if name.startswith(pre_fix): + return name + return f"{pre_fix} {name}" class EntityBase: @@ -69,9 +70,7 @@ def update_topology(self, raw_data: RawData) -> None: and self.bridge in self.home.modules and getattr(self, "device_category") == "weather" ): - self.name = deduplicate( - f"{self.home.modules[self.bridge].name} {self.name}", - ) + self.name = update_name(self.name, self.home.modules[self.bridge].name) def _update_attributes(self, raw_data: RawData) -> None: """Update attributes."""