Skip to main content

Python library for controlling Vitrea Smart Home Controllers via TCP

Project description

vitrea-host

Python library for controlling Vitrea Smart Home Controllers via TCP.

This library provides an Async Python interface to communicate with Vitrea VBox controllers over TCP/IP, enabling control of lights, blinds, thermostats, fans, scenarios, and other smart home devices.

Features

  • Asynchronous API: Built on asyncio for efficient concurrent operations
  • Device Control: Control lights (dimmers), blinds, thermostats, fans, and more
  • Database Reading: Read and parse the Vitrea controller's device database
  • Status Updates: Real-time status updates via callbacks
  • Connection Management: Automatic reconnection and health monitoring
  • Multiple API Versions: Supports Vitrea Parameter API v1, v2, and v3

Installation

From PyPI

pip install vitrea-host

From Source

git clone https://github.com/vitrea-sh/py-vitrea-host.git
cd py-vitrea-host
pip install -e .

Requirements

  • Python 3.8 or higher
  • Network access to the Vitrea controller

Quick Start

import asyncio
from vitrea_host import VBoxController

async def main():
    # Create a controller instance
    controller = VBoxController(
        ip="192.168.1.100",
        port=5000,
        status_update_callback=handle_status_update
    )
    
    # Connect and load database
    await controller.connect()
    
    # Access devices through the database
    for floor in controller.database.floors:
        for room in floor.rooms:
            for key in room.keys:
                print(f"Device: {key.name} in {room.name}")
    
    # Close connection
    await controller.close()

async def handle_status_update(update):
    print(f"Status update: {update}")

asyncio.run(main())

Usage

Basic Connection

from vitrea_host import VBoxController, validate_controller_availability

# Validate controller is available
result = await validate_controller_availability("192.168.1.100", 5000)
if result["supported"]:
    print(f"Controller version: {result['version']}")
    
    # Create and connect
    controller = VBoxController(ip="192.168.1.100", port=5000)
    await controller.connect()

Status Updates

async def status_callback(update):
    if update.get("type") == "node_status":
        node_id = update.get("node_id")
        key_id = update.get("key")
        status = update.get("status")
        print(f"Node {node_id}, Key {key_id}: {status}")

controller = VBoxController(
    ip="192.168.1.100",
    port=5000,
    status_update_callback=status_callback
)

Home Assistant Integration

This library is used by the Home Assistant Vitrea Integration.

To use this library in your Home Assistant integration:

# In your Home Assistant integration
from vitrea_host import VBoxController

# The integration will handle the connection and device management

API Reference

Main Classes

  • VBoxController: Main controller class for managing connections and devices
  • VBoxConnection: Low-level TCP connection management
  • VitreaDatabaseModel: Database model containing floors, rooms, keys, and devices

Functions

  • authenticate_vitrea_device(host, port): Authenticate to a Vitrea controller
  • validate_controller_availability(ip, port): Check if controller is available and supported

Development

Setup Development Environment

git clone https://github.com/vitrea-sh/py-vitrea-host.git
cd py-vitrea-host
pip install -e ".[dev]"

Running Tests

pytest

License

Apache-2.0 License. See LICENSE file for details.

Support

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

vitrea_host-0.2.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

vitrea_host-0.2.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file vitrea_host-0.2.1.tar.gz.

File metadata

  • Download URL: vitrea_host-0.2.1.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for vitrea_host-0.2.1.tar.gz
Algorithm Hash digest
SHA256 db2725f1432a144f4b883fc5b3ea986bacbda34e871cd31675c5859ed9b51972
MD5 b72f5714f054b6dbb2a1fe20d0bd6b88
BLAKE2b-256 8ddbdaff70623c3d521c75621deb5753fc93335f15b4d324a70f1847b34c06ef

See more details on using hashes here.

File details

Details for the file vitrea_host-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: vitrea_host-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for vitrea_host-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f091c6beadadc0519544bd5824a7b792c0ebf63a7abe356dc1ed856257ee96d
MD5 dec3dd43542294de2d7986109f35179e
BLAKE2b-256 8aaa8c4e9e4d483b0be900a6e8405619e73f0020897408d122f6a049a41fea5a

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