We report on a Ni L$_{2,3}$ edges x-ray absorption spectroscopy (XAS) study in $R$NiO$_3$ perovskites. These compounds exhibit a metal to insulator ($MI$) transition as temperature decreases. The L$_{3}$ edge presents a clear splitting in the insulating state, associated to a less hybridized ground state. Using charge transfer multiplet calculations, we establish the importance of the crystal field and 3d spin-orbit coupling to create a mixed-spin ground state. We explain the $MI$ transition in $R$NiO$_3$ perovskites in terms of modifications in the Ni$^{3+}$ crystal field splitting that induces a spin transition from an essentially low-spin (LS) to a mixed-spin state.