Beispiel #1
0
 def startclick(self):
     from boltiot import Bolt
     api_key = "91a27806-4174-4001-9d24-b42a37a3a513"
     device_id = "BOLT5778783"
     mybolt = Bolt(api_key, device_id)
     response = mybolt.serialBegin("9600")
     print(response)
    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')
    try:
        response = requests.request("GET", url, params=data)
        bot.send_photo(chat_id="@alerts_boltIOT19",
                       photo=open("./images/" + str(img_count) + ".bmp", "rb"))
        print("This is the Telegram response")
        print(response.text)
        telegram_data = json.loads(response.text)
        return telegram_data["ok"]
    except Exception as e:
        print("An error occurred in sending the alert message via Telegram")
        print(e)
        return False


response = mb.serialBegin('9600')
while True:
    # response1 = mb.serialRead('10')
    dread = mb.digitalRead("1")
    # data = json.loads(response1)
    dread1 = json.loads(dread)
    print(dread)

    if dread1["value"] == '1':
        with open("image-count.txt", "r") as f:
            image_count = f.read()
        # creating a subprocess to take images from ov7670 camera module
        command = '''C:
cd/
cd "Program Files (x86)"\\Java\\jdk1.8.0_231\\bin
java code.SimpleRead ''' + image_count + '''