This paper focuses on the power harmonic detection problem in smart grids with relay transmissions and stochastic communication delays. A model is established using an orthogonal vector to capture the dynamics of harmonic signals with direct current attenuation components. For the assurance of reliable information delivery, a strategy employing an amplify-and-forward relay with stochastic transmission power is used to schedule data from sensors to the remote filter. Furthermore, a set of random variables that obey Bernoulli distributions is used to characterize the stochastic nature of the communication delays. With the goal of achieving accurate power harmonic detection, a recursive filtering algorithm is aimed to be designed in the presence of the amplify-and-forward relay strategy and stochastic communication delays, which ensures that the desired filter gain parameter is derived recursively by minimizing the upper bound on the filtering error covariance. Ultimately, the effectiveness of the proposed filtering algorithm is demonstrated through simulation experiments on power harmonic detection, thereby verifying its capability in tracking harmonic dynamics.