Sprinkler control and YAML preprocessor

I’m pretty new to Home Assistant and have been working on setting up my pool, security system and sprinklers. I’m doing as much as I can with YAML files so I can have version control and the most flexibility. When working with yaml files I was unhappy with all the duplication and repetitive code that seemed to occur. I looked at yaml anchors but they didn’t do everything I wanted. So I wrote a preprocessor, similar to the C preprocessor, that did what I wanted. I used that to implement my sprinkler control. Have a look at my GitHub repo. Comments and suggestions are welcome.

1 Like

Very cool. Your solution is very validating since I also use the C preprocessor on esphome yaml for similar reasons. Project GrowOS also breaks out the preprocessor tools as a separate github project called cpphash. Cpphash enables the Gnu C preprocessor to be used directly with yaml. It also allows esphome sections to be repeated and merges them before feeding the combined file to esphome - a solution to code integration challenges that occur in larger projects. Kudos!