Let's assume you are supposed to be at work from 8am to 5pm with several breaks, and you get paid for that. And your boss, who is the only one with keys, isn't there at 8am, and not at 8:30am, and not at 9am. You decide to take the train back home. At 10am your boss arrives (with a huge hangover, I assume) and unlocks the door. You're not there.
If you had waited until 5pm, and the boss hadn't arrived at all, then your boss would have had to pay you for working all day, even though you didn't work.
If you had waited until 10am when the boss arrived, with German law you would then have to work until 5pm like normal, and the boss would have to pay for the full pay but couldn't force you to work a full day, only until 5pm.
If you left at 9am, and the office was available from 10am to 5pm, then it seems you were not available for work, and the company wouldn't have to pay except for the hour you were there. Your absence from 10am to 5pm is your own fault.
If it was raining outside, or you needed a toilet, you'd be perfectly entitled to find a nearby dry place with a toilet where you can wait, and check regularly if the office has opened, or leave a note how you can be contacted. I would expect you to contact your boss anyway. Actually, if you contacted his home and found that he left 7am and isn't at the office at 10am, and this has never happened before, someone might want to inform the police.
I think at the point where you leave, you can't expect to get paid anymore.