You could easily turn all lights except a subset on/off by leveraging labels. E.g. give all lights you won‘t like to turn off by a specific action (button press, automation….) a label „dont-turn-off“.
Then you can use a template like this:
{{
states.light
| map(attribute="entity_id")
| reject("in", label_entities("dont-turn-off"))
| list
}}
Use this template directly in the service call or wrap it in a helper sensor if you like.
This can also be extended to filter areas, floors, other domains etc. These are all accessable in templates.