I also work from home, part of that time being software development. I will not contradict any of the above good advice on scheduling and other things because I have unusual habits that would not be good for most people (I code best immediately after waking, so I take lots of power naps and work at really odd hours. I also don't sleep very much sometimes). Do not do this unless you discover that it is magic for you. Otherwise, it will be your downfall.
It is important, as stated, to stay focused and not get sidetracked. If you are writing code, you need to stick with it when you have to, and finish things. When the brain says code, then hit it hard. One thing you will find from this is that you can be highly productive. You can code when you are at your hottest, and the code poetry is flowing. People working somebody else's hours may not be coding at their best time, or at their best. You have the privilege to code at your best time, but now you have the duty to write your best code.
You can use some solitary recreation time to solve problems such as sticky points in algorithms and whatnot. Running, walking, cycling, and other activities are extremely satisfying ways to get the time you need to solve problems. When things aren't working, work them out. Also, keeping multiple parallel coding projects in the mix helps keep things interesting and allows you to problem-solve one and plan another while coding still something else.
In addition to making your environment comfortable, consider working from multiple locations in your house when you need diversion. I have written good code on the patio, in the den, at the dinner table, on the coffee table sitting Japanese-style, and in my bedroom. But I always make sure that the task matches what I have at hand. If you need something, bring it - don't wing it. Don't leave the favored work area if you know you shouldn't.
Most important, use the proper equipment. People often force a too-small laptop to do the work of a desktop. There is no reason not to use your "perfect" mouse and keyboard with your laptop when you move it around. Adding a second monitor on a laptop works nicely, and with a raised laptop and keyboard, mouse, etc., you have mobile double monitors anywhere in the house.
Make sure you have backup, or at least a backup plan. An old Windows machine, a linux box, whatever will get you back up and running - fast. Be prepared for other people's "emergencies", too. Nobody ever tells you about that part. But while you are running around in your bedclothes from early morning through lunch solving the crisis problem, bear in mind that you are being valued by your coworkers. Try to keep smiling. You will come out ahead, and the afternoon break will be all the sweeter.
Make sure you have a good headphone or speaker setup that allows you to converse while typing fast with both hands. I always direct people to my cell so I can type while they are talking to me through my headphones. Don't let people drag you into slow email exchanges when IM is better, and don't use IM when a phonecall is better. Don't be afraid to ring them when you get frustrated with slow responses to questions by IM or email.
What Nukapai said about not letting people turn you from a home worker to a house servant is important. That even goes for visitors. You need to be careful about people taking up your time when you don't want them to. This applies on the phone as well. Learn how to quickly disengage by thanking people.
On the plus side, working at home gets the house in order fast. Receiving packages is a godsend. Things that were painful distractions become easy to deal with.
When you are onsite, make the most of it. Take people to lunch, visit their offices, and give them a friendly face to remember. People who I supported offsite did this for me, and I remember them because of it. I learned this one from them.
Finally, a personal note. Don't let it turn you into a slob like it did me.
I laughed at the Dilbert cartoon when Dilbert got work-at-home and degenerated into a bum. I should not have been so proud. You are one of the sharper dressers on the board. Make a point of fighting back against "bathrobe programming"! I wish I had done so, but it's too late....
On my good days, I look like I'm on vacation. At other times... don't even think about it!