Kevo Plus door locks now working in Home Assistant

I have managed to integrate my Kevo deadbolts into Hass using pykevoplus by cseelye. The only requirement is a Kevo deadbolt and a Kevo Plus bridge. The instructions below assume you are running Hass in a virtual environment on a RPi3. YMMV.

1. Install pykevoplus

$ sudo su -s /bin/bash hass
$ source /srv/hass/hass_venv/bin/activate
$ pip3 install pykevoplus
$ mkdir /home/hass/.homeassistant/kevo
$ cd /home/hass/.homeassistant/kevo

2. Get your Lock-IDs

$ python
>>> from pykevoplus import Kevo
>>> locks = Kevo.GetLocks("***USERNAME***", "***PASSWORD***")
>>> for lock in locks:
...    print repr(lock)
...

Output

KevoLock(name=Front Door, id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, state=Locked)

3. Create the following files in /home/hass/.homeassistant/kevo
status-front.py

#!/usr/bin/python2.7.9

from pykevoplus import KevoLock
lock = KevoLock.FromLockID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "***USERNAME***", "***PASSWORD***")
print lock.GetBoltState()

lock-front.py

#!/usr/bin/python2.7.9

from pykevoplus import KevoLock
lock = KevoLock.FromLockID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "***USERNAME***", "***PASSWORD***")
lock.Lock()
print lock.GetBoltState()

unlock-front.py

#!/usr/bin/python2.7.9

from pykevoplus import KevoLock
lock = KevoLock.FromLockID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "***USERNAME***", "***PASSWORD***")
lock.Unlock()
print lock.GetBoltState()

4. Fix permissions

$ chmod 755 -R ./

5. Add the switch to your configuration.yaml

- platform: command_line
  switches:
    door_front:
      command_on: "python /home/hass/.homeassistant/kevo/lock-front.py"
      command_off: "python /home/hass/.homeassistant/kevo/unlock-front.py"
      command_state: "python /home/hass/.homeassistant/kevo/status-front.py"
      value_template: '{{ value == "Locked" }}'
3 Likes

Can you please list what model of Kevo are you using? Is it a 2nd generation Kevo touch smart lock or is it a kevo smart lock conversion kit ?

I have both 1st gen and a 2nd gen Kevo touch smart locks. I do not have a Kevo convert yet. All 3 models should work so long as you have the Kevo Plus bridge.

Does this talk directly to the kevo bridge on your lan, or does it need internet access?

I am looking for a smart lock that works with hass, but don’t want to depend on any third party cloud services.

Unfortunately, because of the lack of an official API, this has to route calls through the web.

I think your best bet for a smartlock that works with hass and can receive commands locally would probably be a Schlage or Kwikset Z-Wave smartcode lock…

ah too bad, thanks for the suggestions :+1:t3:

No problem.

im getting invalid syntax error in status-front.py. at the print lock.GetBoltState()
Any ideas ?

Did you make sure to include the shebang line?

#!/usr/bin/python2.7.9

Without that, HA will attempt to run the script in python3, which it’s not compatible with.

Yeah that line is there. It seems like its using python3 still. Im pretty sure I installed it.

Is python2 installed on your system?

Got an email today from Kevo about the amount of traffic tied to my account, so this setup might not be the best idea…

Still going strong. I never got a response as to whether the traffic I was generating was excessive, or if they wanted me to increase my scan_interval. It seems they were mainly just checking to ensure it wasn’t an issue with my setup.

Used this guide to install on an hassbian image, change paths to hass to homeassistant. Checked and python2 is installed. Getting SyntaxError: anything I am missing?

    >>> from pykevoplus import Kevo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/srv/homeassistant/lib/python3.4/site-packages/pykevoplus/__init__.py", line 317
    print repr(kevolock)
             ^

Judging by the error, it’s attempting to run in Python3, which won’t work. Try reinstalling and running the command in the terminal to ensure it’s working.

Tried to reinstall and getting the same error. Executing python2 or course says it can’t find the pykevoplus file.

Don’t want to hijack the thread. I don’t think it is an issue with the script. I think if is me not being able to execute a simple script (completely new HA and python) .

Pi user python is showing version 2.7
Homeassistant user showing python 3.4
Executing $ python in homeassistant is giving me the error as shown earlier
Executing $ python2 is file not being found

Maybe attempt to install python2 on the homeassistant account?

sudo apt-get install python2.7

I’ve updated the library to work in python3 to eliminate the issues your having. I’ll update this post tonight with more details.

I have updated the pykevoplus library written by cseelye to python3. The installation is a bit different as is some of the scripting.

I have hopes that someone will eventually pick up from where I have left off and create a full fledged component for using the pykevoplus library. As it stands now, we have very basic status information, and the ability to lock and unlock the device. There is currently no proper error handling or any ability to alert the user to bolt jams or low battery situations.

These instructions assume that you’re running within a virtual environment on a raspberry pi, so you may have to adjust directories slightly You will need to create additional scripts for each lock. These instructions only cover a single lock named "front door."

1. Install pykevoplus v2.0

$ wget -O pykevoplus_v2.0.tar.gz https://github.com/Bahnburner/pykevoplus/archive/v2.0.tar.gz
$ sudo pip3 install pykevoplus_v2.0.tar.gz

2. Create directories for your scripts

$ mkdir /home/hass/.homeassistant/kevo
$ cd /home/hass/.homeassistant/kevo

3. Get your Lock ID’s

$ python
>>> from pykevoplus import Kevo
>>> locks = Kevo.GetLocks("***USERNAME***", "***PASSWORD***")
>>> for lock in locks:
...    print(repr(lock))
...

Output

KevoLock(name=Front Door, id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, state=Locked)

We will be using the lock ID returned from that command in the following scripts

4. Create the following files in /home/hass/.homeassistant/kevo
status-front.py

from pykevoplus import KevoLock
lock = KevoLock.FromLockID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "***USERNAME***", "***PASSWORD***")
print(lock.GetBoltState())

lock-front.py

from pykevoplus import KevoLock
lock = KevoLock.FromLockID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "***USERNAME***", "***PASSWORD***")
lock.Lock()
print(lock.GetBoltState())

unlock-front.py

from pykevoplus import KevoLock
lock = KevoLock.FromLockID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "***USERNAME***", "***PASSWORD***")
lock.Unlock()
print(lock.GetBoltState())

5. Fix permissions

$ chmod 755 -R ./

6. Add the switch to your configuration.yaml

- platform: command_line
  scan_interval: 30
  switches:
    door_front:
      command_on: "python3 /home/hass/.homeassistant/kevo/lock-front.py"
      command_off: "python3 /home/hass/.homeassistant/kevo/unlock-front.py"
      command_state: "python3 /home/hass/.homeassistant/kevo/status-front.py"
      value_template: >
        {% if value == "Locked" %}
          true
        {% elif value == "Unlocked" %}
          false
        {% else %}
        {% endif %}

Why not turn this into an official HA component? Have you reached out to the HA core team to see if this is something they would allow a PR for?

I’m on the market for a smart lock now, and would only go the BT (Kevo) route if I could get it working with HA and have “One-Touch” unlock. Having to pull out the phone and open an app, or manually entering in a code just seems old school to me. Might as well just pull out yer key.

Sounds like this Kevo/HA integration is still very much a shim with limited functionality.