Hi and welcome, here is how you can automate your ceiling lights to turn on/off when you open the door.

With this setup I have automated the following task:

“Open door, turn on lights”

and

“Close door, turn off lights”

The automation works because I switched out the lighting switch with a Xiaomi Aqara Wall Switch that is connected to the Xiaomi gateway. I mainly do not use the switch so it works kinda like a relay.

Due note that the wall switch does NOT fit into the EU wall socket boxes. In order to make it fit I bought a ELKO DIMMER BOX / RISER and put it over the wall socket.

Works just fine, take a look below: