key_data = hashlib.sha256()
key_data.update( base_phrase + ' - ' + door_id )
Congratulations, your program is vulnerable to length-extension attack [0].What you want is something secret determining the output of something public... so instead of reinventing the wheel (the number 1 source of issues in crypto), use the standard, ie HMAC [1].
Now for the rest of the algorithm, IANAC, but truncating sounds like a bad idea.