Python Forum
running different script together
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
running different script together
#1
Hi there,

I'm almost a complete newbie regarding python, and I'm struggling with a problem. I've got a google AIY voice kit running and want the raspberry to run the next script next to the google assistant script. At this moment I use a wemos esp easy to control some leds, but it's a bit inefficient to have a raspberry and a wemos in the same housing ( a model lighthouse) to control some leds....I've tried to insert the code in the assistant script but the script (see below) runs in a loop. I know it must be possible to run this script along the assistant script (they don't have to interact with eachother), but I have no clou on how to achieve that. Can anyone point me in the right direction?

#!/usr/bin/env python3

# execute doorled in lighthouse at specific times
import time
import os
import RPi.GPIO as GPIO
GPIO.setwarnings(False)


doorled = 17 
GPIO.setup(doorled,GPIO.OUT)
GPIO.output(doorled,GPIO.HIGH)

#Define define on time Change the value to what relay you want to respond to they are split into hours minutes and seconds.
doorledONH = 20
doorledONM = 10
doorledONS = 0


#Define doorled off time
doorledOFFH = 20
doorledOFFM = 15
doorledOFFS = 15


# start of doorled cycle
while True: 
    dt = list(time.localtime())#Get local time and store it in dt
    minute = dt[4]
    second = dt[5]
    time.sleep(0.5)
    os.system('clear')
      

#doorled Starts    
#doorled On Logic
    if hour == doorledONH: 				#Relay 1 On Hour setting
       if minute == doorledONM:				#Relay 1 On Minute setting
            if second == doorledONS:			#Relay 1 On Second setting
                GPIO.output(doorled, GPIO.LOW)		#Turn On Relay 1 if all above conditions are true
                
#doorled Off Logic
    if hour == doorledOFFH:				#Relay 1 Off Hour setting
        if minute == doorledOFFM:			#Relay 1 Off Minute setting
            if second == doorledOFFS:			#Relay 1 Off Second setting
                GPIO.output(doorled, GPIO.HIGH)	#Turn Off Relay 1 if all above conditions are true

# end of doorled cycle
 
Reply
#2
Hi,

you can start as many process / Python scripts as you want (well, until you reach the limits of your hardware ;-) ). Simply open as many terminals as you need and start the scripts manually.
If you want them to start at the start of the system, write a systemd service unit for each script.

Regards, noisefloor
Reply
#3
Thank you! I allready hoped it was as simple as that :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  No Internet connection when running a Python script basil_555 8 442 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 335 Mar-10-2024, 07:24 PM
Last Post: Winfried
  Help Running Python Script in Mac OS emojistickers 0 306 Nov-20-2023, 01:58 PM
Last Post: emojistickers
  Trying to make a board with turtle, nothing happens when running script Quascia 3 607 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  Python script running under windows over nssm.exe JaroslavZ 0 671 May-12-2023, 09:22 AM
Last Post: JaroslavZ
  Running script with subprocess in another directory paul18fr 1 3,476 Jan-20-2023, 02:33 PM
Last Post: paul18fr
  Running script on multiple files Afrodizzyjack 1 2,466 May-14-2021, 10:49 PM
Last Post: Yoriz
  Error when running script on startup in Linux NoahTheNerd 0 1,925 Mar-07-2021, 04:54 PM
Last Post: NoahTheNerd
  Refresh data in python script while running in Terminal frankenchrist 4 7,100 Feb-03-2021, 09:54 AM
Last Post: Larz60+
  [SOLVED] Requiring help running an old Python script (non Python savvy user) Miletkir 13 5,307 Jan-16-2021, 10:20 PM
Last Post: Miletkir

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020