*My Friend will be labeled "Friend" to keep this anonymous* Here's the Scenario: It was about 2am when my friend called me to meet him at a restaurant to hang out, and he said he'd treat me. I gladly took him up on the offer seeing that it wasn't that far of a walk, and it would be nice to see him. We conversed for a little while at the restaurant, talking about the past few days and their worth. Just before we left the restaurant, it was about 3am at the time, my friend offered the opportunity to hang at his house. Once again I accepted, I came all the way out there, I mean, I might as well. About half way to his house I realized it was 3am, and asked if I could sleep there, for the night, and leave early just in case my mom needs me at home. No resistance was posed, so I assumed I was allowed to stay. My friend and I talked about the usual, sitting in his kitchen, when he reminded me that at he had work at 2pm so he wanted to sleep into about 10:30am. He also reminded me that he had an alarm system that ran through the entire house so he told me that leaving at 8am was not possible because he'd have to turn off the alarm himself, and he wasn't getting up early to do so. I resented it at first, but realized that he had responsibilities to work, and was nothing but generous that day, so I cut him some slack, and agreed to get up at 10:30am. We went upstairs to his bedroom to set up a bed for me to sleep in. All of a sudden he began getting irritable saying that he was "frustrated, and angry". I didn't pay too much mind to it though, thought he was just stressed from work or something. I asked if I could move some stuff around in his room so I could sleep on the floor, I preferred not to use the air mattress because I did not feel comfy on it. He kept reiterating the fact the floor wouldn't be suitable for me with remarks that it was "dirty" or it had "sharp objects lying around". I told him it would be okay as long as I had a blanket put on the floor under me. My friend's sister was in the room, and suggested we go find some blankets in the basement, my friend refused to assist me so his sister said she'll go with me; I complied. I followed her downstairs to get the blankets, and when we were down there I decided not to bother my friend and just sleep in the basement. My friend's sister helped me make the bed; she was very kind to me, and apologized for her brother's rigid behavior. I told her not to fret, it didn't matter to me, I was just glad they allowed me to stay. She allowed me the room to myself; I set the alarm for 10:30am and dozed off to sleep. I woke up the next morning at around 7:50 am, I saw the time and was about to go back to sleep, but instead I went to go look at my messages on my phone before I did. What I saw perturbed me. It was message after message, from my friend, of how I shouldn't have come over, that he was awake the whole night, and how he was going to get me up, at 8am on the dot. Obviously I was perplexed so I started packing up and putting the away the blankets that were made for me. At 8am on the dot he showed up down stairs, and told me to come up to the kitchen, so I did. In the kitchen, he proceeded to rant on how he didn't get any sleep because, apparently, one of the batteries to the alarm system was dead, and he couldn't turn the alarm off all the way so he had to show me out personally which means he had to stay up all night. He also said he was angry because I let myself in, and if I didn't come over his house none of this would have happened; he accused me of being lazy for not walking home that night (mind you it was 3am). He had blamed it on me and demanded that I go immediately. I respected his decision because it was his house, so I packed up my things, walked out the door, and left with a bitter taste in my mouth. I think what he did was wrong.
What your friend did was absolutely appropriate. You have to put yourself in his shoes.
You being there caused him a great deal of stress, evident by him staying up all night. It didn't seem like he planned to have a guest over. For all we know, he might have been nervous about you being there.
To further this, he checked the alarm system. He wouldn't have known the battery was dead if he hadn't of checked to make sure everything would go fine the next day. He also was concerned about you sleeping on the floor.
So it really seems like he was up all night stressing about the situation. This probably made him react a bit grumpy in the morning. It looks like he just wanted you to go home so that he could relax and try to get some sleep before he had to go to work with no sleep.