Tasker. Basically an interface for writing scripts for your phone. Even if you don't have a use case in the beginning you'll start finding things to do with it.
I used it to identify the cell towers near my home and turn wifi off when I was out of their range and back on when I was in range. It seemed to help save battery by not constantly looking for wifi networks and I didn't have to remember to turn it off and on manually.
At home I want wifi on, and away I want it off. This saves battery so it's not constantly looking for wifi networks.
I could achieve similar with location service turned on all the time, but that drains battery even more.
Since cellular data is always connected to some cell tower nearby, and Tasker is able to identify the cell tower names, I used the ones near my home as flags to indicate "I'm close to home, therefore turn on WiFi because I'll be home soon". And turn it off when I leave my neighborhood.
I used tasker to display an icon on my status bar to tell me whether auto rotate is enabled or not. I kept lying down on my side forgetting that I had auto rotate on and my display would rotate when I didn't want it to.
It's an incredibly specific and minor thing that was annoying me, but tasker let me fix it. It's a great tool, but can be complicated if you aren't familiar with scripting. Luckily it's got some presets and a "basic" mode.
There's a completely free app (no ads, either) that prevents auto-rotate from actually happening unless you want it to. It pops up an icon when your phone wants to rotate, and it you don't tap it within the timeout (adjustable up to 3 seconds) then the icon goes away and the rotation never happens. It's highly customizable, and I just can't live without it since I found it.
I created a trigger to disable auto-rotate when I'm using the apps I'm usually browsing while in bed (i.e. doom scrolling social media) but I like your idea.
I have a script which saves my fine location to a Google sheet when I disconnect from my car's Bluetooth. If, like me, you are the sort of klutz who can lose their car in a two-car garage.....
The main thing is a script to stop any media playing and turn off the screen after x minutes, so I can fall asleep watching YouTube or listening to something. There's probably already an app for that but this is pretty customizable.
Another stupid use is putting the phone on silent while using the camera app because Samsung won't let you turn off the camera shutter sound.
I've got some that pulls the picture from Bing and the picture from NASA and set them to my wall paper and lock screen back grounds.
I've got another one that silences my phone when I'm at work or church and not connected to my car blue tooth. I used something similar in college to silence my phone when a calendar event was happening. My phone never made a peep during a lecture! It resets volumes to normal levels after the silent period is done.