added callback function support for on/off state change, so that user can register callback for doing some custom work when on/off state is toggled