Read the statement by Michael Teeuw here.
MMM-PIR-Sensor with RelayPin and execute script
-
Hi,
My goal is: PIR Sensor detect presence and switch the relay pin. Additionally it should execute ah script hue_on.sh to switch MirrorLight on.
Scripts works fine form CLI
In which position of the node_helper.js from MMM-PIR-Sensor Module i put the lines
exec(“/home/pi/scripts/hue_on.sh”, null);
exec(“/home/pi/scripts/hue_off.sh”, null);pls help
thx -
I have build in this python script in tho rc.local
import RPi.GPIO as GPIO import time #Board Mode: Angabe der Pin-Nummer GPIO.setmode(GPIO.BOARD) #GPIO Pin definieren fuer den Dateneingang vom Sensor PIR_GPIO = 13 Relay_GPIO = 37 GPIO.setup(PIR_GPIO, GPIO.IN) GPIO.setup(Relay_GPIO, GPIO.OUT) GPIO.output(Relay_GPIO, True) GPIO.setup(32,GPIO.IN) read=0 wait=0 ein=0 button=1 while True : #PIR auslesen read = GPIO.input(PIR_GPIO) button = GPIO.input(32) if ((read==1 or button==0) and wait==0): GPIO.output(Relay_GPIO, False) wait=1 ein=1 time.sleep(0.5) elif ein==1 and button==0: ein=0 time.sleep(0.5)
-
Hi Blackmirror,
thx for helping, i am no coders.
pls can you explain me, howto it works to start with your script my hue_on.sh and hue.off.sh scripts?best regards
Egon -
Sorry i understand. MMM-PIR-Sensor config with no RelayPin config. Make RelayPin with your script.
-
-
when execute the python script (python /home/pi/scripts/light.py), i got following error:
File “/home/pi/scripts/light.py”, line 22
read = GPIO.input(PIR_GPIO) -
Hi,
i got an error when i run python script. now the whole error message:
File “/home/pi/scripts/light.py”, line 22
read = GPIO.input(PIR_GPIO)
^
IndentationError: expected an indented blockthx
-
@nogE
Python is a bit tricky. Unlike other languages python needs proper indentation. Make sure you don’t mix up tabs and whitespaces. Best practice is to use 4 whitespaces instead of one tab. -
Yes, the error code says, you have not enought whitespaces before the lines.