aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerg <uinarf@autistici.org>2023-03-01 09:27:00 +0100
committererg <uinarf@autistici.org>2023-03-01 09:27:00 +0100
commit359e051ec88b4daa1fe5cdb7921e747c4584fc46 (patch)
treeefe2e06b5fa3bdd50cb249686e7a3ff33888d891
parentad96edf8be0e758277f77c521ebb0e8383cda647 (diff)
downloadPi_Relay-359e051ec88b4daa1fe5cdb7921e747c4584fc46.tar.gz
Pi_Relay-359e051ec88b4daa1fe5cdb7921e747c4584fc46.tar.bz2
Pi_Relay-359e051ec88b4daa1fe5cdb7921e747c4584fc46.zip
File rename
-rw-r--r--py_relay.py (renamed from main.py)10
1 files changed, 6 insertions, 4 deletions
diff --git a/main.py b/py_relay.py
index 7a87f35..d492ab0 100644
--- a/main.py
+++ b/py_relay.py
@@ -88,7 +88,7 @@ def heater_on(temp, on=False) -> bool:
timestamp = time.strftime(TIMEFORMAT)
# turning it off
if not on:
- if status == 1:
+ if status:
retval = 0
else:
try:
@@ -96,11 +96,12 @@ def heater_on(temp, on=False) -> bool:
message = f"Turning off, temp: {temp}, {timestamp}"
logger.info(message)
retval = 0
- except:
+ except Exception as exc:
+ logger.warning(exc)
retval = 1
# turning it on
else:
- if status == 0:
+ if not status:
retval = 0
else:
try:
@@ -108,7 +109,8 @@ def heater_on(temp, on=False) -> bool:
message = f"Turning on, temp: {temp}, {timestamp}"
logger.info(message)
retval = 0
- except:
+ except Exception as exc:
+ logger.warning(exc)
retval = 1
return retval