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 Vitrea box IP address and port to use this package. Note that the port is not necessarily the port used by the Vitrea app (hint: try +/- 1).

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=11102)

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

    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.1.8.tar.gz (28.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.1.8-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vitreaclient-0.1.8.tar.gz
  • Upload date:
  • Size: 28.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.1.8.tar.gz
Algorithm Hash digest
SHA256 5192d28b05e5fc837ff6613e7b6f28820061382ceeed4872c6c90ea6fb55c2f0
MD5 dfe0b307da2f91f56bed16bc68dbc9b2
BLAKE2b-256 2828e99c01dcf226e2711e6934c9ec2ba77b116fc44cae2cb9b8e36a7adf3fb6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vitreaclient-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 29.8 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.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4f9b7b77848f37145ffcb99e4aa18611413a389ea87c42f741b909cef5a12186
MD5 94a14caafb60db2c9c975683a31b63f5
BLAKE2b-256 b2653d16ede0204219e3158d257881e8f01d41729eeb9ced479f18d335690244

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