You should be able to achieve it with a script. Have a look at examples here:
GitHub - shelly-tools/shelly-script-examples: Shelly mJS Scripting examples
Shelly mJS Scripting examples. Contribute to shelly-tools/shelly-script-examples development by creating an account on GitHub.
github.com