Rapid advancements in electric vehicle (EV) technology have highlighted the importance of lithium-ion (Li) batteries. These batteries are essential for safety and reliability. Battery data show non-stationarity and complex dynamics, presenting challenges for current monitoring and prediction methods. These methods often fail to manage the variability seen in real-world environments. To address these challenges, we propose a Transformer model with a wavelet transform dynamic attention mechanism (WADT). The dynamic attention mechanism uses wavelet transform. It focuses adaptively on the most informative parts of the battery data to enhance the anomaly detection accuracy. We also developed a deep learning model with an improved Transformer architecture. This architecture is tailored for the complex dynamics of battery data time series. The model accounts for temporal dependencies and adapts to non-stationary behavior. Experiments on public battery datasets show our approach’s effectiveness. Our model significantly outperforms existing technologies with an accuracy of 0.89 and an AUC score of 0.88. These results validate our method’s innovation and effectiveness.