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 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/", null);
    exec("/home/pi/scripts/", null);

    pls help

  • 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 Pin definieren fuer den Dateneingang vom Sensor
    PIR_GPIO = 13
    Relay_GPIO = 37
    GPIO.setup(Relay_GPIO, GPIO.OUT)
    GPIO.output(Relay_GPIO, True)
    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)
       elif ein==1 and button==0:

  • Hi Blackmirror,
    thx for helping, i am no coders.
    pls can you explain me, howto it works to start with your script my and scripts?

    best regards

  • Sorry i understand. MMM-PIR-Sensor config with no RelayPin config. Make RelayPin with your script.

  • @nogE
    The MMM-PIR-Sensor module have not work at me.

    So i make a new datei this the name in my home - ordner.
    And add python in the rc.local
    After this was switch the PIR on the GPIO-Pin 13 the relay-pin 37. Add pin 32 i have a button to open the relay manual.

  • when execute the python script (python /home/pi/scripts/, i got following error:

    File “/home/pi/scripts/”, 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/”, line 22
    read = GPIO.input(PIR_GPIO)
    IndentationError: expected an indented block


  • Moderator

    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.

Log in to reply

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.