Error using !include {file: file.yaml, vars: {}}

I’m having troubles trying to include a file using substitution:
configuration.yaml

homeassistant:
  packages:
    this_works: !include packages_test.yaml
    error_a: !include { file: packages_test.yaml, vars: { test: 'a1' } }
    error_b: !include { file: packages_test.yaml }

packages_test.yaml

mqtt:
  cover:
    - name: "test"
      availability:
        - topic: "shellies/shellyswitch25-foooo/online"

I’ve manage to found and read the following resources:

Splitting up the configuration
Packages
Reduce the size of config file (yaml) - many repeats Not Home Assistant Core :upside_down_face:
YAML <<: !include or package substitution variables? Not Home Assistant Core :upside_down_face:

And everything seems fine, but I have not much experience using YAML format. Thanks

The last link you provided leads to a discussion about “variable substitutions” and the following Pull Request (PR):

If you look carefully at that link, it’s a PR for ESPHome. The feature was added to ESPHome, not Home Assistant Core.

My bad. Fooled by the favicon. So, no way to use variables in that way in HA, right?

A search of all closed PRs in the Core repo, for “variable substitutions”, doesn’t produce any related results.

https://github.com/home-assistant/core/pulls?q=is%3Apr+is%3Aclosed+variable+substitutions

In other words, in Home Assistant, the !include directive supports a simple string argument and not ESPHome’s fancier version.

1 Like