For some time, I have been looking for a sensor to mount in my old-fashioned door locks (I do not use smart locks yet - still worried about the security), but I have not been able to find anything.
I have looked at what other people in the same situation have come up with and they all seem to use some sort of mechanical switch. I went for another solution that has no moving parts.
Using a relatively cheap reflective object sensor (containing a LED and a phototransistor) I made a small PCB that measures the distance to the lockbolt and sets the output depending on the distance (above or below a set level).
The sensor is mounted on the back of the locking plate where I made a rectangular hole for the sensor and two M3 threaded holes for mounting the sensor with nylon screws.
The output from the sensor is wired to an Aeotec Door/Window sensor 7 Pro for inclusion in my z-wave network. The Aeotec sensor get its 3V power supply from the lock sensor.
The output is an open collector with optional pull up resistor (to 3V).
The sensor will make a measurement every 3 seconds by turning on the LED, measure the distance and then turning off the LED again. Depending on the distance the sensor will set the output high or low.
When the Aeotec sensor detects a change in its input it will send a message on the z-wave network indicating the new status of the lock.
Works quite well. Only problem I have seen is that bright sunlight when the door is open might cause the sensor to detect the door as locked. No big issue as the door is open, so it cannot be locked at the same time.