Skip to main content

Python package for simple access to Ngenic Tune API.

Project description

Ngenic Tune Python API Wrapper

This python package simplifies access to the Ngenic Tune API. It can be used for viewing or edit your Tune configuration.

Both sync and async APIs are provided - async APIs are prefixed with async_.

NOTE: This API wrapper is not yet finished, and only implements a subset of all the APIs. The interface may very well change.

Prerequisite

Obtain an API token

An API token may be obtained here: https://developer.ngenic.se/

Installation

$ pip install ngenicpy

Example

import json

from ngenicpy import Ngenic

# try/finally
try:
    ngenic = Ngenic(token="YOUR-API-TOKEN")
except NgenicException as e:
        print(str(e))
finally:
    ngenic.close()

# as context manager
with Ngenic(token="YOUR-API-TOKEN") as ngenic:
    tunes = ngenic.tunes()
    for tune in tunes:
        print("Tune %s\nName: %s\nTune Name: %s" %
                (
                    tune.uuid(),
                    tune["name"],
                    tune["tuneName"]
                )
        )

    tune = ngenic.tune("TUNE-UUID")

    rooms = tune.rooms()
    for room in rooms:
        print("Room %s\nName: %s\nTarget Temperature: %d" %
                (
                    room.uuid(),
                    room["name"],
                    room["targetTemperature"]
                )
        )

    # Update a room
    room = tune.room(room_uuid="ROOM-UUID")
    room["name"] = "Livingroom"
    room.update()

    nodes = tune.nodes()
    for node in nodes:
        node_status = node.status()

        print("Node %s\nType: %s" %
                (
                    node.uuid(),
                    node.get_type()
                )
        )

        if node_status:
            print("Battery: %s\nRadio Signal: %s" %
                    (
                        str(node_status.battery_percentage()),
                        str(node_status.radio_signal_percentage())
                    )
            )

        measurements = node.measurements()
        for measurement in measurements:
            print("%s: %d" %
                    (
                        measurement.get_type(),
                        measurement["value"]
                    )
            )

Async example

import json

from ngenicpy import Ngenic

async with AsyncNgenic(token="YOUR-API-TOKEN") as ngenic:
    tunes = await ngenic.async_tunes()
    for tune in tunes:
        print("Tune %s\nName: %s\nTune Name: %s" %
                (
                    tune.uuid(),
                    tune["name"],
                    tune["tuneName"]
                )
        )

Reference

Ngenic Tune Public API

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

ngenicpy-0.5.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

ngenicpy-0.5.2-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file ngenicpy-0.5.2.tar.gz.

File metadata

  • Download URL: ngenicpy-0.5.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ngenicpy-0.5.2.tar.gz
Algorithm Hash digest
SHA256 0e6cf8e016d3ebacebdb54e8bbfe48a670fd8f628046e0a909076df62d575b77
MD5 38c15af2e7cbb50feb282c64339128ca
BLAKE2b-256 07ecf44efc376a31ddc4dc01a49cdb5aa5109709564d928a5860de8da770f357

See more details on using hashes here.

Provenance

The following attestation bundles were made for ngenicpy-0.5.2.tar.gz:

Publisher: publish.yml on dotnetdummy/ngenicpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ngenicpy-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: ngenicpy-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ngenicpy-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8af8925489eb3371a2122ecfa4ca8a1a9087f8a79f31a9efd5e8800a6f4f18f0
MD5 f3c0afa43af35cd8bf9a8d4598c0279b
BLAKE2b-256 0fac115e7be0ad203afa5d9a8a7e78782ed1c34b611c09d34560db5abe20c45d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ngenicpy-0.5.2-py3-none-any.whl:

Publisher: publish.yml on dotnetdummy/ngenicpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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