Thanks for testing, I've committed phil's patch.
MD_tune.bas results: 100 triggers -> min 40 max 1030 Av 228 (darkish room pointed at a phone 10cm distance)
For this test, you should point at a blank, non-moving subject like a blank wall, close enough to the camera so the AF led spot shows up clearly. The AF led is used to trigger MD, so any other source of movement will break the test.
The "max" and average are never reset, so if you get a value like 1000 from not detecting the LED, you need to reboot and start again.
You don't need a huge number of triggers, 10-20 should be fine.
A very dark environment might cause problems because the camera may reduce the live view frame rate. This usually only happens for night shooting, normal indoor lighting should be fine.
Also, which LEDs (if any) did the other two set_led options control?
nothing.
For the record - the cam was connected to chdkptp via a 7 port hub - I had an SD card reader in another port. These:
lua set_led(5,1)
lua set_led(5,0)
lua set_led(8,1)
lua set_led(8,0)
turned the led on/off within the SD card reader as though an SD card had been inserted/removed 
This must be coincidence, or just related to having USB traffic. There is no chance that sending Lua code to chdk on a camera would turn on/off the lights on your SD card reader.
FWIW, there is no need to try values other than 0,1,2, the code takes the LED number mod 3.
If 0 and 1 actually don't do anything, this is another bug. If you want, you can find the actual numbers using the LEDDrive eventproc. With native called enabled, use the following in chdkptp
=return call_event_proc('System.Create')
=return call_event_proc('Driver.Create')
These should both return zero. Then for every LED you want to try
=return call_event_proc('LEDDrive',0,0)
=return call_event_proc('LEDDrive',0,1)
The first number is the LED number. This is NOT the same as the numbers used by CHDK, but will probably range from 0 to 9 or something like that, possibly with multiple values triggering the same LED.
The second value turns the LED on or off.
0 turns the LED on,
1 turns it off.
The function will probably return nonzero if the LED number is not valid.
Looking at the SX150 the activity LED on the back and the AF LED are probably the only ones.