Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9a99982
Showing
6 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.pyc | ||
/konnected/__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
MIT License | ||
Copyright (c) 2018 Konnected Inc | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## Konnected Python library | ||
|
||
This is a simple Python library to talk to a Konnected device. Konnected is an open-source software for ESP8266 devices | ||
that enables simple wired binary sensors and actuators to talk to home automation frameworks such as Home Assistant and | ||
SmartThings. The most popular use case for Konnected is to connected a wired home alarm system to your Smart Home hub. | ||
|
||
This library was written to support Home Assistant integration. | ||
|
||
For more information see [konnected.io](https://konnected.io) | ||
|
||
## Usage | ||
|
||
``` | ||
>>> import konnected | ||
|
||
''' initialize the Konnected client with a host and port ''' | ||
>>> k = konnected.Client('192.168.86.10', '17000') | ||
|
||
|
||
''' sync settings to the device | ||
k.put_settings([{"pin":1}],[],'secureToken','http://example.com') | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
''' Python library for interacting with Konnected devices ''' | ||
''' learn more at konnected.io ''' | ||
|
||
__author__ = 'Nate Clark, Konnected Inc <help@konnected.io>' | ||
|
||
import requests | ||
import json | ||
import os | ||
|
||
from requests.exceptions import RequestException; | ||
|
||
class Client(object): | ||
|
||
def __init__(self, host, port): | ||
self.host = host | ||
self.port = port | ||
self.base_url = 'http://' + host + ':' + port | ||
|
||
def put_settings(self, sensors, actuators, auth_token, endpoint): | ||
''' Sync settings to the Konnected device ''' | ||
url = self.base_url + '/settings' | ||
|
||
payload = { | ||
"sensors": sensors, | ||
"actuators": actuators, | ||
"token": auth_token, | ||
"apiUrl": endpoint | ||
} | ||
|
||
r = requests.put(url, json=payload, timeout = 30) | ||
|
||
return r.ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import sys | ||
|
||
if sys.argv[-1] == 'publish': | ||
os.system('python setup.py sdist upload') | ||
sys.exit() | ||
|
||
try: | ||
from setuptools import setup | ||
except ImportError: | ||
from distutils.core import setup | ||
|
||
license = """ | ||
MIT License | ||
Copyright (c) 2017 Konnected Inc | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
""" | ||
|
||
setup( | ||
name='konnected-py', | ||
version='0.1', | ||
packages=['konnected',], | ||
url='https://github.com/konnected-io/konnected-py', | ||
license=license, | ||
description='A Python library for interacting with Konnected home automation devices (see https://konnected.io)', | ||
author='Nate Clark, Konnected Inc', | ||
author_email='help@konnected.io', | ||
install_requires=['requests>=2.0'] | ||
) |