summaryrefslogtreecommitdiff
path: root/heating.py
diff options
context:
space:
mode:
authorroot <root@turin.home>2022-01-16 13:41:03 +0000
committerroot <root@turin.home>2022-01-16 13:41:03 +0000
commit2ee793179e345f3355462c8d2753543bc397a2aa (patch)
treed1c68adff555f3dc3fbf8a5702855114119bff10 /heating.py
parentbefb917ec5cbcbb0aaae33c53e6c0b2c4b92afcf (diff)
Reformat code
Diffstat (limited to 'heating.py')
-rw-r--r--heating.py33
1 files changed, 9 insertions, 24 deletions
diff --git a/heating.py b/heating.py
index 94943cb..ab058d6 100644
--- a/heating.py
+++ b/heating.py
@@ -30,7 +30,7 @@ class heating(ABC):
else:
self.on = False
self.turn_off()
- '''
+ """
self.db.exec(
"insert into temperature values (?,?,?,?)",
(date, time, self.temperature, self.target),
@@ -39,7 +39,7 @@ class heating(ABC):
"insert into history values (?,?,?)",
(date, time, heatingon(int)),
)
- '''
+ """
"""
Abstract methods used so that configuration for different
@@ -68,7 +68,7 @@ class heating(ABC):
# inherited from heating class
# overriding abstract methods from heating class
class rpi_heating(heating):
- def __init__(self,db):
+ def __init__(self, db):
# https://tutorials-raspberrypi.com/raspberry-pi-control-relay-switch-via-gpio/
# https://www.ics.com/blog/gpio-programming-using-sysfs-interface
# https://medium.com/initial-state/how-to-build-a-raspberry-pi-temperature-monitor-8c2f70acaea9
@@ -82,36 +82,21 @@ class rpi_heating(heating):
# setup GPIO for the relay
- os.system(
- "echo {} >/sys/class/gpio/export".format(self.RELAY)
- )
- os.system(
- "echo out >/sys/class/gpio/gpio{}/direction".format(
- self.RELAY
- )
- )
+ os.system("echo {} >/sys/class/gpio/export".format(self.RELAY))
+ os.system("echo out >/sys/class/gpio/gpio{}/direction".format(self.RELAY))
# file that the temperature gets written t
- self.sensor = "/sys/bus/w1/devices/{}/w1_slave".format(
- self.SENSORID
- )
+ self.sensor = "/sys/bus/w1/devices/{}/w1_slave".format(self.SENSORID)
def turn_on(self):
# turn the heating on by triggering the relay
- os.system(
- "echo 1 >/sys/class/gpio/gpio{}/value".format(self.RELAY)
- )
+ os.system("echo 1 >/sys/class/gpio/gpio{}/value".format(self.RELAY))
def turn_off(self):
# turn the heating off by triggering the relay
- os.system(
- "echo 0 >/sys/class/gpio/gpio{}/value".format(self.RELAY)
- )
+ os.system("echo 0 >/sys/class/gpio/gpio{}/value".format(self.RELAY))
def get_temperature(self):
with open(self.sensor, "r") as file:
data = file.read()
# parse temperature from file
- return (
- float(data.split("\n")[1].split(" ")[9].split("=")[1])
- / 1000
- )
+ return float(data.split("\n")[1].split(" ")[9].split("=")[1]) / 1000