I am trying to use this code Can someone who is a better programmer make this multithread for me with up to 8 threads?
I cannot get more than 1 button to work when I press one it locks the pi/cayenne until that button/script/timer is done. I’d like to use this for pump controls and have multiple running at the same time but in different variations/seconds the pumps are on for each one. but not a single script because the times needed are different depending on soil moisture contents ( a whole other project ) so for now I just need this script turned into multithread and I’m tired of racking my brain trying and not getting it to work.
MQTT_USERNAME = “xxx”
MQTT_PASSWORD = “xxx”
MQTT_CLIENT_ID = “xxx”
print ("message received: " + str(message))
if (message.channel == 7) and (message.value == “0”):execfile(“12.py”)
if (message.channel == 8) and (message.value == “0”):execfile(“20.py”)
if (message.channel == 9) and (message.value == “0”):execfile(“21.py”)
client = cayenne.client.CayenneMQTTClient()
client.on_message = on_message
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)
timestamp = 0
if (time.time() > timestamp + 10):
timestamp = time.time()
i = i+1