I had the same thing. Sometimes it woked, sometimes it didnt. When it stopped working the car would not brake at all with a solid pedal or would just lock up with the faintest touch. Scarey!
That turned out to be a sensor in the end. just had to buy one and swap them round until it was cured. That took a while because it was so intermitent.