Yesterday i've realized it... but there is the same problem of reed... if you use ESP-01 and connect it to gpio2 when it start with sensor in off mode ESP doesn't start correctly because gpio2 result connected to gnd ....
EDIT: Working with ESP-12 with sensor connected to GPIO12