anbindung an setstatus

This commit is contained in:
+++ 2020-10-22 23:59:04 +02:00
parent a2a533ac65
commit 3d824a1c4c

View file

@ -6,13 +6,18 @@
# mail: berhsi@web.de # mail: berhsi@web.de
# desc: deamon who deals with edge detection at pin 18 # desc: deamon who deals with edge detection at pin 18
import time
import logging import logging
import RPi.GPIO as GPIO
loglevel = logging.INFO loglevel = logging.INFO
formatstring = '%(asctime)s: %(levelname)s: %(message)s' formatstring = '%(asctime)s: %(levelname)s: %(message)s'
logging.basicConfig(format=formatstring, level=loglevel) logging.basicConfig(format=formatstring, level=loglevel)
import time
import RPi.GPIO as GPIO
try:
from setstatus import SetStatus
except Exception as e:
logging.error('Cant import module setstatus')
logging.error('Error: {}'.format(e))
GPIO.setmode(GPIO.BOARD) # kind of enumeration GPIO.setmode(GPIO.BOARD) # kind of enumeration
GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) # pin 18 (GPIO 24) GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) # pin 18 (GPIO 24)
@ -25,9 +30,13 @@ def voltage_changed(channel):
if GPIO.input(channel) == GPIO.HIGH: if GPIO.input(channel) == GPIO.HIGH:
# door closed -> pin hight # door closed -> pin hight
logging.info('Pin high triggered - Space closed') logging.info('Pin high triggered - Space closed')
s = SetStatus()
s.run(0)
else: else:
# door open -> pin low # door open -> pin low
logging.info('Pin low triggered - Space is open') logging.info('Pin low triggered - Space is open')
s = SetStatus()
s.run(1)
def main(): def main():
''' '''