Security Script

I want to put a button that turns off or turn on “Security mode”. If security mode is on and if a sensor (door sensor) opens, I want that HA sends an alert to app or something that I want to configure.

How can I do that?

Use a helper input_boolean.

You might want to take a look at this: