Went to go out about a month back and the battery was dead .
A favoured theory of mine that by not changing a dodgy battery you put an undue stress on the electronics and the sensors are known to suffer badly from voltage surges! Hence a common factor in HES failures probably 18 out of 20 that I have changed is a dodgy battery! (2 were dodgy starters that drew all the current to spin the bike over again placing a heavy load on the electronics)
Simple things first !
First thing If it starts okay and revs okay when cold ?????? (cue The Cable thingy pic someone)
Second thing I would do is inspect the fuel tank filler drain hole! Its about 9 o'clock when you sit on the bike (with the cap lifted of course!


If its blocked ??? and when you lift the cap when you have been out when its raining or after washing, have you had water disappear down the main tank filler? If yes then you probably have water in the tank Drain Tank Change filter and Clean out the drain hole Be very very careful here because if you blow up from below with an airline you can blow the hose inside the tank off and If you poke the shite downwards you can compact it A bit of mig wire wound around something like a 2mm drill to make a mini auger is pretty good then you screw it through the dirt
Third thing is the little Ign loom as suggested by others It runs from the base of the Ignition switch round the left side of the head stock to connect under the tank You may find the green wire merely hanging literally on by a thread
If that all checks out okay I think
Number 1 Replace the battery and test ride BUT not too far from home
If okay then good stretch the range a little bit but still with a recovery option from a mate
IF you noticed the Revcounter flicking all over the place whilst its misbehaving then 90% sure its the HES
Buy New ones and Keep a GOOD fresh battery in the bike You shouldn't need to have it on an Optimate ALL the time