Glad it didn't happen last night. Is your power supply on the nightstand as well?
Check all the connections.
Remove the water tank first. Wiggle, inspect, plug and unplug all the connections, including the wall plug, the detachable cord on the power brick, the plug on the back of the CPAP. Remove the humidifier from the blower and reconnect or run without the humidifier.
Plug a regular incandescent lamp into the same outlet. If the problems happen, turn on the lamp and look for flickering.
Feel the power brick and CPAP to see if anything is overly warm.
Get the free SleepyHead software here
for information on the main alternative to CPAP.
If it's midnight and a DME tells you it's dark outside, go and check it yourself.