Lin-Manuel Miranda Lin-Manuel Miranda

The last time Broadway star Lin-Manuel Miranda visited prime time he played a friendly psych ward patient on House. On Wednesday's Modern Family, he'll play a different kind of crazy — the kind that drives Jay up the wall.

"My character is this pathetic loser who Gloria can't say no to," Miranda tells "I'm in her house, I have no business being there, but it's fun being in the middle of Gloria and Jay because they're my favorite couple on the show."

Modern Family recap: "Mother"

Now before you jump to any conclusions about Gloria (Sofia Vergara), Miranda says he isn't playing some ex-lover of hers. He's playing a guy with a dog training business scheme — and Jay (Ed O'Neill) isn't buying it. "He's doing his pitch for Jay to invest in it, only it's a terrible idea," Miranda says.

The actor won't divulge more, but he did reveal that some dog whispering might have gone down on set. "I got to play with this dog all day. I had to learn to speak dog," Miranda says. "Luckily, he was a total pro. I'd work with him again."

Check out videos from Modern Family

Miranda, whose show, In the Heights, won the Tony award for best musical in 2008, says he began begging the producers of Modern Family for a role, "any role," last year. "I met with them last season when In the Heights was in Los Angeles, and I basically told them that I would run craft services to be part of the show," Miranda says. "I think it's one of the best on television."

Miranda's got fans of his own within the cast, too. Rico Rodriguez, who plays Gloria's son Manny, expressed his love for In the Heights during the production's opening-night party. "Rico came with his sister, and well, they kind of stole the show," Miranda says. "They performed all of '96,000' for us at the party, like full-on rapping. It really was one of the highlights of our time in LA. They knew all the words. It was so awesome."

Modern Family airs Wednesdays at 9/8c on ABC.