Could the steel bolt make contact with something like this at the bottom when it is locked if there is space to mount it at the bottom?
E.g the bottom of the bolt bridges two contacts.
You could also look into various microswitches/buttons.
“Surface Mount Spring Contacts” also brings up some interesting options.
I wouldn’t be looking at ESPHome solutions for this BTW. I would be looking for low power battery solutions (hacking zigbee reed switches etc)



