Do you have any recommendations on what type of sensors I should look at? All surfaces are relatively small, so I couldn’t really find a solution, even looking at reed switches available. Should I look into some sort of beams (instead of magnets) that would be blocked by the lower metal part when it’s locked?
Never seen a lock like that, so difficult to give best suggestion. Probably the easiest way is battery operated (magnetic) door/window sensor on top of the piston.
Thanks for your suggestion. I thought about this, but there are some issues: the piston’s head is about 3/4 inches, and I didn’t find anything even close to that (for example, Sonoff’s sensor is 1 1/4 long). Besides that, having something on top of the piston might make it hard to use the lock, since you are supposed to push down with your feet to lock the door.
I edited the original post with the Amazon’s listing and measurements.
Set up a microswitch below the step-on part that’s fixed to the door and which is pushed in when the piston comes out; it looks like there’s a few mm of space between the piston and the frame.
Set up one wire on either side of the bottom of the step-on part so that a circuit will be closed when the piston comes out.
Both approaches will need a battery-powered sensor (like this Aqara MCCGQ11LM control via MQTT | Zigbee2MQTT might just be small enough) where you replace the Reed switch with one of the mechanisms above.
Rather than trying to attach 1 or multiple sensors to get the door state, why not just replace that manual lock with an electric one? Then you can lock/unlock it from HA and see whether its locked/unlocked for its state. Electric locks to have a drawback obviously… during a power outage it will Unlock itself because atleast these type, they need a constant source of power to hold it in the Lock position and no power, no locking. They may make “latching/locking” styles that dont require that constant power source because, when it goes to Lock position, there’s a mechanism that holds it there without needing power and wont unlock untill you toggle power to it a second time.
That makes more sense to me personally, but its up to you. If you go with sensors you cold use a microswitch.
You could glue a round magnet on top of the cylinder and then use a reed switch above it so when its unlocked, the magnet is almost touching the reed sensor.
A better option may be to use something like an IR sensor with a laser to make a break beam sensor and install it towards the bottom so that when the cylinder closes/locks the beam is broken and you can know for sure the door is locked instead of the other options that only verify an unlocked state because the other 2 sensors will show locked before the cylinder moves all the way down and you could get false states if for some reason someone failed to push it down completely and instead it was in the middle which those sensors cant tell the difference between stuck in the middle and fully locked, because they only detect when its fully unlocked and assume the Locked state.
This is a 1 piece sensor setup.
This is a 2 piece transmitter and sensor setup.
Here is a cool “people counter” project that uses the IR break beam sensor in doorways to count people as they come and go. I highly recommend atleast checking it out and even his other projects. Hes a pretty well known contributor and has some cool projects if your the DIY type.
My Shelly door sensor for example is only 7mm thick, I think it would fit there without disturbing the use.
For the piston you can use a small normal disk magnet instead of the rectangular “stock one”.