How to use macros in the configuration.yaml file for light template

I’m a beginner with Home Assistant and a Switch Bot user utilizing Switchbot-mqtt. Recently, I learned how to enable Cards using TemplateLight as described in this discussion: Enhanced the user experience by utilizing the "Template Light" integration for the color bulb. · hsakoh/switchbot-mqtt · Discussion #1 · GitHub

Following this method, with some modifications (changing ‘service’ to ‘action’), I managed to enable the Cards. However, when using TemplateLight for multiple bulbs, the configuration becomes very long.

I’d like to use macros to replace the ‘XXXXXXXXXXXX’ part in the example mentioned above, but I’m unsure of the correct way to do this. I would greatly appreciate any guidance on this matter.