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.
Metadata
Release files for aioketraapi 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aioketraapi-0.1.12.tar.gz | 55.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aioketraapi-0.1.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 159.3 kB
Release files / aioketraapi-0.1.12.tar.gz
| Download URL | aioketraapi-0.1.12.tar.gz |
|---|---|
| Size | 55.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89ed545a0a40e3e2a1dcd0f9d3861684d43c382ddf2a31b68cff69e354d52a4c
|
|
BLAKE2b-256 checksum How to use checksums |
61b393384bd453682a90499498ee22ffff22d53aedf360be8bad71ce25b5b170
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / aioketraapi-0.1.12-py3-none-any.whl
| Download URL | aioketraapi-0.1.12-py3-none-any.whl |
|---|---|
| Size | 103.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec6a1c6d24523890f8987c016dad354e2202479be2574a9014c173ae592a86e1
|
|
BLAKE2b-256 checksum How to use checksums |
4eb6a2aea7731752c19f3a67950af0f9d3ca93c6f69c2f0cf68616dc71bc13f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|