SOLVED (I think):

As above the sensor in question was G356 (error code 01986), but as roof was working I assumed sensor couldn't be completely shot. Linked to VCDS and looked under section 26 (auto roof), cleared code, then plotted real time graph of output from G356. It went down lots, slightly up, then down (as it should) but didn't look smooth, and every cycle or so it spiked down to 0.

So I figured that as it's a variable resistor that doesn't get used much, and only moves a little, it could be dirty tracks giving bad connection.

So took it off (1 screw & 1 connector so 30 seconds), it felt a little rough, so squirted wd40 in the gap, and wiggled end to end about 200 times. Much smoother.

Reassembled, manually reset roof. And opened VCDS again.

Graph for G356 when roof opening and closing is perfectly smooth, with no spikes up or down.

Done 10 cycles so far, no error code.

Fingers crossed