Diplomatic immunity exists to protect embassy staff - and their family - from either being arrested for inadvertent law-breaking or the host nation using obscure laws to arrest and imprison the Embassy. This immunity has nothing to do with the Embassy being 'home turf'.
What usually happens is that the host government puts its case of diplomatic staff breaking the law. In effect, they build a criminal case then present it to the officials boss. Should the case be found proved then the staff might be ordered to attend court (usually in the possibility of non-custodial sentence) or be recalled home. In theory.
What really happens is that the Foreign department considers a) how serious the crime is, b) the possible maximum sentence - any custodial sentence must be avoided, c) the level of importance of the suspect, and d) how more important the host nation is over the foreign nation.
Bottom line is any criminal claiming diplomatic immunity must be pretty confident in their 'value' to their bosses. They may get them off any criminal charges - by refusing them to attend open court - but what happens to them when they get home depends on how much embarrassment to the home government.
Think about it - if Diplomatic Immunity was available to anyone who could get to the embassy, how many idiots abroad would break the law (drunkenness, criminal damage, personal injury, even murder) then leg it to the consulate* just to get out of a court appearance and get sent home?
* The difference between Embassy and Consulate? Scale. An embassy is the government whereas consulate officials are government employees working abroad.
An embassy is located in a country’s capital city, whereas consulate is located in major cities.
An embassy represents a country’s political interests, whereas consulate represents a country’s commercial interests.
An embassy is headed by an ambassador, whereas consulate is headed by a consul general.
An embassy offers a wider range of services, such as issuing visas and passports, whereas consulate offers limited services, such as assisting with emergencies.