Light switch - protection of switching it on when it is bright in the outside

You'll need to provide more information - like your yaml showing us how far you have got etc...

But yes - you can test a condition on operation of a switch.

Best done with a momentary button, an on_click trigger and a condition.

Read this, which discusses triggers, actions and conditions:

https://esphome.io/guides/automations

And while you are at it, read this - all of it: