Closed marcobaumann123 closed 5 years ago
I want to start a python script with writing a pushbullet message on my phone. How can I do that? Here is my script:
import picamera, sys, time import RPi.GPIO as GPIO from pushbullet import PushBullet
cam = picamera.PiCamera() cam.resolution = (1920,1080) GPIO.setmode(GPIO.BOARD) GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
api_key = "o.5vNMA2J9kC2JztSe3VaH2vf0gG5szY8d" pb = PushBullet(api_key)
def motion(pin): print("Bewegung erkannt") t = time.strftime("%Y%m%d-%H:%M:%S") print("Erzeuge Foto") cam.capture('Ueberwachungskamera.png') print("Foto gespeichert") cam.capture('/home/pi/AlarmFotos/Ueberwachungskamera_%s.png' %t) print("FotoBackup") devices = pb.getDevices() pb.pushNote(devices[0]["iden"], 'Bewegung erkannt!', t) pb.pushFile(devices[0]["iden"], "Ueberwachungskamera.png", "Hier das Beweisfoto", open("Ueberwachungskamera.png", "rb")) print("Nachricht gesendet") return
GPIO.add_event_detect(7, GPIO.RISING) GPIO.add_event_callback(7, motion)
Thanks for answers marco
I want to start a python script with writing a pushbullet message on my phone. How can I do that? Here is my script:
import picamera, sys, time import RPi.GPIO as GPIO from pushbullet import PushBullet
cam = picamera.PiCamera() cam.resolution = (1920,1080) GPIO.setmode(GPIO.BOARD) GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
API(Pushbullet)
api_key = "o.5vNMA2J9kC2JztSe3VaH2vf0gG5szY8d" pb = PushBullet(api_key)
API(DropBox)
def motion(pin): print("Bewegung erkannt") t = time.strftime("%Y%m%d-%H:%M:%S") print("Erzeuge Foto") cam.capture('Ueberwachungskamera.png') print("Foto gespeichert") cam.capture('/home/pi/AlarmFotos/Ueberwachungskamera_%s.png' %t) print("FotoBackup") devices = pb.getDevices() pb.pushNote(devices[0]["iden"], 'Bewegung erkannt!', t) pb.pushFile(devices[0]["iden"], "Ueberwachungskamera.png", "Hier das Beweisfoto", open("Ueberwachungskamera.png", "rb")) print("Nachricht gesendet") return
GPIO.add_event_detect(7, GPIO.RISING) GPIO.add_event_callback(7, motion)
Thanks for answers marco