Hermione tell Harry when they are discussing how Rita Skeeter is getting her information:
All those substitutes for magic Muggles use – electricity, and computers and radar, and all those things – they all go haywire around Hogwarts, there’s too much magic in the air.'
Goblet of Fire - pages 475-476
I also take from this quote that this why we only see candles,torches, and other fire driven lighting systems in the wizarding world. Houses and shops where magic is present, but probably not in same level as Hogwarts (think of the protection spells), also do not use electricity.
However, Mr. Weasley's flying Ford Anglia
and Sirius Black's flying motorbike
are both shown to have working headlights.
Since these vehicles clearly have magical enchantments and electric devices do not work around magic, how do the headlights work?
I am not asking why the vehicles themselves work as a combustion engine is mechanical, not electrical. Also, I would assume that all the buttons and levers the activate the vehicles special functions (invisibility on the car, dragon fire boot on the motorbike) are mechanical.
If something in canon can answer this, great. However, if this is just another inconsistency with JKR's application of magic universe, please support with out-of-universe context.