fixing crash for device_lost using undefined _self

fixes an unhandled exception that occurred when checking for expired devices and emitting the device_lost event caused by use of undefined variable _self.
Merge pull request #5 from robby/patch-1

fixing crash for device_lost using undefined _self