Skip to main content

Proxmox Home Assistant Integration Service for Home Assistant.

Project description

Proxmox Home Assistant Integration Service

An asynchronous, type-safe Python client tailored for extracting raw performance telemetry out of Proxmox VE clusters, nodes, and guests.

The Backstory: Why "PHAIS"?

PHAISE stands for Proxmox Home Assistant Integration Service.

But there is an intentional double meaning here: it is hopefully just a PHASE.

This library was built out of necessity because existing ecosystem integrations and underlying client libraries have structural limitations—whether they are synchronous bottlenecks, missing granular unnested endpoint layouts, or lacking strict runtime type enforcement via tools like Mashumaro. PHAIS serves as our high-performance bridge today while we wait for mainstream upstream libraries to catch up, open up, or accept modern async paradigms. Once they do, this phase can comfortably conclude.

Features

  • Strict Asynchronous Execution: Native aiohttp implementation designed never to block the event loop.
  • Unified REST Client: Centralized HTTP architecture managing internal auth tickets, cookie construction, and CSRF token propagation seamlessly.
  • Granular Telemetry Models: Distinct dataclasses separating cluster maps from deep host (NodeStatus), VM (QemuStatus), and container (LXCStatus) sensor profiles.
  • Smart Reconciliation: Automated cache pruning to instantly evict vanished or decommissioned resources from tracking tables using fast set operations.

Usage

The library provides a modern, fluent interface built on asyncio and aiohttp, designed to mirror the structure of the Proxmox VE API while maintaining strict type safety via dataclasses.

Instead of passing endpoints via string formatting or multi-level item lookups, phais exposes clean, chainable proxy paths. All data responses are fully validated dataclass objects rather than raw nested dictionaries.

import asyncio
import aiohttp
import phais

async def main():
    async with aiohttp.ClientSession() as session:
        # Initialize the type-safe client backend
        pve = phais.Backend(
            session=session,
            host="192.168.1.100",
            user="root@pam",
            password="your_secure_password",
            verify_ssl=False
        )

        cluster = await pve.connect()
        print(f"Connected to cluster with: {len(cluster.resources)} resources")

        lxc_status = await pve.nodes("pvex").lxc(501).status.current()
        print(f"Container Memory: {lxc_status.mem} bytes")

        cluster_resources = await pve.cluster.resources()
        print(f"Total cluster resources tracked: {len(cluster_resources.resources)}")

        node_status = await pve.nodes("pvex").status()
        print(f"Node CPU usage: {node_status.cpu * 100}%")

        vm_status = await pve.nodes("pvex").qemu(102).status.current()
        print(f"VM {vm_status.name} Status: {vm_status.status}")


if __name__ == "__main__":
    asyncio.run(main())

Contrast from Proxmoxer

Feature proxmoxer (Generic String Wrapper) phais (Type-Safe Telemetry Client)
I/O Strategy Synchronous (blocks the event loop) Native Asynchronous (aiohttp)
Path Navigation Verbatim endpoint strings / properties Fluid, chainable proxy paths
Terminal Calls Explicit method tags required (.get()) Direct execution or explicit telemetry targets
Data Format Untyped primitives (dict / list) Validated Mashumaro Dataclasses
from proxmoxer import ProxmoxAPI

# Initialize synchronous client
proxmox = ProxmoxAPI(
    "192.168.1.100",
    user="root@pam",
    password="your_secure_password",
    verify_ssl=False
)

# 1. Fetch cluster resources (returns raw lists of dicts)
resources = proxmox.cluster.resources.get()
print(f"Total cluster resources tracked: {len(resources)}")

# 2. Fetch specific physical node status
node_status = proxmox.nodes("pvex").status.get()
print(f"Node CPU usage: {node_status.get('cpu', 0) * 100}%")

# 3. Fetch QEMU VM status
vm_status = proxmox.nodes("pvex").qemu(102).status.current.get()
print(f"VM Status: {vm_status.get('status')}")

# 4. Fetch LXC container status
lxc_status = proxmox.nodes("pvex").lxc(501).status.current.get()
print(f"Container Memory: {lxc_status.get('mem')} bytes")

Development Diagnostics

The repository provides a diagnostic CLI utility to verify authentication mechanics, cookie/ticket attachment, and data serialization against live systems.

Running the Live Test Script

Execute the script from the root directory by providing your targeted cluster parameters:

scripts/live_test.py <host-ip-or-fqdn> "<user@realm>" "<password>"

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

phais-0.0.1a4.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

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

phais-0.0.1a4-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file phais-0.0.1a4.tar.gz.

File metadata

  • Download URL: phais-0.0.1a4.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for phais-0.0.1a4.tar.gz
Algorithm Hash digest
SHA256 3fc3c26a7d2edb3dccb88c1282018b23d8e44844575fddeaed03035147504b5d
MD5 c9b46c9dee7f27a6506d5c3b1a28c671
BLAKE2b-256 d349170ea3cfabfcc30c5cb15c74cb05d6e1b7d3ec1db310fcedfd7463f74ad8

See more details on using hashes here.

Provenance

The following attestation bundles were made for phais-0.0.1a4.tar.gz:

Publisher: release.yml on CoMPaTech/python-phais

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

File details

Details for the file phais-0.0.1a4-py3-none-any.whl.

File metadata

  • Download URL: phais-0.0.1a4-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for phais-0.0.1a4-py3-none-any.whl
Algorithm Hash digest
SHA256 5c8c289b1677429ceedb38dfaca9b7947efa3637eab5a50a765c93d81cc5aeea
MD5 16a14429b1afd614059393f1008f70a6
BLAKE2b-256 0182c7cf4d51fd65b827688caf0ff239cfbf212913bfcf03f247f54940e7c2f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for phais-0.0.1a4-py3-none-any.whl:

Publisher: release.yml on CoMPaTech/python-phais

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