Handle multiple similar devices

Hello,
I have 5 custom thermostats with a few hundred lines of code that is mostly the same, but there are some variables in the code that are different.
The thermostats have a touch screen and there is still a lot of things that needs to be changed, so a lot of compiling and copy pasting.
I wanted to define variables at the top of the code, so i could just copy paste everything below that, but I am not sure if that is an option with esphome.
How would you guys handle this? The goal is to make copy pasting faster.

I think this is what you need:

Great thats what I was looking for!
Thank you!

A bit off topic but how are your custom thermostat working out? I’m hoping to make custom thermostats as well with wired ESP32s