Browse Source

Fixed minor bug in sonoff scanner

TC pushbot 5 4 years ago
parent
commit
aa04458774
1 changed files with 4 additions and 0 deletions
  1. 4 0
      mod/iot/sonoff_s2x/sonoff_s2x.go

+ 4 - 0
mod/iot/sonoff_s2x/sonoff_s2x.go

@@ -44,6 +44,10 @@ func (h *Handler) Scan() ([]*iot.Device, error) {
 	scannedDevices := h.scanner.Scan(10, "")
 	for _, dev := range scannedDevices {
 		if dev.Port == 80 {
+			if len(dev.IPv4) == 0 {
+				//This device has no return IP???
+				continue
+			}
 			//This things has web UI. Check if it is sonoff by grabbing its index
 			value, err := tryGet("http://" + dev.IPv4[0].String() + "/")
 			if err != nil {