async run()

in src/sensors/battery.ts [54:84]


  async run() {
    let intId: ReturnType<typeof setInterval>;
    if (this.simulated) {
      intId = setInterval(
        function (this: Battery) {
          this.emit(
            DATA_AVAILABLE_EVENT,
            this.id,
            Math.floor(Math.random() * 100),
          );
        }.bind(this),
        this.interval,
      );
    } else {
      intId = setInterval(
        async function (this: Battery) {
          this.emit(
            DATA_AVAILABLE_EVENT,
            this.id,
            Math.floor((await DeviceInfo.getBatteryLevel()) * 100),
          );
        }.bind(this),
        this.interval,
      );
    }
    this.currentRun = {
      unsubscribe: () => {
        clearInterval(intId);
      },
    };
  }