Azelphur / pyPushBullet

Python library to interface with PushBullet
GNU General Public License v3.0
180 stars 48 forks source link

start script #52

Closed marcobaumann123 closed 5 years ago

marcobaumann123 commented 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(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