Police found an £8,000 cannabis farm at a family home in Wrenthorpe.
Leeds Crown Court heard officers found 23 cannabis plants when they executed a search warrant at Michael Stoner’s home on Bradford Road in August last year.
He initially refused to let the officers in and they went to the rear of the property.
Officers returned later to the front door only to discover that a couple had just left the property with a child.
Police searched the area and found Stoner and his family nearby.
Stoner then gave the officers the house keys and they discovered the plants, heating and growing equipment.
Prosecutor Mehran Nassiri said the plants were capable of producing £8,600 worth of the drug.
An electrician was later able to confirm that the electricity to the property had been bypassed.
Stoner told officers he had started growing the cannabis as he was struggling to afford paying for it.
Stoner, 28, now of Beckbridge Court, Normanton, pleaded guilty to producing cannabis.
Shufquat Khan, mitigating, said Stoner now committed to working hard to provide for his family. His partner is expecting another child.
Stoner was sentenced to a six-month prison sentence, suspended for 12 months. He must also do 180 hours of unpaid community work.
Judge Neil Clark told Stoner : “You are a man who has turned his life around. You have despite your record, you found good employment. You are a family man and have tried to support them. I hope you can continue to support them.”