Skip to content

Commit

Permalink
override logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric George committed Apr 10, 2016
1 parent cb74c46 commit 6639891
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions wsp_control/functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#! /usr/bin/python
import time
import RPi.GPIO as GPIO
from wsp_control.config import PIN

from wsp_control.config import PIN, logger


GPIO.setwarnings(False)

Expand All @@ -24,17 +26,23 @@ def toggle():
def on():
print 'Switching on'
GPIO.output(PIN.PUMP, GPIO.HIGH)
state = GPIO.input(PIN.PUMP)

if GPIO.input(PIN.PUMP):
logger.info('Override - Pump {0}'.format(('OFF', 'ON')[state]))

if state:
print 'Pump is on'
else:
print 'Pump is off'

def off():
print 'Switching off'
GPIO.output(PIN.PUMP, GPIO.LOW)
state = GPIO.input(PIN.PUMP)

if GPIO.input(PIN.PUMP):
logger.info('Override - Pump {0}'.format(('OFF', 'ON')[state]))

if state:
print 'Pump is on'
else:
print 'Pump is off'
2 changes: 1 addition & 1 deletion wsp_control/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def turn_off(self):
def check(self):
" Check the state of the output pin (to the relay) "
state = self.is_on()
logger.info('Pump {0}'.format(('OFF', 'ON')[state]))
logger.info('Turning Pump {0}'.format(('OFF', 'ON')[state]))
r = requests.post(PUMP_ENDPOINT, {'is_on': state}, auth=AUTH)


Expand Down

0 comments on commit 6639891

Please sign in to comment.