Deferred entry of judgment is a form of probation. A search condition is probably part of your terms and conditions. So yes, the police had a right to search you.
You've got two issues that only an attorney with access to the police reports and all the evidence can answer, but...
Issue 1 - DEJ (PC 1000) may or may not have search terms imposed. It is a modified form of probation, but doesn't come with the full sentence imposed like a "regular" conviction. You'd have to verify whether search terms were included on your case or not.
Issue 2 - Whether or not there was any reason for them to search with the new situation. If the situation had resolved, it doesn't sound like there would be a reason for them to need to search, but these situations are always fact-specific, so that's why your lawyer will need to review the entire case.
The above answer is for general information only and is based on the information you posted. Every case is fact dependent, so to get a thorough analysis of your situation, you will need to consult face to face with an attorney licensed to practice in the jurisdiction where the incident took place. Do not conclusively rely on any information posted online when deciding what to do about your case.
As other attorneys have mentioned, you may or may not have a search clause as a condition of your DEOJ/pc1000. You probably should know and one way to find out is to go to the court where you pleaded and look in your court folder. Hopefully you can see if you have the conditions written on the minute form from your plea court date. If you can't figure the form out, you ought to get a copy made of it and ask an attorney to tell you if it says so.
As for the new charges, it is impossible to advise based on the information you gave. You will need to have an attorney review your new charges and advise you about the "facts" of the arrest. Generally, the police may go where ever the public may go and if they see or hear something that arises in them some suspicion or adds up to probable cause to arrest, they may act appropriately on that. It GENERALLY does not matter why they were there in the first place. Obviously there are exceptions, and that is why you need an attorney to review your facts. Good luck.