Esempio n. 1
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Kevo platform."""
    from pykevoplus import KevoLock

    # Assign configuration variables. The configuration check takes care they are
    # present.
    email = config.get(CONF_EMAIL)
    password = config.get(CONF_PASSWORD)
    lock_id = config.get(CONF_LOCK_ID)
    max_retries = config.get(CONF_MAX_RETRIES)
    retry_delay = config.get(CONF_RETRY_DELAY)

    # Setup connection with devices/cloud (broken as of 9 Sep 2019 due to CAPTCHA changes)
    # kevos = Kevo.GetLocks(email, password)
    # add_devices(KevoDevice(kevo) for kevo in kevos)

    # Setup manual connection with specified device
    for attempt in range(max_retries):
        try:
            kevo = KevoLock.FromLockID(lock_id, email, password)
        except:
            if attempt == max_retries - 1:
                raise
            else:
                time.sleep(retry_delay)
        else:
            break

    add_devices([KevoDevice(kevo)])
Esempio n. 2
0
def get_lock(lock_id):
    if locks.get(lock_id, None) is None:
        lock = KevoLock.FromLockID(lock_id, os.environ['KEVO_USERNAME'],
                                   os.environ['KEVO_PASSWORD'])
        locks[lock_id] = lock

        return lock
    else:
        return locks[lock_id]
 def FromJSON(lockJSON, username, password):
     """
     Create a KevoLock from the JSON metadata of the lock
     Args:
         lockJSON:   the JSON data of the lock (dict)
         username:   your mykevo.com username (str)
         password:   your mykevo.com password (str)
     Returns:
         A ready to use lock object (KevoLock)
     """
     lock = KevoLock()
     lock.username = username
     lock.password = password
     lock.data = lockJSON
     lock.lockID = lock.data["id"]
     lock.name = lock.data["name"]
     lock.state = lock.data["bolt_state"]
     return lock
Esempio n. 4
0
    def initialize(self):

        #create and set instance variables
        self.lock = globals.get_arg(self.args, "lock_id")
        self.kuser = globals.get_arg(self.args, "k_user")
        self.kpass = globals.get_arg(self.args, "k_pass")
        self.sname = globals.get_arg(self.args, "select_name")

        self.a_lock = KevoLock.FromLockID(self.lock, self.kuser, self.kpass)
        self.select_name = 'input_boolean.' + self.sname

        # locked = on , unlocked = off

        #self.set_state(self.select_name, state= self.a_lock.GetBoltState())
        self.listen_state(self.changer, self.select_name)
        ti_now = datetime.datetime.now()
        r_next = random.randint(4, 9)
        self.log("Update " + self.sname + " every " + str(r_next) + " minutes")
        self.run_every(self.lock_status, ti_now, r_next * 60)
 def FromLockID(lockID, username, password):
     """
     Create a KevoLock from the ID of the lock
     Args:
         lockID:     the UUID of the lock (str)
         username:   your mykevo.com username (str)
         password:   your mykevo.com password (str)
     Returns:
         A ready to use lock object (KevoLock)
     """
     lock = KevoLock()
     lock.lockID = lockID
     lock.username = username
     lock.password = password
     lock.Refresh()
     return lock

#if __name__ == "__main__":
#    from getpass import getpass

#user = raw_input("Username: "******"Password: "******"cca7cd1d-c1d5-43ce-a087-c73b974b3529"
#    back_door_id = "c60130cd-8139-4688-8ba3-199276a65ad6"
#    for lock_id in [front_door_id, back_door_id]:
#        kevolock = KevoLock.FromLockID(lock_id, user, passwd)
#        print str(kevolock)

# Do multiple operations on a lock using a single session
#    kevolock = KevoLock.FromLockID(garage_door_id, user, passwd)
#    with KevoLockSession(kevolock):
#        kevolock.Unlock()
#        kevolock.Lock()

from pykevoplus import KevoLock
lock = KevoLock.FromLockID("84760801-cccd-a54f-c321-76e29cc6489a",
                           "*****@*****.**", "Epl7004872")
print(lock.GetBoltState())