Man undertakes before domestic violence court to stay away from family home for three years