I’d suggest you read the documentation about Automations.
If that isn’t suitable, then look at these options…
Pete.