A barechested man was Tasered after threatening to shoot and knife police officers, a court was told.
Javid Aktar had to be taken to hospital with burn marks on his chest after being shot with the stun gun and there he made race-hate remarks.
Aktar, 43, of Buchanan Street, Blackpool, pleaded guilty to racially aggravated threatening behaviour.
After hearing Aktar was being recalled to prison Blackpool magistrates sentenced him to an 18 months conditional discharge.
Nigel Beeson, prosecuting, said on July 13 about 8.30am two police officers heard Aktar being racially abused and a man was arrested.
Just before midnight two officers went to Aktar’s home to take a statement from him.
Aktar refused to open the door shouting: “Come near me and I’ll shoot you” and also “I’ll stab you.”
Reinforcements were called for and a sergeant saw Aktar brandishing a knife at the window.
When the door was opened Aktar stood there will one hand behind his back and officer shot him with a Taser stun gun.
At the hospital Aktar was racially abusive, the court heard.
Neal Brookes, for the Probation Service, said Aktar had been on prison licence and as a result of this offence was being recalled to jail for 28 days.
Gerry Coyle, defending, said his client had mental health problems and psychotic difficulties.
Aktar had been repeatedly targeted and racially abused by groups, Mr Coyle said.
He did not know police would call about midnight and he had already taken his medication and drunk some alcohol.
He was in a confused state and thought the police officers were another group which had come to abuse him.