I have a similar Apple HomeKit integration to my apartment door system in a much simpler way;
When you buzz the apartment from the intercom it connects to a dedicated landline phone, That landline is setup to automatically go straight to voicemail, and then the voicemail message is just a recording of the tone required to open the door.
Then I have a smart power socket that the landline phone gets its power from - which I can toggle in the home app.
So if you turn on the power socket and dial the apartment code at the entrance, it buzzes you straight in. Or turn the power socket off and it doesn't.
When you buzz the apartment from the intercom it connects to a dedicated landline phone, That landline is setup to automatically go straight to voicemail, and then the voicemail message is just a recording of the tone required to open the door.
Then I have a smart power socket that the landline phone gets its power from - which I can toggle in the home app.
So if you turn on the power socket and dial the apartment code at the entrance, it buzzes you straight in. Or turn the power socket off and it doesn't.