summaryrefslogtreecommitdiff
path: root/heating.py
diff options
context:
space:
mode:
authorroot <root@turin.home>2022-01-30 14:01:55 +0000
committerroot <root@turin.home>2022-01-30 14:01:55 +0000
commitafdc48378489d1ce1183dfd720fd838074812a49 (patch)
tree2e4cb3663212694aa6fe64be35c9ecff575e30c7 /heating.py
parentb6698810b9ff40a2d91b71c61017667642db212a (diff)
Reformatting. Adding things to date.py
Diffstat (limited to 'heating.py')
-rw-r--r--heating.py33
1 files changed, 25 insertions, 8 deletions
diff --git a/heating.py b/heating.py
index 757f877..42401ad 100644
--- a/heating.py
+++ b/heating.py
@@ -69,9 +69,11 @@ class heating(ABC):
# overriding abstract methods from heating class
class rpi_heating(heating):
def __init__(self, db):
- # https://tutorials-raspberrypi.com/raspberry-pi-control-relay-switch-via-gpio/
+ # 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
+ # https://medium.com/initial-state/how-to-build-a-raspberry-
+ # pi-temperature-monitor-8c2f70acaea9
# run init from super class
super().__init__(db)
@@ -82,21 +84,36 @@ 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
+ )