A better approach: keep only plants that are safe for the cat to eat. Cats need to eat grass or other plants, they do that to stimulate regurgitation of their own hair they unwillingly eat when they clean themselves, and that if not expelled could clog their digestive system.
Image recognition could be used to open a cat flap door when the right cat arrives, and a timer could keep it closed for a while after the cat went out to eat some grass. It usually takes a few minutes to the cat from eating grass to regurgitating it, so it's just a matter of keeping it out for a while.