An emergency was declared after an electrical substation was damaged by gunfire.