validierung Fix

This commit is contained in:
Martin Ness 2014-02-15 15:09:12 +01:00
parent 18aba03379
commit 34c5fb6450

View file

@ -17,9 +17,8 @@ except:
else:
# Status lessen
data = response.read(1)
try:
data = int(data)
except:
# Data validieren
if len(data) != 1 or data not in ("0", "1"):
logging.exception("ungueltigen Zustand gelesen")
data = None
@ -37,9 +36,10 @@ state = raw["state"]
# letzte Verarbeitungszeit setzen
state["lastchange"] = int(time.time())
# Status setzen
if data and data == 0:
if data:
if data == "0":
state["open"] = False
elif data and data == 1:
else:
state["open"] = True
else:
state["open"] = None