Kevo Plus door locks now working in Home Assistant

Yeah, I get that, when I bought my Baldwin lock (which is a Kevo) I had all these ideas of enabling home mode and disabling the security system when the door unlocks, etc… But I’ve changed my mindset completely now, honestly, the Kevo app SUCKS, the locking and unlocking is very unreliable unless the app is opened in the foreground.

So when I leave the house in the morning I double tap down on a GE switch and it enables my away mode sequence which includes locking my Kevo after so many seconds. This has been working perfectly so far and it is 50% of the battle. I can leave the house quickly and not worry about having to open the app and launch/relaunch it so I can lock my door.

I just started playing around with presence detection using a ping to my iPhone to disable away mode and unlock the door. I have all the logic down and it works but my phone doesn’t connect to the WiFi network fast enough always; I hope that gets fixed once i move away from my temporary AP in the basement to my two UniFi APs I’ll have setup on the first and second floor.

So my mindset has changed form trying to make the lock a trigger for automation to making it as invisible as possible so I don’t have to think about it. I love how the lock looks on the inside and outside and if I can get the functionality to be invisible then I’ll be happy.

If you want the Kevo to be a trigger for actions, have you thought about using IFTTT/Kevo to trigger actions - I know there will be a delay but it might work for your needs.

That would be perfect but I agree, we shouldn’t hold our breath.

I’m wondering if maybe we’re reading too deep into something that’s not there. Since Januaryish, I’ve had issues with the Error500’s when using the custom component, and have instead been running my locks using command line switches with a 30 second scan interval. Yesterday, I had the same consistent errors that everyone else did. Every 3rd scan would return an error. Today, those errors are gone. I’m maybe getting 1 or 2 per hour.

I’m wondering if Kwikset/Unikey were simply having server issues yesterday. Either way, it’s probably not in our best interest to continuously hammer their webapp with requests, but it seems like maybe this time we were seeing something that didn’t actually exist.

I am only checking every 15 minutes I get a consistent

KevoError(“Error getting lock info: {}”.format(info_result.text))

and server 500 error along with it.

for about a week I was able to track the kids and lock the locks if they left the home zone and left the door unlocked, now I can’t even get the state, or control the locks at all.

Unfortunately, there’s not much we can do about it as the issue appears to be on Kevo’s side.

I’ve been talking with a few Kevo Homebridge users/developers, and we’ve confirmed that this is caused by an issue on Kevo’s servers as the Error 500’s are occurring even when directly accessing the web app in a browser.

Hopefully they’ll resolve the issue quickly. The last time this occurred, it lasted a few days. We’re sitting at over a week now…

POTENTIAL GOOD NEWS
My current setup polls 2 separate locks every 30 seconds and I have not had a single failed call or Error 500 returned since 12:30am CST this morning. I’m hoping this means that any server issues on Kwikset’s side have been resolved. I have temporarily re-enabled @gaggle331’s component as a backup to my current command_line switch and will monitor for issues and report back.

EDIT: Scratch that. The component has began failing with Error 500’s every update again. The command line switch is still working without a hiccup though.

Hey Bahnburner,

My locks are also continuing to return the server 500 errors, so I am confused.

If your command lines switches are working, gaggle’s custom component is 500ing and my python scripts are 500ing, but we are all using the underlying pykevoplus code what is happening? aren’t they ‘the same’ in terms of hitting the server?

thoughts?

They are using identical components. The only thing I can think of is that the python scripts my command line switch uses logs in every refresh rather than reusing the same auth cookies the way a proper component should.

I have come back to this after a few weeks and tried with just one lock and it is working fine. As soon as I add in the second lock, the second starts getting the 500s, while the first is continues fine.

I have removed the second lock, as having one working is better than none.

I also cleaned up the code as it was really inept and while it may not be perfect this new version (below) is much better. If you can see any reason why the second instance may be causing issues let me know.

import appdaemon.plugins.hass.hassapi as hass
import datetime
from pykevoplus import KevoLock

class DoorLock(hass.Hass):

    def initialize(self):
             
        #create and set instance variables
        self.a_lock = KevoLock.FromLockID(self.args["lock_id"], self.args["k_user"], self.args["k_pass"])
        self.select_name = 'input_select.' + self.args["select_name"]
 
        self.set_state(self.select_name, state= self.a_lock.GetBoltState())
        self.listen_state(self.changer,  self.select_name)
        ti_now = datetime.datetime.now()
        self.run_every(self.lock_status, ti_now, 15 * 60)
                  
    def changer(self, entity, attribute, old, new, kwargs):

        current = self.a_lock.GetBoltState()

        if new == "Locked" and current == "Unlocked":
            self.a_lock.Lock()
        elif new == "Unlocked" and current == "Locked":
            self.a_lock.Unlock()

        self.set_state(self.select_name, state= self.a_lock.GetBoltState())
        self.log("change " + entity + " to " + new)

    def lock_status(self, kwargs):

        self.log(self.select_name + " status checked")

        self.set_state(self.select_name, state= self.a_lock.GetBoltState())

I’ve made (what should be) a very temporary update to my custom component that should hopefully clear up a majority of the 500 errors. It’s honestly not a very smart fix but it works for me (for now). I had a suspicion that the problem was caused by invalid sessions, so I’ve been trying to address that. I’m positive there’s a better way to do this but it’s what I came up with in my 5 free minutes today.

All I’ve done is tell the underlying pykevoplus library to invalidate the session on every lock status update. This will force it create a new session every time it tries to get the status of the locks. So far, it works for me. Occasionally, I still get 500 errors but this fix at least makes it so you don’t have to restart HA completely for the locks to start working again.

The component can still be found here: https://github.com/gaggle331/home-assistant-kevo

2 Likes

Thanks gaggle331, I have also changed my code to start and close a new session on each call, as well as putting in a ‘random’ refresh time (between 3 and 11 minutes) which is allowing me to run my two locks at the same time (so that they aren’t doing the requests on top of each other). This has been working well for the last few weeks.

@gaggle331 @Bahnburner

I’ve been using this for a while, and it’s pretty stable for me. Have you considered submitting it as an official component? I don’t have the knowledge to help develop it, but I have a Kevo and can help test if needed.

I’ve actually moved to kwikset z-wave locks due to constant issues with the kevo ecosystem, so I won’t be working on this any further. With that being said, all the real work was done by @gaggle331 anyway.

Mind sharing which locks you moved to?

Kwikset 916.

Anyone updated to 0.84? Since updating, my kevo custom_component no longer works. I get:

 2018-12-12 19:31:08 ERROR (MainThread) [homeassistant.components.lock] Error while setting up platform kevo
 Traceback (most recent call last):
   File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
     SLOW_SETUP_MAX_WAIT, loop=hass.loop)
   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
     return fut.result()
   File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
     result = self.fn(*self.args, **self.kwargs)
   File "/config/custom_components/lock/kevo.py", line 32, in setup_platform
     kevos = Kevo.GetLocks(email, password)
   File "/config/deps/lib/python3.6/site-packages/pykevoplus/__init__.py", line 92, in GetLocks
     locks.append(KevoLock.FromJSON(lock_details, username, password))
   File "/config/deps/lib/python3.6/site-packages/pykevoplus/__init__.py", line 157, in FromJSON
     lock.lockID = lock.data["id"]
 KeyError: 'id'

When will this component be updated to support the latest custom component structure introduced in 88.1?

You just have to move the file from lock/kevo.py to kevo/lock.py and create a blank init.py file in the kevo folder. The actual component doesn’t need to be modified.

1 Like

Any plans for this to become an official platform?

This might be broken for good. :sob: The mykevo.com site is now using captchas, so the method used by pykevocontrol isn’t working anymore.

If anyone has another method that allows HA to know the current state of the lock, please send pointers. The IFTTT integration doesn’t report state changes from manual lock/unlock events.

  • Benjamin