Hello everybody,
I’ve started with openHAB one week ago and have the following running:
Exec Binding that calls a python script which checks the status of a magnetic door sensor. The python script runs with an interval of 2 seconds and prints the status of the door sensor which is “garage door is open” and “garage door is closed” and this is shown as “Output” of the Exec Binding.
But what I’d like to have is the following:
The Exec Binding runs a python script, which checks the status of the magnetic door sensor in an endless loop. The python script just prints the status “garage door is open/closed” if it changes and that printing is recognized as Output in the Exec Binding. I’ve written a python script which does exactly what I want, but in openHAB the Output of the Exec Binding doesn’t change and is “NULL”.
Does anyone know whether it is possible what I want?
This is my pythonscript with the endless loop:
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM) # GPIO Nummern statt Board Nummern
Magnetschalter_GPIO = 27
GPIO.setup(Magnetschalter_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP) # GPIO Modus zuweisen
def Ausloesefunktion(GPIO_NR_Funktion):
if GPIO.input(GPIO_NR_Funktion):
print "Magnetschalter ist high, also offen"
else:
print "Magnetschalter ist low, also geschlossen"
GPIO.add_event_detect(Magnetschalter_GPIO, GPIO.BOTH, callback = Ausloesefunktion)
try:
while True:
sleep (1)
except:
print "Fehler aufgetreten"
finally:
GPIO.cleanup()
- Platform information:
- Hardware: Raspberry Pi 4
- OS: openhabian
- openHAB version: 3.0.1