As a key technology of the Internet of Things, wireless sensor network (WSN) has been used widely in indoor localization systems. However, when the sensor is transmitting signals, it is affected by the non-line-of-sight (NLOS) transmission, and the accuracy of the positioning result is decreased. Therefore, solving the problem of NLOS positioning has become a major focus for indoor positioning. This paper focuses on solving the problem of NLOS transmission that reduces positioning accuracy in indoor positioning. We divided the anchor nodes into several groups and obtained the position information of the target node for each group through the maximum likelihood estimation (MLE). By identifying the NLOS method, a part of the position estimates polluted by NLOS transmission was discarded. For the position estimates that passed the hypothesis testing, a corresponding poly-probability matrix was established, and the probability of each position estimate from line-of-sight (LOS) and NLOS was calculated. The position of the target was obtained by combining the probability with the position estimate. In addition, we also considered the case where there was no continuous position estimation through hypothesis testing and through the NLOS tracking method to avoid positioning errors. Simulation and experimental results show that the algorithm proposed has higher positioning accuracy and higher robustness than other algorithms.