Skip to main content

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())

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.2.tar.gz (7.3 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.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: terncy-0.4.2.tar.gz
  • Upload date:
  • Size: 7.3 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.2.tar.gz
Algorithm Hash digest
SHA256 194ca05d725a8ff5d216af88ee66a4d5de111fe8c1077c5aac144631b853c26a
MD5 dc88b5c800c3cc695a82fe07232f113a
BLAKE2b-256 320ba21c06d5632eef72748b8a50a97a47cd376b6f447d47dfe2962490da4166

See more details on using hashes here.

File details

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

File metadata

  • Download URL: terncy-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 644ac9c0ff240402f0286a335ec60734b434736da53d20af8055032d897037f1
MD5 03601e8bf80bb991d564f9ce18e7ff31
BLAKE2b-256 7efff0ab33e6ca337868baf681f2b7b902ee365dc9fda0224412a0020522a496

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 files

0.4.1

2 files

0.4.0

2 files

0.3.9

1 file

0.3.8

1 file

0.3.7

1 file

0.3.6

1 file

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page