Leeds Crown Court heard Paul Bareham was arrested after the officers forced their way into the property in Harehills on December 3, 2019.
Alex Menary, prosecuting, said the officers had initially visited the address on Berkeley View, Harehills, as they wanted to speak to Bareham's dad.
The defendant was alone in the property when officers arrived but he refused to answer the door.
Mr Menary said the officers forced the door open and found a cannabis farm in the upstairs rooms.
A total of 30 plants were found and rooms were equipped with heating, lighting, electrical transformers and other growing equipment.
The prosecutor said the plants were capable of producing cannabis with a street value of £16,500.
Bareham was arrested and was found in possession of a small bag of cannabis when he was searched.
The defendant's fingerprint was found on the growing equipment.
Bareham, 45, pleaded guilty to producing cannabis and possessing cannabis.
A probation officer told the court that Bareham had stated in interview that he had been living at the address with his father and was aware that cannabis was being grown at the property.
Bareham also told the officer that he was a user of the class B drug.
The court heard he was the victim of an attack in 2017 and suffered head injuries.
He continues to suffer from anxiety as a result of the incident.
Michael Walsh, mitigating, said Bareham pleaded guilty to the offences at an early stage.
Judge Mushtaq Khokhar gave Bareham an an eight-month prison sentence, suspended for 18 months.
He was also made the subject of an electronically tagged curfew for two months and was ordered to complete 15 days rehabilitation activity requirement days.