Assume there is some constant which is used for different sensors, automation, …
If these things are defined in same yaml file, it is possible to define a constant on the top of the file and then used by a yaml anchor:
xxxxxxxxxx: &ref_const 1234
...
some_option_1: *ref_constant
...
some_option_2: *ref_constant
...
But if the constant is used in different yaml files - then a possible way is using secrets:
global_constant: 1234
some_option: !secret global_constant
Similarly dictionaries may be available globally as secrets:
settings_for_input_number:
min: 0
max: 100
step: 1
mode: slider
input_number:
number_1: !secret settings_for_input_number
Storing global constants & dicts in “secrets.yaml” (either a global file or placed on some tree level of a config dir) may declutter the “secrets.yaml”.
Another way is using “!include”.
In some way it is more preferable than secrets - global definitions may be shared for other people when exposing the HA setup on Github.
But you need to create a separate file for each definition! (could be weird if a definition is ONE value)
Also, each “!include” directive should contain a full path to the included file - which may be cumbersome.
Means - we need to have a possibility to keep several definitions in ONE file (like secrets) but this file should be safe to expose.
Question - is it possible to add a NEW directive which may be used like
some_option: !const global_constant
...
input_number:
number_1: !const settings_for_input_number
and these “global_constant” & “settings_for_input_number” definitions can be stored in ONE file?
Probably with same logic as “secrets.yaml”: if some requested definition is not found in the same folder → go to an upper level and so on.