Button reliability and web request timeouts

This commit is contained in:
2024-05-21 21:15:55 +01:00
parent f5c6e9e0aa
commit c657df8090
2 changed files with 6 additions and 6 deletions

4
api.py
View File

@@ -11,7 +11,7 @@ def getReq(endpoint) -> dict:
}
print("GET " + endpoint)
try:
response = get(HASS_URL + endpoint, headers=headers)
response = get(HASS_URL + endpoint, headers=headers, timeout=2)
return response.json()
except:
return {}
@@ -24,7 +24,7 @@ def postReq(endpoint, d) -> bool:
}
print("POST " + endpoint)
try:
response = post(HASS_URL + endpoint, headers=headers, json=d)
response = post(HASS_URL + endpoint, headers=headers, json=d, timeout=2)
return response.status_code == 200
except:
return False