Fix Backend State Sensor returning null

This commit is contained in:
Linus Dietz
2023-11-21 18:50:55 +01:00
parent 126cc37269
commit 2e95e71661
4 changed files with 16 additions and 4 deletions
+9 -2
View File
@@ -328,9 +328,16 @@ def get_backend_status():
response = session.get(API_BACKEND_STATUS, timeout=15)
try:
data = response.json()
backend_status = data["message"] if util.keys_exists(data, "message") else "No warnings"
if util.keys_exists(data, "message"):
if data["message"]:
backend_status = data["message"]
else:
backend_status = "NO_WARNING"
else:
backend_status = "NO_WARNING"
except JSONDecodeError as e:
backend_status = "No warnings"
backend_status = "NO_WARNING"
return backend_status