From d6cc0edb8bfadaaa1e4e787e919ed0e094ac7808 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 3 Jun 2017 19:31:27 +0200 Subject: [PATCH] Beacuse states are checked before its toggled a new function was made, just to update the GPIO with the fan state last saved in db. --- scripts/fanController.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/fanController.py b/scripts/fanController.py index cb9e261..5be5bd2 100644 --- a/scripts/fanController.py +++ b/scripts/fanController.py @@ -28,21 +28,24 @@ def turnFanON(): if not getFanstate(): updateFanstate(1) GPIO.setup("CSID0", GPIO.OUT) #set CSID0 as an output - GPIO.output("CSID0", GPIO.HIGH) #set CSID0 (LED) HIGH (On) + GPIO.output("CSID0", GPIO.HIGH) #set CSID0 (Relay) HIGH (On) return '1' def turnFanOFF(): if getFanstate(): updateFanstate(0) GPIO.setup("CSID0", GPIO.OUT) #set CSID0 as an output - GPIO.output("CSID0", GPIO.LOW) #set CSID0 (LED) HIGH (On) + GPIO.output("CSID0", GPIO.LOW) #set CSID0 (Relay) LOW (Off) return '1' def reloadFanstate(): - if (getFanstate()): - turnFanON() - else: - turnFanOFF() + GPIO.setup("CSID0", GPIO.OUT) #set CSID0 as an output + + if getFanstate(): + GPIO.output("CSID0", GPIO.HIGH) #set CSID0 (Relay) HIGH (On) + else: + updateFanstate(1) + GPIO.output("CSID0", GPIO.LOW) #set CSID0 (Relay) LOW (Off) if __name__ == '__main__': arg = argv[-1]