The error I dont understand. Please help. @shoeb.ahmed @rahul.singh1
> import conf, json,time, requests, statistics, math
> from boltiot import Sms, Bolt
>
> def data_get(hdata, frame, factor):
>
> if len(hdata)<frame :
> return None
> if len(hdata)>frame :
> del hdata[0:len(hdata-frame)]
>
> Mean = statistics.mean(hdata)
>
> Variance= 0
>
> for data in hdata :
> Varianace= Variance + math.pow((data-Mean),2)
>
> zn = factor * math.sqrt(Variance/frame)
>
> hbound = hdata[frame-1]+zn
> lbound = hdata[frame-1]-zn
> return[hbound,lbound]
>
> mybolt = Bolt(conf.api, conf.id)
> sms = Sms(conf.ssid, conf.token, conf.ton, conf.fromn)
> hdata=[]
>
> while True:
> response = mybolt.analogRead('A0')
> data = json.loads(response)
> if data['success'] != 1:
> print("There was an error while retriving the data.")
> print("This is the error:" +data['value'])
> time.sleep(10)
> continue
> print ("This is the value "+data['value'])
> sensor=0
> try:
> sensor = int(data['value'])
> except e:
> print("Error. Try again", e)
> continue
>
> bound = data_get(hdata, conf.frame, conf.factor)
> if not bound :
> reqbound= conf.frame -len(hdata)
> print ("No. of points needed is" , reqbound ,"more points")
> hdata.append(int (data['value']))
> time.sleep(10)
> continue
>
> try :
> if (sensor> bound[0]):
> print("Light level increased. Sending sms")
> response = sms.send_sms("Someon turned on the lights")
> print("REsponse is ", response)
> elif sensor < bound[1]:
> print ("The light level decreased suddenly. Sending an SMS")
> response = sms.send_sms("Someone turned off the lights")
> print("This is the response ",response)
> hdata.append(sensor);
> except Exception as e:
> print ("Error",e)
> time.sleep(10)