From 26048d18ef3a674847d9b14b6f396b57949b7279 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 9 May 2024 13:08:30 +1000 Subject: [PATCH] [core] Ensure that a generated ID name is distinct from its type. (#6706) --- esphome/core/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 58ae23e139..f25891965a 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -340,6 +340,8 @@ class ID: if self.id is None: base = str(self.type).replace("::", "_").lower() + if base == self.type: + base = base + "_id" name = "".join(c for c in base if c.isalnum() or c == "_") used = set(registered_ids) | set(RESERVED_IDS) | CORE.loaded_integrations self.id = ensure_unique_string(name, used)