Ketra Lighting API
Project description
aioketraapi
aiohttp-based Python Client SDK for controlling Ketra lighting products. Based on Ketra API documentation available here.
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 1.4.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
Requirements.
Python 3.6+
Installation & Usage
pip install
You can install from pypi using:
pip install aioketraapi
Or, you can install directly from github using:
pip install git+https://github.com/s4v4g3/aio-ketra-api.git
Note that in either case you may need to run pip
with root permission: sudo pip install aioketraapi
or sudo pip install git+https://github.com/s4v4g3/aio-ketra-api.git
Then import the package:
import aioketraapi
Setuptools
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install
to install the package for all users)
Then import the package:
import aioketraapi
Getting Started
In order to use this package you will need to contact Ketra Support and get assigned a client_id and client_secret.
Authentication
You will only need to obtain a single access token for a given user account; at present the access tokens do not expire.
import asyncio
from aioketraapi.oauth import OAuthTokenResponse
async def main():
client_id = 'YOUR CLIENT ID'
client_secret = 'YOUR CLIENT SECRET'
username = '<your Ketra Design Studio username here>'
password = '<your Ketra Design Studio password here>'
oauth_token = await OAuthTokenResponse.request_token(client_id, client_secret, username, password)
access_token = oauth_token.access_token
print(f"My access token is {access_token}")
if __name__ == '__main__':
asyncio.run(main())
Usage
import asyncio
from aioketraapi.n4_hub import N4Hub
from aioketraapi.models.lamp_state import LampState
async def main():
# Find the installation id for your installation by logging into https://my.goketra.com
# and finding your installation in the list and going to the “Details” page for your
# installation. The installation id is displayed in the URL of this page, for example
# a URL of https://my.goketra.com/installations/0fbcada7-b318-4d29-858c1ea3ac1fd5cb
# would indicate an installation id of “0fbcada7-b318-4d29-858c1ea3ac1fd5cb”
installation_id = 'my-installation-id'
# Use the access token received from the authentication step above
access_token = 'access token received from authentication step'
# Set to False to access your installation directly through your local network,
# set to True to access your installation through the cloud (requires remote access
# to be enabled in Design Studio for the installation)
use_cloud = False
hub = await N4Hub.get_hub(installation_id,
access_token,
use_cloud=use_cloud)
# get the keypads in the installation and print all button names
keypads = await hub.get_keypads()
for keypad in keypads:
for button in keypad.buttons:
print(button.scene_name)
# activate the "Natural" button on the "Kitchen" keypad
if button.scene_name == "Kitchen Natural":
await button.activate()
# get the groups in the installation and print all group names
groups = await hub.get_groups()
for group in groups:
print(group.name)
# Control the "Office" group
if group.name == "Office":
await group.set_state(LampState(transition_time=13000, cct=2000, brightness=0.95, power_on=True))
if __name__ == '__main__':
asyncio.run(main())
License
The library is available as open source under the terms of the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aioketraapi-0.1.10.tar.gz
.
File metadata
- Download URL: aioketraapi-0.1.10.tar.gz
- Upload date:
- Size: 55.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55441eb4b755ae1873cd2cfce20836d3556563ffb0717b76d1004f01dd1cdc69 |
|
MD5 | e28b2c44b89485aa9535b071c0932cf6 |
|
BLAKE2b-256 | 0d6b9783cad1142f7dc548c2b1bc330e852d7cdbc6a8950510f1576b78732e2c |
Provenance
File details
Details for the file aioketraapi-0.1.10-py3-none-any.whl
.
File metadata
- Download URL: aioketraapi-0.1.10-py3-none-any.whl
- Upload date:
- Size: 103.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5204746074a40ada6a4324953ce8c1384f3ded25692b7642c812e812ff93c8d |
|
MD5 | 6e4884cca3db62636db0355d0949500d |
|
BLAKE2b-256 | 396cc656383f46ba19157f35990c5a42c2383435d5d05c54365b68386c1be1ad |