I’m not the first to think about it, since I see a bunch of patent filings related to it, but how hard would it be to have a sensor for windshield fog. Seems to me you could bounce light (UV perhaps which water scatters, though other colours might work) off the windshield to detect if there’s fog on the inside and use that to control the defogger.
In particular, modern defoggers use the air conditioner which provides dehumidified air when you heat it up again, great for defogging. But also fuel inefficient. I swear that while today’s AC based defoggers are better than the old pure heat ones, I think the AC-off mode of modern defoggers is not as good as the AC-less mode of the old ones.
Anyway, the sensor could at least control if the AC is used, if nothing else.