Similar logic could be used for lights or locks, but the piston would have to be revised because, as currently written, it checks the status of the device’s contact instead of switch or lock, as you can see on lines 56, 58, and 91 of your snapshot. I’ve never really given this any thought as lights and locks are easy to turn off or lock remotely if they’ve been on or open too long, but I would probably create separate pistons to accomplish this to avoid complications.
Also, note that you have an error on lines 40 and 93, as the originating piston is not correctly specified. If the originating piston is not paused and resumed, the “B” piston may not always behave as expected.
With regard to lines 24-26, on the snapshot you provided those are fixed variables, so I don’t think those are the lines you intended to reference. My suspicion is that you meant to reference one of list variables below the line that says “Do Not Modify.” If so, then what you’re describing is normal. Clearing and/or stuffing list variables has been a hot topic around here for a while, but I don’t recall if the issue was ever fully addressed. In any case, while it’s annoying, it’s also harmless.