Example #1
0
def plugin(srv, item):
    ''' expects (apikey, device_id) in adddrs '''

    srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__, item.service, item.target)

    recipient_type = "device_iden"
    try:
        apikey, device_id = item.addrs
    except:
        try:
            apikey, device_id, recipient_type = item.addrs
        except:
            srv.logging.warn("pushbullet target is incorrectly configured")
            return False

    text = item.message
    title = item.get('title', srv.SCRIPTNAME)

    try:
        srv.logging.debug("Sending pushbullet notification to %s..." % (item.target))
        pb = PushBullet(apikey)
        pb.pushNote(device_id, title, text, recipient_type)
        srv.logging.debug("Successfully sent pushbullet notification")
    except Exception as e:
        srv.logging.warning("Cannot notify pushbullet: %s" % e)
        return False

    return True
Example #2
0
def plugin(srv, item):
    ''' expects (apikey, device_id) in adddrs '''

    srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__,
                      item.service, item.target)
    if not HAVE_PUSHBULLET:
        srv.logging.warn("pushbullet is not installed")
        return False

    try:
        apikey, device_id = item.addrs
    except:
        srv.logging.warn("pushbullet target is incorrectly configured")
        return False

    text = item.message
    title = item.get('title', srv.SCRIPTNAME)

    try:
        srv.logging.debug("Sending pushbullet notification to %s..." %
                          (item.target))
        pb = PushBullet(apikey)
        pb.pushNote(device_id, title, text)
        srv.logging.debug("Successfully sent pushbullet notification")
    except Exception, e:
        srv.logging.warning("Cannot notify pushbullet: %s" % (str(e)))
        return False
Example #3
0
def compare_collections():
    myclient = pymongo.MongoClient("mongodb://localhost:27017/")
    db = myclient["Takealot_DB"]
    collectionA = "graphics_cards_day_{}".format(initial_day)
    collectionB = "graphics_cards_day_{}".format(next_day)
    print(collectionA, collectionB)
    apiKey = "GET YOUR OWN API KEY"
    p = PushBullet(apiKey)
    # Get a list of devices
    devices = p.getDevices()

    x = get_var_value()
    print("THIS IS THE VARSTORE VALUE: {}".format(x))
    y = x - 1
    print("THIS IS THE VARSTORE VALUE MINUS 1: {}".format(y))
    if x < 2:
        print("Nothing to compare. Program must run at least twice.")
    else:
        for item in db.get_collection(collectionA).find():
            item_name = item['item_name']
            item2 = db.get_collection(collectionB).find_one(
                {'item_name': item_name})

            result = "\n Price change is {} for item {} with original price being {} in collection A,\n and item {} with original price being {} in collection B.\n The difference is {}".format(
                item['item_price'] > item2['item_price'], item['item_name'],
                item['item_price'], item2['item_name'], item2['item_price'],
                item['item_price'] - item2['item_price'])

            p.pushNote(devices[0]["iden"], 'Scraping completed', result)
    def connect(self):
        apiKey = "o.2uIo9r0MKCCFX8Mv3uMhp4xOXE9vgBrC"
        p = PushBullet(apiKey)
        # Get a list of devices
        devices = p.getDevices()

        msg, ct, ch = self.blueMsg()

        while True:
            botList = self.detect()
            print(botList)
            if devices[0].get("nickname") in botList:

                print("Found device with names: ", botList)
                p.pushNote(
                    devices[0]["iden"],
                    'Raspberry-Pi-Notification',
                    'Current Temperature is :' +
                    str(ct) +
                    'Degrees' +
                    '\nCurrentHumid :' +
                    str(ch) +
                    '%' +
                    '\n' +
                    msg)
                break
Example #5
0
def recog():
    visitor=0
    known_encoding = face_recognition.face_encodings(known_image)[0]
    print('known image encodings done')
    previous_state = False
    current_state = False
    while True:
            
        previous_state=current_state
        current_state=GPIO.input(sensor)
        if(current_state != previous_state):
            if(current_state): new_state="HIGH"
            else: new_state="LOW"
            print("GPIO pin %s is %s" % (sensor,new_state))
            if(current_state):
                print("A photo will be taken in 3 seconds")
                time.sleep(3)
                with picamera.PiCamera() as camera:
                    camera.resolution = (340, 220)
                    time.sleep(2)
                    camera.capture('unknown.jpg')
                unknown_image = face_recognition.load_image_file("/home/pi/Desktop/unknown.jpg")
                face_locations = face_recognition.face_locations(unknown_image)
                if(len(face_locations) == 0):
                    print("no face detected")
                    os.remove('unknown.jpg')
                    continue
                    
                unknown_encoding = face_recognition.face_encodings(unknown_image)[0]
                print("encodings calculated")
                results = face_recognition.compare_faces([known_encoding], unknown_encoding)
                print(results)
                if results == [True]:
                    GPIO.setup(14, GPIO.OUT)
                    print("person recognised,frank")
                    p = PushBullet("o.a441em4dWH3fzGm1mcURidwfuJ1gG4Jn") #secret key of pushbullet API
                    devices = p.getDevices()
                    p.pushNote(devices[0]["iden"], 'Frank is at the door', 'open the door')
                    os.remove("unknown.jpg")
                    print("message sent")
                    GPIO.cleanup()
                    break
                else:
                    while(os.path.exists("/home/pi/Desktop/known/"+str(visitor)+".jpg")):
                        visitor=visitor+1
                    os.rename("/home/pi/Desktop/unknown.jpg","/home/pi/Desktop/"+str(visitor)+".jpg")
                    shutil.move("/home/pi/Desktop/"+str(visitor)+".jpg","/home/pi/Desktop/known")
                    print("unknown person")
                    picname = str(visitor) + ".jpg"
                    visitor=visitor+1
                        #cv2.imwrite(picname,frame) 
                    p = PushBullet("o.a441em4dWH3fzGm1mcURidwfuJ1gG4Jn") #secret key of pushbullet API
                    devices = p.getDevices()
                    p.pushFile(devices[0]["iden"], picname, "unknown person", open("/home/pi/Desktop/known/"+picname, "rb"))

                    print("Sending email")
                    attach=picname #attachments to send with email
                    smail.send_mail(attach)
                    print("email sent")           
                    break
Example #6
0
def plugin(srv, item):
    ''' expects (apikey, device_id) in adddrs '''

    srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__, item.service, item.target)
    if not HAVE_PUSHBULLET:
        srv.logging.warn("pushbullet is not installed")
        return False

    try:
        apikey, device_id = item.addrs
    except:
        srv.logging.warn("pushbullet target is incorrectly configured")
        return False

    text = item.message
    title = item.get('title', srv.SCRIPTNAME)

    try:
        srv.logging.debug("Sending pushbullet notification to %s..." % (item.target))
        pb = PushBullet(apikey)
        pb.pushNote(device_id, title, text)
        srv.logging.debug("Successfully sent pushbullet notification")
    except Exception, e:
        srv.logging.warning("Cannot notify pushbullet: %s" % (str(e)))
        return False
Example #7
0
def addDevice(args):
    p = PushBullet(args.api_key)
    devices = p.addDevice(args.nickname)
    if args.json:
        print(json.dumps(devices))
        return
    print("Device %s was assigned ID %s" % (devices["nickname"],
                                            devices["iden"]))
Example #8
0
def pushBullet(title, message):
    try:
        from pushbullet.pushbullet import PushBullet
        apiKey = "o.mKznlsIJB18uq6qArGrl2AOPU2KbISsR"
        p = PushBullet(apiKey)
        devices = p.getDevices()
        p.pushNote(devices[0]["iden"], title, message)
    except Exception, e:
        logger.exception(e)
Example #9
0
    def sendNotif(self, header, body):
        if self.apiKey == "":
            fichier = open("api.txt", "r")
            self.apiKey = fichier.read()[:-1]  # attention retour a la ligne
            fichier.close()

        p = PushBullet(self.apiKey)
        devices = p.getDevices()
        for i in range(len(devices)):
            p.pushNote(devices[i]["iden"], header, body)
Example #10
0
def sendNotif():
    pb = PushBullet("o.sqTG7BlAEOoQDpccJ2n3nFwZ4BRy2637")

    devices = pb.getDevices()

    title = "Recolteur d'eau"
    text = "Le reservoir est vide!"

    for device in devices:
        if device['pushable']:
            note = pb.pushNote(device["iden"], title, text)
Example #11
0
def pushFile(args):
    p = PushBullet(args.api_key)
    file = p.pushFile(args.device, os.path.basename(args.file), "", open(args.file, 'rb'))
    if args.json:
        print(json.dumps(file))
        return
    if args.device and args.device[0] == '#':
        print("File broadcast to channel %s" % (args.device))
    elif not args.device:
        print("File %s sent to all devices" % (file["iden"]))
    else:
        print("File %s sent to %s" % (file["iden"], file["target_device_iden"]))
Example #12
0
def pushLink(args):
    p = PushBullet(args.api_key)
    link = p.pushLink(args.device, args.title, args.url)
    if args.json:
        print(json.dumps(link))
        return
    if args.device and args.device[0] == '#':
        print("Link broadcast to channel %s" % (args.device))
    elif not args.device:
        print("Link %s sent to all devices" % (link["iden"]))
    else:
        print("Link %s sent to %s" % (link["iden"], link["target_device_iden"]))
Example #13
0
def pushAddress(args):
    p = PushBullet(args.api_key)
    address = p.pushAddress(args.device, args.name, " ".join(args.address))
    if args.json:
        print(json.dumps(address))
        return
    if args.device and args.device[0] == '#':
        print("Address broadcast to channel %s" % (args.device))
    elif not args.device:
        print("Address %s sent to all devices" % (address["iden"]))
    else:
        print("Address %s sent to %s" % (address["iden"], address["target_device_iden"]))
Example #14
0
def pushNote(args):
    p = PushBullet(args.api_key)
    note = p.pushNote(args.device, args.title, " ".join(args.body))
    if args.json:
        print(json.dumps(note))
        return
    if args.device and args.device[0] == '#':
        print("Note broadcast to channel %s" % (args.device))
    elif not args.device:
        print("Note %s sent to all devices" % (note["iden"]))
    else:
        print("Note %s sent to %s" % (note["iden"], note["target_device_iden"]))
Example #15
0
def getDevices(args):
    p = PushBullet(args.api_key)
    devices = p.getDevices()
    if args.json:
        print(json.dumps(devices))
        return
    for device in devices:
        if "manufacturer" in device:
            print("%s %s %s" % (device["iden"],
                            device["manufacturer"],
                            device["model"]))
        else:
            print(device["iden"])
Example #16
0
	def push(self, token, notification_info):
		try:
			pb = PushBullet(token)
			pbDevices = pb.devices
		except Exception, e:
			print e
			return False
def main():
    #setup our reddit instance
    reddit = praw.Reddit(client_id=CLIENT_KEY,
                         client_secret=SECRET_KEY,
                         user_agent=USERNAME)
    #setup our pushbullet instance
    push = PushBullet(API_KEY)

    loop_through_posts(reddit=reddit, push=push)
Example #18
0
#!/usr/bin/python2.7
#pushbullet python library - https://github.com/Azelphur/pyPushBullet
from pushbullet.pushbullet import PushBullet
import csv
import os, sys
import glob
import datetime as dt
from operator import sub
#emoji for python https://pypi.python.org/pypi/emoji
import emoji

#pushbullet api key
apiKey = "your pushbullet key"
pb = PushBullet(apiKey)

#grab and set device to push to
devices = pb.getDevices()
phone = devices[1]["iden"]

#get current date
date = dt.datetime.now().date()

#emoji cheatsheet at http://www.emoji-cheat-sheet.com/
meh = (emoji.emojize(':unamused:', use_aliases=True))
sweat = (emoji.emojize(':sweat:', use_aliases=True))
fear = (emoji.emojize(':fearful:', use_aliases=True))
'''
parse csv file
NOTE: csv file must be saved as windows comma seperated values format
	  Saving CSV on a windows machine should be ok but saving on Mac
	  or Linux seems to throw a weird error if not resaved as Windows format
from pushbullet.pushbullet import PushBullet

apiKey = "o.4Om3sn1YmS2wAXKDQG7wakv3Z7yDE5B4"
p = PushBullet(apiKey)

devices = p.getDevices()

# print(devices)

# p.pushNote(devices[3]["iden"], 'Hello mcfly', 'Test body')
p.pushLink(devices[3]["iden"], "Google", "http://www.google.com")
import time
from pydub import AudioSegment
from pydub.playback import play
from pushbullet.pushbullet import PushBullet
import os
import sys


# Script config
CERTS_URL = 'https://review-api.udacity.com/api/v1/me/certifications.json'
ASSIGN_URL = 'https://review-api.udacity.com/api/v1/projects/{pid}/submissions/assign.json'
REVIEW_URL = 'https://review.udacity.com/#!/submissions/{sid}'
REQUESTS_PER_SECOND = 1 # Please leave this alone.

apiKey = "ENTER YOUR PUSHBULLET API KEY"
p = PushBullet(apiKey)
# Get a list of devices
devices = p.getDevices()

# Get a list of contacts
contacts = p.getContacts()


logging.basicConfig(format = '|%(asctime)s| %(message)s')
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

project = {19:"Pitch Perfect: 15$", 20:"MemeMe 2.0: $33",21:"On the Map: $28",22:"Virtual Tourist:$28",23:"You Decide!: 50$",78:"MemeMe 1.0: $28",95:"Pirate Fleet 1: $15",96:"Robot Maze 2: $15",97:"Alien Adventure 1: $12",98:"Alien Adventure 2: $12",99:"Dry-Run: 35$",101:"Pirate Fleet2: $12",102:"Alien 3: $25",110:"Alien 4: $25",111:"Silly Song: $25",155:"GeoQuiz: $15",168:"Common Interoperability Challenges"}
def request_reviews(token):
    song = AudioSegment.from_mp3("doorbell.mp3")
    headers = {'Authorization': token, 'Content-Length': '0'}
Example #21
0
#import wiringpi2 as wiringpi

A_PIN  = 7
B_PIN  = 9
SW_PIN = 8
Xapikey = "08767C1F6E15462D851BAAA5643B7E844"
encoder = gaugette.rotary_encoder.RotaryEncoder.Worker(A_PIN, B_PIN)
encoder.start()
switch = gaugette.switch.Switch(SW_PIN)
last_state = None
count = 0
ecou = 0
envoi = 1
delai = 10
apiKey = "iJqqpUXVEZiBuxFuv35LQYeigq4Ido0L"
p = PushBullet(apiKey)
devices = p.getDevices()
contacts = p.getContacts()
#p.pushNote(devices[0]["iden"], 'Hello world', 'Test body')
#wiringpi.wiringPiSetupGpio()
#wiringpi.pinMode(21, 0)
#wiringpi.digitalRead(21)
#p.pushList( "list", "courses", "tomates", "oeufs", "pain", "eau", "mayo")
while True :
    #delta = encoder.get_delta()
    sleep(0.5)
    timer = time.time()
    ecou = timer + delai
    sw_state = switch.get_state()
    #print "boucle1"
    while sw_state == 1 :
        "/home/roark/AutoAccessCowin/cowin-vaccination-slot-availabilityv2/PreviousAvailabilityShelf",
        writeback=True)
else:
    shelf = shelve.open(
        "/home/roark/AutoAccessCowin/cowin-vaccination-slot-availabilityv2/PreviousAvailabilityShelf",
        writeback=True)
    shelf['previousavailability'] = False

numdays = 7
DIST_ID = '170'

config_object = ConfigParser()
config_object.read("config.ini")
auth = config_object["AUTH"]["api_key"]
print(auth)
p = PushBullet(auth)

base = datetime.datetime.today()
date_list = [base + datetime.timedelta(days=x) for x in range(numdays)]
date_str = [x.strftime("%d-%m-%Y") for x in date_list]

temp_user_agent = UserAgent()
browser_header = {'User-Agent': temp_user_agent.random}

for INP_DATE in date_str:
    URL = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id={}&date={}".format(
        DIST_ID, INP_DATE)
    response = requests.get(URL, headers=browser_header)
    if (response.ok) and ('centers' in json.loads(response.text)):
        resp_json = json.loads(response.text)['centers']
        if (resp_json is not None):
Example #23
0
 def sendNotify(self, msg):
     # pushBullet notify call for registerd devices
     apiKey = "o.2uIo9r0MKCCFX8Mv3uMhp4xOXE9vgBrC"
     p = PushBullet(apiKey)
     devices = p.getDevices()
     p.pushNote(devices[0]["iden"], 'Raspberry-Pi-Notification', msg)
Example #24
0
import dryscrape
import sys
import time
from pushbullet.pushbullet import PushBullet

if 'linux' in sys.platform:
    dryscrape.start_xvfb()

# USER VARIABLES START
trackingNumber = 'YOUR_TRACKING_NUMBER'
apiKey = 'YOUR_API_KEY'
deviceId = 'YOUR_PUSHBULLET_DEVICE_ID'
refreshRate = 30  # how often to check the status in minutes
# USER VARIABLES END

p = PushBullet(apiKey)
prevStatus = ''

# set up a web scraping session
sess = dryscrape.Session(base_url='https://www.royalmail.com')

# we don't need images
sess.set_attribute('auto_load_images', False)

while True:
    # visit the tracking page and lookup the tracking number
    sess.visit('/track-your-item')
    q = sess.at_xpath('//*[@name="tracking_number"]')
    q.set(trackingNumber)
    q.form().submit()
Example #25
0
def notifyuser():
    p = PushBullet(apiKey)
    devices = p.getDevices()
    print(devices)
    p.pushNote(devices[0]["iden"], 'Smart Home Manager', 'Intruder Detected')
Example #26
0
def notify_neighbor(name):
    p = PushBullet(apiKey)
    devices = p.getDevices()
    print(devices)
    response="Intruder Detected in {}'s Home. Please check.".format(name)
    p.pushNote(devices[0]["iden"], 'Smart Home Manager', response)
Example #27
0
def notifyuser_place(msg):
    p = PushBullet(apiKey)
    devices = p.getDevices()
    print(devices)
    p.pushNote(devices[0]["iden"], 'Smart Home Manager', 'Intruder Detected in {}'.format(msg))
Example #28
0
from pushbullet.pushbullet import PushBullet

api_key = ''

pb = PushBullet(api_key)


# Get a list of devices
devices = pb.getDevices()
print(devices)

# test values
albumURI = "1231232141sdasd"
deviceID = "123214123212"

# Send a note
note_title = 'Played ' + albumURI
note_body = 'Song played on ' + deviceID
pb.pushNote(devices[1]["iden"], note_title, note_body)
import datetime
import itertools  #Implements iterators which run efficiently
import json
import requests
from pushbullet.pushbullet import PushBullet
from configparser import ConfigParser
from urllib.parse import urljoin

config = ConfigParser()
config.read("config.ini")
auth = config["push_bullet"]["api_key"]
cowin_api = config["api"]
search_params = config["search"]

p = PushBullet(auth)
push_to_devices = [x["iden"] for x in p.getDevices()
                   if x["active"]]  # allows to push to multiple devices.

numdays = int(search_params["num_days"])  #Converts String into Integer
district_ids = search_params["districts"].split(",")

base = datetime.datetime.today()
date_list = [base + datetime.timedelta(days=x) for x in range(0, numdays, 2)]
date_str = [x.strftime("%d-%m-%Y") for x in date_list]

header = {
    'User-Agent':
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) "
    "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"
}
Example #30
0
from fbchat import log, Client
from pushbullet.pushbullet import PushBullet
import requests
import json

apiKey = "YOUR API KEY"
p = PushBullet(apiKey)
# Get a list of devices
devices = p.getDevices()


class Checker:
    sendmes = False
    prev_auth = '0000000000000'


def send_notification_via_pushbullet(title, body):
    """ Sending notification via pushbullet.
        Args:
            title (str) : title of text.
            body (str) : Body of text.
    """
    data_send = {"type": "note", "title": title, "body": body}

    ACCESS_TOKEN = apiKey
    resp = requests.post('https://api.pushbullet.com/v2/pushes',
                         data=json.dumps(data_send),
                         headers={
                             'Authorization': 'Bearer ' + ACCESS_TOKEN,
                             'Content-Type': 'application/json'
                         })
Example #31
0
    def sendPushNotification(self):
        apiKey = "o.BpgNSJ77CGxsWEz2CUJWkDI0oI8hYGoq"
        p = PushBullet(apiKey)
        # Getting a list of devices
        devices = p.getDevices()

        # Specifying relative path
        path1 = os.path.realpath(__file__)
        path2 = os.path.basename(__file__)
        rel_path = path1.replace(path2, "")

        # Loading config.json file
        with open(rel_path + 'config.json', 'r') as f:
            config_dict = json.load(f)

        i = 1
        while i < 10:
            deviceList = self.scanDevices()
            print(deviceList)
            if devices[0].get("nickname") in deviceList:
                print("Device found. Sending notification...")
                print(self.humid)
                print(self.temp)
                # Check if the readings are out of range
                # Send pushbullet notification based on readings status
                if self.humid < config_dict['min-humidity']:
                    if self.temp < config_dict['min-temperature']:
                        range1 = config_dict['min-humidity'] - self.humid
                        range2 = config_dict['min-temperature'] - self.temp
                        comment = 'The temperature is ' + str(round(range2, 2))
                        comment = comment + ' degrees lower than the limit '
                        comment = comment + 'and the humidity is '
                        comment = comment + str(round(range1, 2))
                        comment = comment + '% lower than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                    elif self.temp > config_dict['max-temperature']:
                        range1 = config_dict['min-humidity'] - self.humid
                        range2 = self.temp - config_dict['max-temperature']
                        comment = 'The temperature is ' + str(round(range2, 2))
                        comment = comment + ' degrees higher than the limit '
                        comment = comment + 'and the humidity is '
                        comment = comment + str(round(range1, 2))
                        comment = comment + '% lower than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                    else:
                        range = config_dict['min-humidity'] - self.humid
                        comment = 'The humidity is ' + str(round(range, 2))
                        comment = comment + '% lower than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                elif self.humid > config_dict['max-humidity']:
                    if self.temp < config_dict['min-temperature']:
                        range1 = self.humid - config_dict['max-humidity']
                        range2 = config_dict['min-temperature'] - self.temp
                        comment = 'The temperature is ' + str(round(range2, 2))
                        comment = comment + ' degrees lower than the limit '
                        comment = comment + 'and the humidity is '
                        comment = comment + str(round(range1, 2))
                        comment = comment + '% higher than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                    elif self.temp > config_dict['max-temperature']:
                        range1 = self.humid - config_dict['max-humidity']
                        range2 = self.temp - config_dict['max-temperature']
                        comment = 'The temperature is ' + str(round(range2, 2))
                        comment = comment + ' degrees higher than the limit '
                        comment = comment + 'and the humidity is '
                        comment = comment + str(round(range1, 2))
                        comment = comment + '% higher than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                    else:
                        range = self.humid - config_dict['max-humidity']
                        comment = 'The humidity is ' + str(round(range, 2))
                        comment = comment + '% higher than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                elif self.temp < config_dict['min-temperature']:
                    if self.humid < config_dict['min-humidity']:
                        range1 = config_dict['min-humidity'] - self.humid
                        range2 = config_dict['min-temperature'] - self.temp
                        comment = 'The temperature is ' + str(round(range2, 2))
                        comment = comment + ' degrees lower than the limit '
                        comment = comment + 'and the humidity is '
                        comment = comment + str(round(range1, 2))
                        comment = comment + '% lower than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                    elif self.humid > config_dict['max-humidity']:
                        range1 = self.humid - config_dict['max-humidity']
                        range2 = config_dict['min-temperature'] - self.temp
                        comment = 'The temperature is ' + str(round(range2, 2))
                        comment = comment + ' degrees lower than the limit '
                        comment = comment + 'and the humidity is '
                        comment = comment + str(round(range1, 2))
                        comment = comment + '% higher than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                    else:
                        range = config_dict['min-temperature'] - self.temp
                        comment = 'The temperature is ' + str(round(range, 2))
                        comment = comment + ' degrees lower than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                elif self.temp > config_dict['max-temperature']:
                    if self.humid < config_dict['min-humidity']:
                        range1 = config_dict['min-humidity'] - self.humid
                        range2 = self.temp - config_dict['max-temperature']
                        comment = 'The temperature is ' + str(round(range2, 2))
                        comment = comment + ' degrees higher than the limit '
                        comment = comment + 'and the humidity is '
                        comment = comment + str(round(range1, 2))
                        comment = comment + '% lower than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                    elif self.humid > config_dict['max-humidity']:
                        range1 = self.humid - config_dict['max-humidity']
                        range2 = self.temp - config_dict['max-temperature']
                        comment = 'The temperature is ' + str(round(range2, 2))
                        comment = comment + ' degrees higher than the limit '
                        comment = comment + 'and the humidity is '
                        comment = comment + str(round(range1, 2))
                        comment = comment + '% higher than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                    else:
                        range = self.temp - config_dict['max-temperature']
                        comment = 'The temperature is ' + str(round(range, 2))
                        comment = comment + ' degrees higher than the limit'
                        p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                else:
                    comment = 'The temperature is ' + str(round(
                        self.temp, 2)) + ' degrees'
                    comment = comment + ' and the humidity is ' + str(
                        round(self.humid, 2))
                    comment = comment + '%'
                    p.pushNote(devices[0]["iden"], 'Bluetooth', comment)

                i = 10
            # If the device is not found
            else:
                print("Device not found")
                i = i + 1
Example #32
0
import dryscrape
import sys
import time
from pushbullet.pushbullet import PushBullet

if 'linux' in sys.platform:
    dryscrape.start_xvfb()

# USER VARIABLES START
trackingNumber = 'YOUR_TRACKING_NUMBER'
apiKey = 'YOUR_API_KEY'
deviceId = 'YOUR_PUSHBULLET_DEVICE_ID'
refreshRate = 30 # how often to check the status in minutes
# USER VARIABLES END

p = PushBullet(apiKey)
prevStatus = ''

# set up a web scraping session
sess = dryscrape.Session(base_url = 'https://www.royalmail.com')

# we don't need images
sess.set_attribute('auto_load_images', False)

while True:
    # visit the tracking page and lookup the tracking number
    sess.visit('/track-your-item')
    q = sess.at_xpath('//*[@name="tracking_number"]')
    q.set(trackingNumber)
    q.form().submit()