Arfan Karimi was arrested when West Yorkshire Police officers executed a search warrant at a house on Bayswater Terrace, Harehills, Leeds.
Ian Cook, prosecuting, told Leeds Crown Court that the three-storey house overlooked a takeaway next door.
Officers went to the property on June 3, 2019.
Lamborghini pictured with car on top of its bonnet at busy Leeds junction following crash
Rage Against The Machine pull out of headline slot at Leeds Festival
Leeds thunderstorms warning as Met Office shares latest weather forecast
Leeds Bradford Airport: Full statement on August security staff strike
York Road incident: Police appeal after pedestrian killed in crash outside Leeds Dogs Trust
Mr Cook said the house had a camera placed outside so people inside could see anyone approaching.
Karimi was arrested as he left a living room on the first floor.
The room was searched and £180 in cash was found under a cushion.
Five bags of cannabis were then found under a sofa.
Mr Cook said the curtains in the room were closed.
When officers opened them they saw two black bags on the roof of the takeaway below.
The bags contained smaller bags of cannabis with a street value of around £840.
Karimi, 27, of Conway Place, Harehills denied that the cannabis was his when he was questioned and claimed it belonged to a friend.
He later pleaded guilty to possessing cannabis with intent to supply and possession of criminal property.
Soheil Khan, mitigating, said Karimi has no previous convictions and pleaded guilty to the offences at an early stage.
Mr Khan said his client had not been in trouble in nearly three years since the incident.
Recorder Andrew Latimer gave Karimi a 46-week prison sentence, suspended for 18 months, plus 200 hours of unpaid work.