From afdc48378489d1ce1183dfd720fd838074812a49 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 30 Jan 2022 14:01:55 +0000 Subject: Reformatting. Adding things to date.py --- heating.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'heating.py') 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 + ) -- cgit v1.2.3