Adding a script, need help to get started


After using HomeSeer for 14 year I am moving away from it and into HA-OS. In the past I made a script (vbscript) to control my whole house audio and mics system via a XAP800. Because this system is running for more then 10 year flawless and without interruptions I want to incorporate it also into HA.
Controlling the XAP800 is just a matter of sending the right string via the serial connection. I know how to set up a serial connection with HA.
So far so good.
To control this device under HA-OS I can make many automations or such for every situation but that would be an administrative nightmare. It’s better to use a script that handles a few parameters so it will make the proper commands and send them to the device. For HomeSeer I could use vbscript but I presume that I have to use python for HA. However, HA is fairly new to me and it’s unclear for me where to start. I need some pointers to get started otherwise I will spend a lot of time re-inventing the wheel.

This brings me to my question(s)
How do I start a python script from HA?
Where should the script be located?
How do I pass parameter from HA to the script.?
But most of all are there any good examples how to get started with this?

Any help to get me into the right direction is appreciated.