Sterile neutrinos can affect the evolution of the universe, and thus using the cosmological observations can search for sterile neutrinos. In this work, we use the cosmic microwave background (CMB) anisotropy data from the Planck 2018 release, combined with the latest baryon acoustic oscillation (BAO), type Ia supernova (SN), and Hubble constant ($H_0$) data, to constrain the cosmological models with considering sterile neutrinos. In order to test the influences of the properties of dark energy on the constraint results of searching for sterile neutrinos, in addition to the $Lambda$ cold dark matter ($Lambda$CDM) model, we also consider the $w$CDM model and the holographic dark energy (HDE) model. We find that sterile neutrinos cannot be detected when the $H_0$ local measurement is not included in the data combination. When the $H_0$ measurement is included in the joint constraints, it is found that $Delta N_{rm eff}>0$ is detected at about 2.7$sigma$ level for the $Lambda$CDM model and at about 1--1.7$sigma$ level for the $w$CDM model. However, $m_{ u,{rm{sterile}}}^{rm{eff}}$ still cannot be well constrained and only upper limits can be given. In addition, we find that the HDE model is definitely ruled out by the current data. We also discuss the issue of the Hubble tension, and we conclude that involving sterile neutrinos in the cosmological models cannot truly resolve the Hubble tension.