Need help with integrating python script(s)

Can anyone help me with my StepperMotor, it uses ULN2003 motor drivers and is directly connected from the drivers to my pi. I’ve got a good working script to get the motor to make a 360 degree turn. Here it is:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
control_pins = [40,38,36,32]
for pin in control_pins:
  GPIO.setup(pin, GPIO.OUT)
  GPIO.output(pin, 0)
halfstep_seq = [
  [1,0,0,0],
  [1,1,0,0],
  [0,1,0,0],
  [0,1,1,0],
  [0,0,1,0],
  [0,0,1,1],
  [0,0,0,1],
  [1,0,0,1]
]

print "Rotatie Gestart"

for i in range(512):
  for halfstep in range(8):
    for pin in range(4):
      GPIO.output(control_pins[pin], halfstep_seq[halfstep [pin])
    time.sleep(0.001)
GPIO.cleanup()

Is there any way for me to just simply call this script in Hassio? I have no idea how to turn this script into a service/action.

Now that I’m still on topic, let me ask another question. What if I had 3 python scripts in the same folder, is it possible to use one of the scripts to call on the other 2? Meaning I import script1 and script2 into script3 and use this in some custom way.

Try to call your script with a shell_command BUT if you’re running Hassio, shell_commands and command_line components do not work well.
The forum is full of topics about it.

For your second question:
If the first script works, i see no problems to import the others.

1 Like

It seems like I’ll have to convert the whole python script to something that hassio will agree with. I have no idea how to this though.

Running the scripts just gave me errors saying:

Error running command: python3 /config/python_scripts/Stap1.py, return code: 1