Looks like you’re getting the old and new template syntax confused in addition to trying to split the config. (the two sets of keywords that wiil help you search for help on this one BTW, new template and split config)
This thread will probably help
Also this will be far easier if you…
First get the template working correctly in configuration.yaml using the new template configuration for a binary_sensor (its the simplest and most native way - what you have is indeed a binary sensor - only two states active or not) let the UI handle the fact that it’s a door and should use door stuff by declaring the device class.
Then, once that’s working split the config
(TL ;Dr: the two syntaxes you are mixing are added under two completely different keys, one tenplate: and the other binary_sensor: so fix that first, then you can work on the split again)
And do you ‘need to?’ that’s entirely up to you but if it’s mine yes. First this seems reusable, second fixing it will teach you how to differ between old and new template sensor syntaxes and how to properly split config)