Can you define constants in jinja templates that you can then import in YAML and use (eg reuse across various ESPHome .yaml files)?

I’m testing it out now but it doesn’t seem to work. Curious if this is formally supported or I’m just trying something that will never work. Thanks.

ESPHome I don’t think uses jinja. It uses functions and lambdas. Remember the processor here is an esp chip not a python software package.

Take a look at substitutions and packages for reusing code.

1 Like

Thank you both.
@Mahko_Mahko this is exactly what I was looking for!!

1 Like