Skip to main content

Python package encapsulating Vitrea box communication protocol.

Project description

Vitrea

Python package encapsulating the simple Vitrea box communication protocol. You need to identify the VBox fixed IP address and port to use this package. The VBox usually listens to 3 ports, one of them is used by the Vitrea application, another is used for admin purposes, and the third one is used for communication with external systems such as this package.

Installation

pip install vitreaclient

Usage

from vitreaclient.client import VitreaClient, VitreaResponse, DeviceStatus
import asyncio


async def vitrea_test():
    client = VitreaClient(host='192.168.1.100', port=11111)

    status_events = []
    def on_status(event):
        print(f"Event type: {event.type}, Node: {event.node}, Key: {event.key}, Status: {event.status}, data: {event.data}")
        status_events.append(event)

    client.on(VitreaResponse.STATUS, on_status)

    def on_ok(event):
        print(f"Event type {event.type}")

    client.on(VitreaResponse.OK, on_ok)

    # connect and start the read task to listen for incoming messages
    await client.connect()

    await client.key_off("018", "2")  # Example command to turn on a key
    await asyncio.sleep(2)
    await client.key_on("018", "2")  # Example command to turn off a key

    # get the status of all nodes
    await client.status_request()

    await asyncio.sleep(60)  # Give time for response
    print(f"Status events received: {len(status_events)}")
    # unsubscribe from events
    client.off(VitreaResponse.STATUS, on_status)
    client.off(VitreaResponse.OK, on_ok)
    
    client.disconnect()

License

See 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

vitreaclient-0.2.0.tar.gz (54.5 kB view details)

Uploaded Source

Built Distribution

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

vitreaclient-0.2.0-py3-none-any.whl (44.5 kB view details)

Uploaded Python 3

File details

Details for the file vitreaclient-0.2.0.tar.gz.

File metadata

  • Download URL: vitreaclient-0.2.0.tar.gz
  • Upload date:
  • Size: 54.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for vitreaclient-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1b84be762c115d7ccc3dcd5c9734538087d6825848956b50c259d469b8fd01fb
MD5 5c579816447071f57b5bad5021e47fbf
BLAKE2b-256 75f8aba11b4d6fc3dd5a1797f60e9d4774b1a6e17ff111664527577d6cb24db3

See more details on using hashes here.

File details

Details for the file vitreaclient-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vitreaclient-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 44.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for vitreaclient-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f619d4595f866930349e80b756d9866d7c5804cc08c3ab51da0d7f3b978b2529
MD5 26750afd61ebbb976ff61f85a6ce4319
BLAKE2b-256 3fcaed3a6acfb764ff089c9ac2ffa672034178f090e951b22478fb901d7bed6e

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