You got lots of coding options for getting the job done with HA. If you want to do stuff outside of HA you can write scripts in any language you want and then generate events you send to HA via MQTT. You then have automation that take actions based on these events. HA has an addon called Appdaemon where can write scripts in python to interact with HA. You can also look at ESPhome and have lower power micro controllers that can run code and interact with HA. HA supports a shell command integration where you can use bash to get things done. As you’ve already noted you can use templates and automation. The web interface allows you to change from visual to yaml editing if you prefer to just write your yaml scripts in a general editor. I run the supervised version of HA on debian so I can have some supporting scripts outside in the language of my choice.
Here’s an example of using ruby gems that connect to HA via MQTT.
Here’s a bash script that monitors GPIO pins and talks with HA via MQTT.
Here’s an example using ESP32 to provide local control of a lamp, but also allowing the lamp to be send touch events to HA to control the overhead light in the same room.
Here I use a command script in HA to send a message out via whatsapp.
Here’s an example of using Appdeamon to control the lights when you’re away from home.
This just shows the HA debian setup I use.