I'm sorry but I don't quite understand the code, is that the code from the tutorial or the action I've provided in this thread? If you are using the action in this thread, there is no need to alter the code, just simply use the Calibrate Device action to retrieve the quaternion of the device upon calibration, and then use that quaternion value to feed it back as a starting base on the new Device Acceleration action from this thread..
@jeanfabre: sorry I completely missed your post, I'm not quite familiar with github yet as for the moment, if you can put it on ecosystem, I think it would be great and useful for others looking this kind of action in the ecosystem.