mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Add default substitutions for package includes (#5752)
This commit is contained in:
		| @@ -185,6 +185,7 @@ CONF_DEFAULT_MODE = "default_mode" | ||||
| CONF_DEFAULT_TARGET_TEMPERATURE_HIGH = "default_target_temperature_high" | ||||
| CONF_DEFAULT_TARGET_TEMPERATURE_LOW = "default_target_temperature_low" | ||||
| CONF_DEFAULT_TRANSITION_LENGTH = "default_transition_length" | ||||
| CONF_DEFAULTS = "defaults" | ||||
| CONF_DELAY = "delay" | ||||
| CONF_DELIMITER = "delimiter" | ||||
| CONF_DELTA = "delta" | ||||
|   | ||||
| @@ -282,7 +282,7 @@ class ESPHomeLoader(FastestAvailableSafeLoader): | ||||
|             return file, vars | ||||
|  | ||||
|         def substitute_vars(config, vars): | ||||
|             from esphome.const import CONF_SUBSTITUTIONS | ||||
|             from esphome.const import CONF_SUBSTITUTIONS, CONF_DEFAULTS | ||||
|             from esphome.components import substitutions | ||||
|  | ||||
|             org_subs = None | ||||
| @@ -294,7 +294,15 @@ class ESPHomeLoader(FastestAvailableSafeLoader): | ||||
|             elif CONF_SUBSTITUTIONS in result: | ||||
|                 org_subs = result.pop(CONF_SUBSTITUTIONS) | ||||
|  | ||||
|             defaults = {} | ||||
|             if CONF_DEFAULTS in result: | ||||
|                 defaults = result.pop(CONF_DEFAULTS) | ||||
|  | ||||
|             result[CONF_SUBSTITUTIONS] = vars | ||||
|             for k, v in defaults.items(): | ||||
|                 if k not in result[CONF_SUBSTITUTIONS]: | ||||
|                     result[CONF_SUBSTITUTIONS][k] = v | ||||
|  | ||||
|             # Ignore missing vars that refer to the top level substitutions | ||||
|             substitutions.do_substitution_pass(result, None, ignore_missing=True) | ||||
|             result.pop(CONF_SUBSTITUTIONS) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user