aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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