Skip to main content

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

aioketraapi-0.1.12.tar.gz (55.7 kB view details)

Uploaded Source

Built Distribution

aioketraapi-0.1.12-py3-none-any.whl (103.6 kB view details)

Uploaded Python 3

File details

Details for the file aioketraapi-0.1.12.tar.gz.

File metadata

  • Download URL: aioketraapi-0.1.12.tar.gz
  • Upload date:
  • Size: 55.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for aioketraapi-0.1.12.tar.gz
Algorithm Hash digest
SHA256 89ed545a0a40e3e2a1dcd0f9d3861684d43c382ddf2a31b68cff69e354d52a4c
MD5 bfbf56f60b51b9b5e8e43c0104b8764e
BLAKE2b-256 61b393384bd453682a90499498ee22ffff22d53aedf360be8bad71ce25b5b170

See more details on using hashes here.

File details

Details for the file aioketraapi-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: aioketraapi-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 103.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for aioketraapi-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 ec6a1c6d24523890f8987c016dad354e2202479be2574a9014c173ae592a86e1
MD5 ff9018cfa659823926b1f489ce974ba3
BLAKE2b-256 4eb6a2aea7731752c19f3a67950af0f9d3ca93c6f69c2f0cf68616dc71bc13f4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page