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 %}