readd delay
This commit is contained in:
@@ -51,6 +51,14 @@ class GoveeApi:
|
|||||||
sock.settimeout(1)
|
sock.settimeout(1)
|
||||||
data = json.dumps(payload).encode()
|
data = json.dumps(payload).encode()
|
||||||
|
|
||||||
sock.sendto(data, (self.device_ip, 4003))
|
for attempt in range(retries):
|
||||||
|
sock.sendto(data, (self.device_ip, 4003))
|
||||||
|
try:
|
||||||
|
response, _ = sock.recvfrom(1024)
|
||||||
|
print(f"Got response on attempt {attempt + 1}")
|
||||||
|
break # stop retrying once we get an ack
|
||||||
|
except socket.timeout:
|
||||||
|
if attempt < retries - 1:
|
||||||
|
time.sleep(delay)
|
||||||
|
|
||||||
sock.close()
|
sock.close()
|
||||||
Reference in New Issue
Block a user