def take_pic(): iot.say("Taking a selfie!") with picamera.PiCamera(): with open("image.jpg", 'wb') as capture_file: camera.hflip = True # kaanna vaaka-akselin suhteen camera.vflip = True # peilikuva camera.resolution = (1296, 972) camera.capture(capture_file) with open(filename, 'rb') as capture_file: url = TG_URL + '/sendPhoto' files = {"photo": capture_file} res = requests.post(url, files=files, params={'chat_id': GROUP_ID})
def said_hello(): iot.say("Hello. ")
def said_How_are_you(): iot.say("I'm good. Thank you for asking ")
def said_right(): iot.publish("messages","right") iot.say("Asking the car to move right")
def said_left(): iot.publish("messages","left") iot.say("Asking the car to move left")
def said_back(): iot.publish("messages","back") iot.say("Asking the car to move backward")
def full_speed(): iot.say("OK, turning the fan on") iot.publish("tuuletin","full")
def new_message(message): iot.say(message)
def half_speed(): iot.say("OK, turning the fan off") iot.publish("tuuletin","half")
def cycle(): print("lähetettiin komento e") iot.say("Deploying wipe") ser.write(b"e") iot.publish("messages", "green")
def bounce(): print("lähetettiin komento c") iot.say("Deploying bounce") ser.write(b"c") iot.publish("messages", "green")
def rainbow_cycle(): print("lähetettiin komento b") iot.say("Deploying rainbow cycle") ser.write(b"b")
def red_led(): ser.write(b"a") print("lähetettiin komento a") iot.say("Deploying red LED")
def said_forward(): iot.publish("messages", "sparkle") iot.say("OK, sparkle")
def said_hello(): iot.say("Hi there, I am shining.")
def said_forward(): iot.publish("messages","forward") iot.say("Asking the car to move forward")
def testi(message): print(message) distance = float(message) if distance < 20.0: iot.say("Obstacle warning!") time.sleep(4)
def off(): iot.say("OK, turning the fan off") iot.publish("tuuletin","off")