Trouble substituting in included files

Hi all. Pointers are appreciated!

In a run to simplify / modularize my ESPHome configs I want to move generic configs to files that are included from the host config.

How, for example can one move the api configuration down to a generic included file? The config below gives this error:

INFO ESPHome 2024.4.0
INFO Reading configuration /config/esphome/kitchen-switch.yaml...
ERROR Error while reading config: Invalid YAML syntax:

Secret 'key-${device_name}' not defined
  in "/config/esphome/common/.base.yaml", line 11, column 10

kitchen_switch.yaml

substitutions:
  device_name: "kitchen-switch"
<<: !include common/.base.yaml

common/.base.yaml

api:
  encryption:
    key: !secret key-${device_name}

secrets.yaml

 key-kitchen-switch: "vh/06Fs83ZW7RFMLEp6SmVkP6FDhH4rnR80zmsbLots="

If I set the api key to key-kitchen-switch directly from the node config, it works.