raspishake / rsudp

Continuous visual display, sudden motion monitoring, and historical replay of Raspberry Shake data
https://raspishake.github.io/rsudp/
GNU General Public License v3.0
52 stars 30 forks source link

Having trouble running a python script with the custom module. #59

Closed matiro99 closed 12 months ago

matiro99 commented 12 months ago

Im trying to run a script that opens and closes a relay when the ALARM message goes off. RSUDP recognizes the code and everything but when it tries to run it, the client throws the following error:

2023-08-01 14:59:07 [Custom] Got ALARM message... 2023-08-01 14:59:07 [Custom] Executing code from file: /home/matiasrodriguez/customrele.py 2023-08-01 14:59:07 [Custom] Code execution failed. Error: invalid syntax (, line 1)

The python script is the follownig:

import RPi.GPIO as GPIO
import time

RELAY_PIN = 22

GPIO.setmode(GPIO.BCM)
GPIO.setup(RELAY_PIN, GPIO.OUT)

GPIO.output(RELAY_PIN, GPIO.HIGH)

time.sleep(2)

GPIO.output(RELAY_PIN, GPIO.LOW)

GPIO.cleanup()

If someone recognizes my mistake or why does this error pops up id really apreciate some help as ive already tried everything that my limited knowledge in coding let me. I tried running the script by itself and it runs without problems, i also wrote a script using the exec() function to see if that could be the problem but again, it worked without any trouble.