For example, I have a room I go into and close the door. When I am in there I am working. When I am out of there I'm not. It's like a mental switch. I also use some tricks to keep be from being distracted like a pomodoro timer.
Doesn't work for everyone. But, I learned from training my dog that situational training can be important. If we are training ourselves we might need to train ourselves to be productive at home.