I will state at the outset that all this is because of Bahnburner and gaggle331, I have just played about with their ideas and hard work. My many thanks go to those skilled individuals.
I have got the whole lot working in appdaemon, with IFTTT webhooks to provide a more âreal-timeâ connection. Here are the steps if anyone needs it for use in Hass.io
First install appdaemon v3 & the ssh component using the following Git - GitHub - hassio-addons/repository: Home Assistant Community Add-ons
Then once you have started the service, you will get an appdaemon folder in your config directory.
follow the instructions to turn on apps in the appdaemon.yaml file.
In the apps directory, in the apps.yaml file you will need to add in the following (one per lock)
front-lock:
module: locks
class: DoorLockF
lock_id: "YOUR LOCK ID"
k_user: "YOUR KEVO USERNAME"
k_pass: "YOUR KEVO PASSWORD"
select_name: "xxxxx"
you need an input_select.xxxxx setup (in your config file) that looks like (one per lock)
xxxxx:
name: Front Door
options:
- Locked
- Unlocked
initial: Locked
icon: mdi:key-variant
using ssh (add in the component from the repository) into your server, (/usr/bin/pip3) to install Bahnburnerâs code
This will install them to /usr/lib/python3.6/site-packages/pykevoplus
or use
$ find / -name pykevoplus
use
$ cp -R /usr/lib/python3.6/site-packages/pykevoplus /config/appdaemon/apps
$ cp -R /usr/lib/python3.6/site-packages/bs4 /config/appdaemon/apps
then, in the apps directory in the appdaemon folder create a âkevoâ folder
create a file called locks.py (I actually have a separate file for each lock, locksf.py, locksg.py) as the instances seemed to be getting mixed up
copy in the following code (same exact code for each file, all the differences are in the apps.yaml)
import appdaemon.plugins.hass.hassapi as hass
import datetime
from pykevoplus import KevoLock
class DoorLockF(hass.Hass):
lock_id = ""
k_user = ""
k_pass = ""
select_name = ""
a_lock = ""
def initialize(self):
global lock_id
lock_id = self.args["lock_id"]
global k_user
k_user = self.args["k_user"]
global k_pass
k_pass = self.args["k_pass"]
global select_name
select_name = 'input_select.' + self.args["select_name"]
global a_lock
a_lock = KevoLock.FromLockID(lock_id, k_user, k_pass)
self.set_state(select_name, state= a_lock.GetBoltState())
self.listen_state(self.changer, select_name)
ti = datetime.datetime.now()
self.run_every(self.mode_status, ti, 15 * 60)
def changer(self, entity, attribute, old, new, kwargs):
self.log("change " + entity + " " + select_name + " " + old + " " + new)
if entity == select_name and new == "Locked" and a_lock.GetBoltState() == "Unlocked":
a_lock.Lock()
elif entity == select_name and new == "Unlocked" and a_lock.GetBoltState() == "Locked":
a_lock.Unlock()
self.set_state(select_name, state= a_lock.GetBoltState())
def mode_status(self, kwargs):
self.log("called updated")
self.set_state(select_name, state= a_lock.GetBoltState())
this now has a check of every 15 minutes to see what the status of the locks is, as well as watching your input select control, and adjusting the lock to match the control. (it is relatively slow (10-20 seconds) but it works)
to do the real time stuff with IFTTT
You need to turn on api calls into the system, add to your configuration file
api:
You can then setup the webhooks IFTTT integration using the how to on the site. and then add the following in your recipe (2 receipes per lock);
https://YOUR_DOMAIN.duckdns.org:8123/api/states/input_select.xxxxxx?api_password=YOUR PASSWORD
As a POST with the following body
{âstateâ:âUnlockedâ}
or
{âstateâ:âLockedâ}
OK hopefully that helps someone else get this stuff running on Hass.io (I tried a few times with the component, but I continued to get the 500 errors and couldnât control the locks).
Please note that all of this is down to Bahnburner and gaggle331. All the credit goes to those helpful people, and my many thanks, I have learnt a huge amount about this platform over the last few weeks, and without the help and examples and instructions I would have probably given up.