I would also consider using an app designed for exactly this use case.
Jeff’s app was forked from this one:
And there’s also the app discussed in this thread:
I believe both can be installed through Hubitat Package Manager.