mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[core] Ensure that a generated ID name is distinct from its type. (#6706)
This commit is contained in:
		
				
					committed by
					
						 Jesse Hills
						Jesse Hills
					
				
			
			
				
	
			
			
			
						parent
						
							0883f0efd7
						
					
				
				
					commit
					26048d18ef
				
			| @@ -340,6 +340,8 @@ class ID: | |||||||
|  |  | ||||||
|         if self.id is None: |         if self.id is None: | ||||||
|             base = str(self.type).replace("::", "_").lower() |             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 == "_") |             name = "".join(c for c in base if c.isalnum() or c == "_") | ||||||
|             used = set(registered_ids) | set(RESERVED_IDS) | CORE.loaded_integrations |             used = set(registered_ids) | set(RESERVED_IDS) | CORE.loaded_integrations | ||||||
|             self.id = ensure_unique_string(name, used) |             self.id = ensure_unique_string(name, used) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user