Kevo Plus door locks now working in Home Assistant

I don’t have enough knowledge of python to migrate this to a full HA component. I’ve asked a few other devs if they would like to take on the project, but without a device to test on, none were willing to help.

I’ve gone ahead and created a custom component and it all seems to work on my own setup. If you get your python3 version of pykevoplus onto PyPI, then my custom component can be fully released and potentially turned into a full official component.

1 Like

Holy crap. THANK YOU!

Let me work on that.

Done.

Uploaded as pykevocontrol, but the package still installs as pykevoplus to ensure there’s no changes needed to scripting.

I’m actually running into issues getting it to install your version of the package as a dependency. Once I get this figured out, I’ll throw it on github and let you play with it.

Interesting. Do you think it’s a issue with the new and old version sharing a package name? I can always change the entire project to pykevocontrol and reupload if it helps.

I tested on a fresh venv before uploading to pypi and had no issues installing or checking the status of my locks.

I don’t think it’s an issue on your part. For some reason, my home assistant install is not installing the dependency. I’ve gone and uploaded my latest version to github here. If you throw that kevo.py into your home assistant environment at CONFIG_DIRECTORY/custom_components/lock, you can then add

lock:
  platform: kevo
  email: [email protected]
  password: xxxxxxxx

to your configuration.yaml and you should be ready to roll.

Let me know how it works for you and if you run into any issues.

Just reuploaded a new commit of the custom component where I’ve fixed my stupid mistake. Let me know if you get a chance to try it.

I’ll be in installing it as soon as I get home. I was out with the wife running errands.

Working well so far.

Great. I’m going to put together what I need to submit this as a pull request so that it can be an official component included in a future HA release.

Awesome. Thank you for putting this component together.

I’ve ran into an issue when locking my doors. If the front door is locked and the back door is unlocked, running this script:

lock_doors:
  sequence:
    - service: lock.lock
      entity_id: lock.front_door
    - delay:
        seconds: 10
    - service: lock.lock
      entity_id: lock.back_door

results in this error:

2017-08-19 08:42:15 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 181, in _step
    result = coro.throw(exc)
  File "/srv/hass/lib/python3.6/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/lib/python3.6/site-packages/homeassistant/components/lock/__init__.py", line 95, in async_handle_lock_service
    yield from entity.async_lock(code=code)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/.homeassistant/custom_components/lock/kevo.py", line 58, in lock
    self._kevo.Lock()
  File "/srv/hass/lib/python3.6/site-packages/pykevoplus/__init__.py", line 108, in _wrapped
    return method(self, *args, **kwargs)
  File "/srv/hass/lib/python3.6/site-packages/pykevoplus/__init__.py", line 253, in Lock
    self.WaitForLocked()
  File "/srv/hass/lib/python3.6/site-packages/pykevoplus/__init__.py", line 235, in WaitForLocked
    self._WaitForState("locked", timeout)
  File "/srv/hass/lib/python3.6/site-packages/pykevoplus/__init__.py", line 108, in _wrapped
    return method(self, *args, **kwargs)
  File "/srv/hass/lib/python3.6/site-packages/pykevoplus/__init__.py", line 197, in _WaitForState
    raise KevoError("Timeout waiting for {}".format(state.lower()))
pykevoplus.KevoError: Timeout waiting for locked

I wrote a quick script to add some logic and only send lock requests to unlocked doors and am no longer receiving the error. It looks like the component panics if we try to lock an already locked door.

I am researching a future purchase of a smart lock. Does anyone know if this will work with hassio?

I’m not extremely familiar with hassio, but so long as you can install custom components into your install, it should.

Just tried to install this component in Hass.io and I’m getting the following error on startup:

Error while setting up platform kevo
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 171, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, 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 88, in GetLocks
    lock_id = lock_info.get("data-lock-id")
AttributeError: 'NoneType' object has no attribute 'get'

That error is usually a result of the kevo webserver acting wonky. They have been doing a large amount of maintenance lately and it’s been causing the webapp to show kevo plus bridges as offline from time to time. Give it a couple hours, and if it’s still throwing the error after a restart, there may actually be something wrong.

Sounds good. I’ve just tried rebooting and I’m still getting the same error but I’ll try again in another hour or so.

Still not working this morning. The Homebridge-Kevo addon however does work and I’m pretty sure it uses the same API albeit the original version.

I’m happy to help test this component so as necessary so that it can be integrated as an official component.

Running the Homebridge-Kevo addon might be what’s causing the issue as both PyKevoControl (my version) and PyKevoPlus (the original library) both use the same class names and both install as PyKevoPlus due to prior compatibility concerns. You may want to try manually installing PyKevoControl from pypi.com:

pip install pykevocontrol

This will more than likely break the homebridge addon, but correct the Hass component. As for testing to turn this into an official component, that would be up to gaggle331. It’s way out of my league.