Question: from authy.api import AuthyApiClient import serial import time import sys import io import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.OUT) GPIO.setup(27, GPIO.OUT) arduino = serial.Serial('/dev/ttyACM0', 9600)

from authy.api import AuthyApiClient import serial import time import sys import io import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.OUT) GPIO.setup(27, GPIO.OUT)

arduino = serial.Serial('/dev/ttyACM0', 9600) #arduino_data = arduino.readline()

data =[] for i in range(50): b = arduino.readline() string_n = b.decode() string = string_n.rstrip() s = str(string) print(s) data.append(s) time.sleep(0.1) if s == " 21 F8 7C 26": authy_api = AuthyApiClient('jtJEfq9PPAdHOALNrt8FsVescO1C6RrZ')

response = authy_api.one_touch.send_request( 593152871, #adam "Requesting login for Encation", seconds_to_expire=120) if response.ok(): print(response.get_uuid()) else: print(response.errors())

time.sleep(8)

old_stdout = sys.stdout sys.stdout = buffer = io.StringIO()

if response.ok(): status = authy_api.one_touch.get_approval_status(response.get_uuid()) print(status.content) sys.stdout = old_stdout statuscontent = buffer.getvalue() print(statuscontent) index = statuscontent.find("approved") if index == 339: print('yes') GPIO.output(17, True) GPIO.output(27, True) time.sleep(5) GPIO.output(17, False) GPIO.output(27, False) else: print('no') if s == " D3 99 12 2E": authy_api = AuthyApiClient('jtJEfq9PPAdHOALNrt8FsVescO1C6RrZ')

response = authy_api.one_touch.send_request( 596467975, #rachel "Requesting login for Encation", seconds_to_expire=120) if response.ok(): print(response.get_uuid()) else: print(response.errors())

#time.sleep(8)

old_stdout = sys.stdout sys.stdout = buffer = io.StringIO() #sys.stdout = old_stdout #statuscontent = buffer.getvalue()

if response.ok(): status = authy_api.one_touch.get_approval_status(response.get_uuid()) print(status.content) sys.stdout = old_stdout statuscontent = buffer.getvalue() print(statuscontent) index = statuscontent.find("approved") #halp = statuscontent.find("pending") #print(halp) #print(index) #n = 10 #while halp == 339: # status = authy_api.one_touch.get_approval_status(response.get_uuid()) # print(status.content) # sys.stdout = old_stdout # statuscontent = buffer.getvalue() # halp = statuscontent.find("pending") # print(halp) # while n > 0: # status = authy_api.one_touch.get_approval_status(response.get_uuid()) # print(status.content) # sys.stdout = old_stdout # statuscontent = buffer.getvalue() # halp = statuscontent.find("pending") # print(halp) # time.sleep(1) # n -= 1 # break n = 10 while index != 339: #print(index) old_stdout = sys.stdout sys.stdout = buffer = io.StringIO() if response.ok(): status = authy_api.one_touch.get_approval_status(response.get_uuid()) print(status.content) sys.stdout = old_stdout statuscontent = buffer.getvalue() print(index) print(statuscontent) index = statuscontent.find("approved") time.sleep(1) #n -= 1 if index == 339: print('yes') GPIO.output(17, True) GPIO.output(27, True) time.sleep(5) GPIO.output(17, False) GPIO.output(27, False) else: print('no') Need help fixing this script , the script that as soon as you click 'approve' on the app, the door opens, but it keeps running and checking it, the loop won't stop. We've been trying to get it to either stop the loop when the user approves or stop after 10 seconds, whichever happens first so that it can then start over and wait for another input.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!