Beispiel #1
0
 def RBclick(self):
     from boltiot import Bolt
     api_key = "91a27806-4174-4001-9d24-b42a37a3a513"
     device_id = "BOLT5778783"
     mybolt = Bolt(api_key, device_id)
     response = mybolt.serialWrite("RB")
     print(response)
Beispiel #2
0
    Mn = statistics.mean(history_data)
    Variance = 0
    for data in history_data:
        Variance += math.pow((data - Mn), 2)
    Zn = factor * math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size - 1] + Zn
    Low_bound = history_data[frame_size - 1] - Zn
    return [High_bound, Low_bound]


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
history_data = []

while True:
    mybolt.serialWrite("GetAnalogData")
    response = mybolt.serialRead(10)
    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_value = 0
    try:
        sensor_value = int(data['value'].split(",")[0])
    except e:
        print("There was an error while parsing the response: ", e)
        continue
    tag = soup("span")
    Effected_people = tag[4].contents[0]
    for i in range(9):
        if i == 1 or i == 5:
            continue
        y = y + Effected_people[i]
    x = int(y)
    return (x)


#———————Execution starts from here————————————
Effected_people = getting_value()
apikey = input("Enter API Key")
Bolt_id = input("Enter the Bolt_ID")
device = Bolt(apikey, Bolt_id)
for i in range(1000):
    print(device.isOnline())
    response = device.serialBegin(9600)
    x = getting_value()
    z = checking1(x, 0)
    response2 = device.serialWrite(x)
    print(response2)
    time.sleep(100)  #time.sleep(100) with delay for execution for 100 sec
    y = getting_value()
    z = checking1(y, 1)
    response2 = device.serialWrite(y)
    if (z == 1):
        device.digitalWrite('0', 'HIGH')
        time.sleep(5)
        device.digitalWrite('0', 'LOW')