validierung Fix
This commit is contained in:
parent
18aba03379
commit
34c5fb6450
1 changed files with 7 additions and 7 deletions
14
state.py
14
state.py
|
@ -17,9 +17,8 @@ except:
|
||||||
else:
|
else:
|
||||||
# Status lessen
|
# Status lessen
|
||||||
data = response.read(1)
|
data = response.read(1)
|
||||||
try:
|
# Data validieren
|
||||||
data = int(data)
|
if len(data) != 1 or data not in ("0", "1"):
|
||||||
except:
|
|
||||||
logging.exception("ungueltigen Zustand gelesen")
|
logging.exception("ungueltigen Zustand gelesen")
|
||||||
data = None
|
data = None
|
||||||
|
|
||||||
|
@ -37,10 +36,11 @@ state = raw["state"]
|
||||||
# letzte Verarbeitungszeit setzen
|
# letzte Verarbeitungszeit setzen
|
||||||
state["lastchange"] = int(time.time())
|
state["lastchange"] = int(time.time())
|
||||||
# Status setzen
|
# Status setzen
|
||||||
if data and data == 0:
|
if data:
|
||||||
state["open"] = False
|
if data == "0":
|
||||||
elif data and data == 1:
|
state["open"] = False
|
||||||
state["open"] = True
|
else:
|
||||||
|
state["open"] = True
|
||||||
else:
|
else:
|
||||||
state["open"] = None
|
state["open"] = None
|
||||||
|
|
||||||
|
|
Reference in a new issue