Skip to main content

A Python library for controlling Terncy home automation system.

Project description

python-terncy

A python library for control Terncy devices.

PyPI version Build Status

Installation

pip install terncy

Introduction

Before use this library, developer need to get a client id from terncy. The client id is a string that uniquely identifies the client app connectes to Terncy system. For istance, Home Assistant integration has its own client id. By presenting a valid client id to Terncy, it's allowed to access the system.

In addition, an access credential is also needed to make sure the owner of the Terncy system is aware of, and permit the client access. The approval of the access credential is done in Terncy app by the owner.

Example:

import asyncio
import terncy


def event_hander(t, msg):
    print("got event", msg)


async def main():
    await terncy.start_discovery()
    await asyncio.sleep(2)
    await terncy.start_discovery()
    print(terncy.discovered_homecenters)

    # construct a Terncy object from discovered info
    t = terncy.Terncy(
        "client_id",
        "box-12-34-56-78-90-ab",
        "192.168.1.187",
        443,
        "homeassistant_user",
        "",
    )
    token_id, token = await t.request_token("homeassistant_user", "HA User")

    # approve the token request in Terncy app, the client should store the
    # allocated token and token id for later usage
    
    # create a new Terncy object with approved token
    t.token = token
    t.token_id = token_id
    t.register_event_handler(event_hander)
    await t.start()
    t.set_onoff("devid_of_device", 1)

    attributes = [{"attr":"on", "value":1}, {"attr":"brightness", "value":42}]
    t.set_attributes("devid_of_device", attributes) 


loop = asyncio.get_event_loop()
loop.run_until_complete(main())

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

terncy-0.4.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terncy-0.4.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file terncy-0.4.1.tar.gz.

File metadata

  • Download URL: terncy-0.4.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for terncy-0.4.1.tar.gz
Algorithm Hash digest
SHA256 cc16b76784fbdc125859ef140fc0d5421d7e2223aaec338759708ff785e50ded
MD5 c18359bf2fcfbb45bfe51844aa76171c
BLAKE2b-256 3a8c555e5270fbee64672c8492f717d2915775e6977993000c4ff0c6439e4a44

See more details on using hashes here.

File details

Details for the file terncy-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: terncy-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for terncy-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 173ea3074026d609205a736aba0140076a6a4c0ce4c7c048f1fdb16ba7749413
MD5 c2b03b28813fbf68af9f3073a2150ec2
BLAKE2b-256 b16ebcf0b74cce7ea602260cc6c333af11271944834c761061908428b7880b3e

See more details on using hashes here.

Supported by

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