def PushNotification (push): try: if push_notification == "true": pb = PushBullet(push_token) phone = pb.get_device(push_device) push = phone.push_note("SolarPower", time.strftime("%H:%M") +" "+ push) return return except: print("PushNotification: failed")
def add_maintenance(vehicleID): """ Route for report vehicle page of the website Parameters: vehicleID(Integer): Vehicle ID from the database Returns: return redirect(url_for('dashboard')): Redirect to Admin dashboard return render_template('report_vehicle.html', form=form): Render the report vehicle HTML page """ obj = requestsUtil() form = MaintenanceForm(request.form) engineerResult = obj.get_engineers() result = obj.get_vehicle(vehicleID) dropdownValue = [] for i in engineerResult: dropdownValue.append(i['engineerUsername']) tupleDropDownValue = [(val, val) for val in dropdownValue] form.engineerName.choices = tupleDropDownValue if request.method == 'POST' and form.validate(): apiKey = "o.spfQSePwyGKGMeZG8DZxXZRJIMmSli0X" p = PushBullet(apiKey) vehicleID = result['vehicleID'] vehicleModel = result['vehicleModel'] longitude = result['longitude'] latitude = result['latitude'] engineerName = request.form['engineerName'] engineerDevice = "" engineerDeviceID = "" for i in engineerResult: if i['engineerUsername'] == engineerName: engineerDevice = i['engineerDevice'] engineerDeviceID = i['engineerDeviceID'] obj.add_maintenance(vehicleID, vehicleModel, longitude, latitude, engineerName, engineerDevice, engineerDeviceID) dev = p.get_device(engineerDevice) push = dev.push_note( "NOTICE: ", "A new vehicle has been assigned to you for maintenence!!") flash('Vehicle Reported', 'success') return redirect(url_for('dashboard')) return render_template('report_vehicle.html', form=form)
def push(title: str, body: str = None) -> None: """ Push a message to iPhone :param title: Title of the message to push :param body: Body of the message to push """ try: with open( '/Users/Alex/Documents/Python3/driveuploader/pushbullet_token.txt' ) as files: token = files.read().strip() pb = PushBullet(token) pb.push_note('{}'.format(title), '{}'.format(body), device=pb.get_device('iPhone')) except: pass
def Verify(self, addr, phone): """ Verify function. Takes in the mac address of the device and compare it with the database Parameters: addr(str): Mac address from the detected phone phone(str): Mac address information from the database Returns: None """ if addr == phone: print("Authorised, Vehicle Unlocked!!!") apiKey = "o.spfQSePwyGKGMeZG8DZxXZRJIMmSli0X" p = PushBullet(apiKey) dev = p.get_device('HUAWEI TAS-L29') push = dev.push_note("NOTICE: ", "Vehicle Unlocked!!") else: print("Unauthorised!!!")
def __init__(self, bot): self.bot = bot pb = PushBullet(api_key=open('pb_token', 'r').read().rstrip("\n")) self.phone = pb.get_device('Phone')
from pushbullet import PushBullet from picamera import PiCamera import datetime GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(10, GPIO.OUT) GPIO.setup(21, GPIO.IN) led_red = 2 led_green = 3 GPIO.setup(led_red, GPIO.OUT) GPIO.setup(led_green, GPIO.OUT) camera = PiCamera() apiKey = "your key" p = PushBullet(apiKey) devices = p.get_device('your devices') def getFileName(): return '/home/pi/program/picture/' + datetime.datetime.now().strftime( '%Y-%m-%d%H:%M:%S') + '.png' while True: input_state = GPIO.input(21) if input_state == True: GPIO.output(10, 1) GPIO.output(led_green, 0) GPIO.output(led_red, 1) print('Motion Detected') push = devices.push_note("Alert!!", "Intruder Alert!")
from twitter import * from pushbullet import PushBullet import config CONSUMER_KEY = config.twitter_consumer_key CONSUMER_SECRET = config.twitter_consumer_secret OAUTH_TOKEN = config.twitter_oauth_token OAUTH_SECRET = config.twitter_oauth_secret pb_api_key = config.pb_api_key twitter = Twitter(auth=OAuth( OAUTH_TOKEN, OAUTH_SECRET, CONSUMER_KEY, CONSUMER_SECRET)) tweets = twitter.statuses.user_timeline(screen_name="CGShanghaiAir", count=1) text = tweets[0]['text'] pm25 = text.split(";")[3] if pm25 > 90: pb = PushBullet(pb_api_key) nexus6p = pb.get_device('Huawei Nexus 6P') nexus6p.push_note('Shanghai Air Quality', text)