Switch between multiple YAML files for same MCU

I have some MCUs that are constantly used for experimenting.

It turns out that the YAML code for these MCUs fills up with more and more blocks of code that are commented out because they came from other experiments and I don’t want to loose them.

It would be much easier to use multiple YAML files for the same MCU and load one or the other into it.
So I tried to create different files with identical esphome.name settings. But the problem is that ESPHome derives both the compilation path as well as the WIFI hostname from this name setting.

So I can choose between two horns of the torro to kill me:

  1. I use a different esphome.name in both YAML files
    In this case ESPHome will assign a different WIFI hostname and will not find the MCU for upload.
    So this option is a no-go.
  2. I use the same esphome.name in both YAML files
    Now ESPHome uses the same compilation path for both YAML files. Switching between the two takes a lot of time because everything is compiled from scratch.
    So this option works but is time consuming.

Is there a more elegant way to switch between multiple YAML files for the same MCU?
Maybe one that uses distinct compilation folders for each YAML file but the same MCU hostname for the final upload?

I haven’t tested this, but I think this will work:

In common/base.yaml:

esphome:
  name: foobar

In config1.yaml:

esphome:
  build_path: ./build/config1

packages:
  base: !include common/base.yaml

In config2.yaml:

esphome:
  build_path: ./build/config2

packages:
  base: !include common/base.yaml

This should use the same node name but a different build path for each configuration.

1 Like

Aaaah, there is a build_path property!!! I was looking just for that but sadly did not find the Core Configuration page. I already wondered why all the MCU specific pages do not explain the available props.

Thanks, this is exactly what I was looking for.

Yes, it’s under “Advanced options” here:

1 Like

Yepp. With the term “build_path” I found that page immediately. That’s why I mentioned it in my reply. Have now already linked it there.

Thanks again.