Error in code, cant understand

i have built fire detection system, when i try to convert the temperature, it says invalid syntax, kindly help

import conf1
from boltiot import Sms, Bolt,Email
import json,time

def main_process():

maximum_limit = 28.0 
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID) 
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER) 
mailer = Email(conf.MAILGUN_API_KEY,conf.SANDBOX_URL,conf.SENDER_EMAIL,conf.RECIPIENT_EMAIL)

is_Fire = False 

status = json.loads(mybolt.isOnline())   
print("Status Check : ",status["value"])  

if status["value"] != "offline":   
    while True: 
        print ("Reading sensor value")
        response = mybolt.analogRead('A0')   
        data = json.loads(response)   

        try:
            flag = 1
            sensor_value = int(data['value'])  
            temp1 = (100*sensor_value)/1024  
            print("Sensor value is: " + str(temp1))  

            while temp1 > maximum_limit:  
                if flag == 1: 
                    response = sms.send_sms("ALERT ALERT ALERT !! Fire in workplace")   
                    print("Response received from Twilio is: " + str(response)) 
                    print("Status of SMS at Twilio is :" + str(response.status))

                    response_mail = mailer.send_email("ALERT ALERT ALERT !! Fire in workplace")    
                    response_text = json.loads(response_mail.text)
                    print("Response received from Mailgun is: " + str(response_text['message']))
                
                
                mybolt.digitalWrite('1', 'HIGH')
                mybolt.digitalWrite('2', 'HIGH')
                response = mybolt.analogRead('A0') 
                data = json.loads(response)
                sensor_value = int(data['value'])
                temp1 = (100*sensor_value)/1024 
                print("Sensor value is: " + str(temp1))
                flag = 0
                is_Fire = True

            
            mybolt.digitalWrite('2', 'LOW') 
            mybolt.digitalWrite('1', 'LOW')

            if is_Fire:
                  print("Response received from Twilio is: " + str(response))
                  print("Status of SMS at Twilio is :" + str(response.status))
        except Exception as e:
            print ("Error occured: Below are the details")
            print (e)


 else:
    print("Device is Offline")

if name == ‘main’:
main_process()

Try declaring the temp1 variable as a global variable before if statement and assign it 0. Then you can use it again where require. I feel the problem is related to declaration of the variable.

Correction -

  1. sensor_value = int(data[‘value’]) - closing bracket ‘)’ missing
  2. import conf - you imported conf1 but have conf.API_KEY in all the parameters.
  3. Repeated response, data, sensor value inside while condition. (It will loop many times, most likely you’ll run out of API in a minute)

I see you have done the correction. Update the error you’re getting now.

still getting the same error

Can you share the output screen and the code you have edited?