mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	fix prefix in expanded
This commit is contained in:
		| @@ -231,12 +231,28 @@ def merge_component_configs( | ||||
|         # This allows components that use local file references to be grouped | ||||
|         comp_abs_dir = str(comp_dir.absolute()) | ||||
|  | ||||
|         # Prefix substitutions in component data | ||||
|         if "substitutions" in comp_data and comp_data["substitutions"] is not None: | ||||
|             prefixed_subs = {} | ||||
|             for sub_name, sub_value in comp_data["substitutions"].items(): | ||||
|                 prefixed_subs[f"{comp_name}_{sub_name}"] = sub_value | ||||
|             comp_data["substitutions"] = prefixed_subs | ||||
|         # Prefix substitutions in component data (including those in packages) | ||||
|         # Must do this recursively before expanding packages | ||||
|         def prefix_all_substitutions(data, prefix): | ||||
|             """Recursively prefix substitution definitions in data structure.""" | ||||
|             if isinstance(data, dict): | ||||
|                 # Prefix substitutions at this level | ||||
|                 if "substitutions" in data and data["substitutions"] is not None: | ||||
|                     prefixed_subs = {} | ||||
|                     for sub_name, sub_value in data["substitutions"].items(): | ||||
|                         prefixed_subs[f"{prefix}_{sub_name}"] = sub_value | ||||
|                     data["substitutions"] = prefixed_subs | ||||
|  | ||||
|                 # Recursively process nested dicts (like packages) | ||||
|                 for key, value in data.items(): | ||||
|                     if key != "substitutions":  # Already handled above | ||||
|                         data[key] = prefix_all_substitutions(value, prefix) | ||||
|             elif isinstance(data, list): | ||||
|                 return [prefix_all_substitutions(item, prefix) for item in data] | ||||
|  | ||||
|             return data | ||||
|  | ||||
|         comp_data = prefix_all_substitutions(comp_data, comp_name) | ||||
|  | ||||
|         # Add component_dir substitution with absolute path for this component | ||||
|         if "substitutions" not in comp_data or comp_data["substitutions"] is None: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user