oh, simple
it probably has a variable of blotts, then when you turn on a light it decreases it, on the relay loop it probably checks the varaible to make sure there's still power left, then when turned off it cancels the relay and adds power to it
otherwise it's annoying and uses horserays to incriment the variable, and on relay decreases it