From 3d824a1c4ceb9e742f691dcf3f4ea099702a3b9c Mon Sep 17 00:00:00 2001 From: +++ Date: Thu, 22 Oct 2020 23:59:04 +0200 Subject: [PATCH] anbindung an setstatus --- watchdoor.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/watchdoor.py b/watchdoor.py index bfaa17a..7eb8aa7 100755 --- a/watchdoor.py +++ b/watchdoor.py @@ -6,13 +6,18 @@ # mail: berhsi@web.de # desc: deamon who deals with edge detection at pin 18 -import time import logging -import RPi.GPIO as GPIO - loglevel = logging.INFO formatstring = '%(asctime)s: %(levelname)s: %(message)s' 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.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: # door closed -> pin hight logging.info('Pin high triggered - Space closed') + s = SetStatus() + s.run(0) else: # door open -> pin low logging.info('Pin low triggered - Space is open') + s = SetStatus() + s.run(1) def main(): '''