Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebridge integration? #19

Open
dikodahan opened this issue May 7, 2019 · 3 comments
Open

Homebridge integration? #19

dikodahan opened this issue May 7, 2019 · 3 comments

Comments

@dikodahan
Copy link

Hi,
I was wondering if you might have looked at providing this as a Homebridge plugin as well?
Though the August lock is compatible with Apple Homekit, it is only the lock/unlock functionality. The door ajar sensor is not, as well as the doorbell. Using this with Homebridge would complement the existing integration.

Thoughts??

@snjoetw
Copy link
Owner

snjoetw commented Jul 12, 2019

As far as I know Homebridge is JS based not sure how this python lib can be integrated

@snjoetw
Copy link
Owner

snjoetw commented Jul 12, 2019

Do you use HomeAssistant? If so you can expose HomeAssistant devices to HomeKit without running Homebrdige in between

@Jefronty
Copy link

Jefronty commented Oct 7, 2019

I've added this to my homebridge via the homebridge-http plugin. I have it point to a raspberry pi, which has a DHCP reservation, on my network for status, lock, and unlock URLs. The Rpi hosts a web server and the python script. I wrote the script to return a tuple of the open/closed and locked/unlocked status by default, but unlock, lock, or return locked status as 1 or 0 depending on the argument passed. The web server (nodeJS in my case) calls the python script with an argument depending on the URL path requested.
the relevant Homebridge configuration looks like:

{
 	"accessory": "Http",
 	"name": "August Lock",
 	"switchHandling": "realtime",
 	"http_method": "GET",
 	"on_url":      "http://192.168.10.100/lock",
 	"off_url":     "http://192.168.10.100/unlock",
 	"status_url":  "http://192.168.10.100/door",
 	"brightnessHandling": "no",
 	"sendimmediately": "",
 	"username" : "optional",
 	"password" : "basic_auth"
 }

and the python script looks like:

#!/usr/bin/python

import os, sys
from august.api import Api

tkn_file = 'PATH_TO_FILE_WHERE_TOKEN_STRING_IS_SAVED'
lock_id = 'august_id_of_specific_lock_being_controlled'
api = Api(timeout=20)

if os.path.isfile(tkn_file):
	r = open( tkn_file, 'r')
	token = r.read()
	r.close()
else:
	print "must sign-in and authenticate"
	print "this script doesn't handle authentication"
	sys.exit()


def lock_status( id ):
	return api.get_lock_door_status(token, id, True)


def unlock( id, status ):
	if status[1] == 'locked':
		return api.unlock( token, id )
	else:
		return status[1]

def lock( id, status ):
	if status[1] != 'locked':
		return api.lock( token, id )
	else:
		return status[1]

if not token:
	sys.exit()
elif not lock_id:
	# if lock_id isn't hard coded, get the first lock from "My House"
	houses = api.get_houses( token )
	for house in houses:
		if house['type'] == 'superuser':
			house_id = house['HouseID']
			break
	house_info = api.get_house( token, house_id )
	lock_id = house_info['locks'].keys()[0]
else:
	status = lock_status( lock_id )
	try:
		arg = sys.argv[1].lower()
	except:
		arg = ''
	if arg == 'lock':
		print lock( lock_id, status )
	elif arg == 'unlock' or arg == 'open':
		print unlock( lock_id, status )
	elif arg != '':
		is_locked = status[1] == 'locked'
		print int( is_locked )
	else:
		print status

This is a total kludge, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants