if (Toybox has :SensorHistory && Toybox.SensorHistory has :getBodyBatteryHistory) { var lastvalue_0 = Toybox.SensorHistory.getBodyBatteryHistory({:period => new Time.Duration(900)}).next(); if (lastvalue_0 != null && lastvalue_0 has :data && lastvalue_0.data != null) { _percentage = lastvalue_0.data.toFloat(); } }