Jsotola is right. The cars use the distance to know when they have to close doors.
In your case, you can use an extra sensor in the inside part. Maybe, an RFID or NFC tag, an ultrasonic sensor, or a laser or infrared sensors. With this element, you can detect if people are in the inside part.
I think most locks will offer option number 1.
For 2: The Schlage locks state this Built-in alarm technology senses potential security breaches at the lock, while the low battery indicator offers advanced warning for battery replacement
Also I found August has the following alerts:
The Door is locked or unlocked manually
This alert notifies you when someone ...
Many of these types of product are intended for use on exterior doors so should be weather proof (when installed correctly).
I would point out that they are probably intended to be installed vertically (e.g. in a front door) rather than horizontally (e.g. in the top of a box) where water might pool on the surrounding surface or the face of the product