Skip to main content

Interact with and control Vantage InFusion home automation controllers.

Project description

aiovantage

aiovantage is a Python library for interacting with and controlling Vantage InFusion home automation controllers.

Uses a controller pattern inspired heavily by the aiohue library.

This open-source, non-commercial library is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Vantage, and is provided for interoperability purposes only.

Table of contents

Example

from aiovantage import Vantage

async with Vantage("192.168.1.2", "username", "password") as vantage:
    async for load in vantage.loads:
        print(f"{load.name} is at {load.level}%")

See the examples folder for more examples.

Features

  • Uses Python asyncio for non-blocking I/O.
  • Exposes "controllers" to make fetching and controlling various objects easy.
  • Uses SSL connections by default, with automatic reconnection.
  • Fetch objects lazily (with async for obj in controller).
  • Alternatively, eager-fetch objects with controller.initialize.

Supported objects types

The following interfaces/controllers are currently supported.

Type Description Controller Examples
AnemoSensor Wind speed sensors vantage.anemo_sensors Examples
Area Rooms, etc vantage.areas Examples
Blind Shades, blinds vantage.blinds Examples
BlindGroups Groups of blinds vantage.blind_groups Examples
Buttons Keypad buttons vantage.buttons Examples
DryContacts Motion sensors, etc vantage.dry_contacts Examples
GMem Vantage variables vantage.gmem Examples
LightSensor Light sensors vantage.light_sensors Examples
Load Lights, relays, etc vantage.loads Examples
LoadGroup Groups of loads vantage.load_groups Examples
OmniSensor Power, current, etc vantage.omni_sensors Examples
RGBLoad RGB lights vantage.rgb_loads Examples
Stations Keypads, etc vantage.stations Examples
Tasks Vantage tasks vantage.tasks Examples
Temperature Temperature sensors vantage.temperature_sensors Examples

If you have an object that you expect to show up in one of these controllers, but it is missing, please let me know in an issue.

Installation

Add aiovantage as a dependency to your project, or install it directly:

pip install aiovantage

Usage

Creating a client

Begin by importing the Vantage class:

from aiovantage import Vantage

The most convenient way to create a client is by using the async context manager:

async with Vantage("hostname", "username", "password") as vantage:
    # ...use the vantage client

Alternatively, you can manage the lifecycle of the client yourself:

from aiovantage import Vantage

vantage = Vantage("hostname", "username", "password")
# ...use the vantage client
vantage.close()

Querying objects

The Vantage class exposes a number of controllers, which can be used to query objects. Controllers can either be populated lazily (by using async for), or eagerly (by using controller.initialize()).

For example, to get a list of all loads:

async with Vantage("hostname", "username", "password") as vantage:
    async for load in vantage.loads:
        print(f"{load.name} is at {load.level}%")

Alternatively, you can use controller.initialize() to eagerly fetch all objects:

async with Vantage("hostname", "username", "password") as vantage:
    await vantage.loads.initialize()
    for load in vantage.loads:
        print(f"{load.name} is at {load.level}%")

If you aren't interested in the state of the objects, you can call controller.initialize(fetch_state=False) to slightly speed up the initialization:

async with Vantage("hostname", "username", "password") as vantage:
    await vantage.loads.initialize(fetch_state=False)
    for load in vantage.loads:
        print(f"{load.name}")

All controllers implement a django-like query interface, which can be used to filter objects. You can either query by matching attributes:

async with Vantage("hostname", "username", "password") as vantage:
    async for load in vantage.loads.filter(name="Kitchen"):
        print(f"{load.name} is at {load.level}%")

Or by using a filter predicate:

async with Vantage("hostname", "username", "password") as vantage:
    async for load in vantage.loads.filter(lambda load: load.level > 50):
        print(f"{load.name} is at {load.level}%")

Fetching a single object

You can fetch a single object by id, by calling controller.aget() or controller.get():

async with Vantage("hostname", "username", "password") as vantage:
    load = await vantage.loads.aget(118)
    print(f"{load.name} is at {load.level}%")

These functions also implement the same query interface as controller.filter() for querying by attributes or filter predicate:

async with Vantage("hostname", "username", "password") as vantage:
    load = await vantage.loads.aget(name="Kitchen")
    print(f"{load.name} is at {load.level}%")

Controlling objects

Most controllers expose a various methods for controlling the state of objects. The first parameter to these methods is always the vantage id of the object to control.

For example, to turn on a load:

async with Vantage("hostname", "username", "password") as vantage:
    await vantage.loads.turn_on(118)

Subscribing to state changes

You can subscribe to state changes by using the controller.subscribe() method:

def on_load_state_change(event, load, data):
    print(f"{load.name} is at {load.level}%")

async with Vantage("hostname", "username", "password") as vantage:
    vantage.loads.subscribe(on_load_state_change)
    await vantage.loads.initialize()

Note that a subscription will only receive state changes for objects that have populated into the controller.

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

aiovantage-0.7.0.tar.gz (47.9 kB view details)

Uploaded Source

Built Distribution

aiovantage-0.7.0-py3-none-any.whl (78.2 kB view details)

Uploaded Python 3

File details

Details for the file aiovantage-0.7.0.tar.gz.

File metadata

  • Download URL: aiovantage-0.7.0.tar.gz
  • Upload date:
  • Size: 47.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for aiovantage-0.7.0.tar.gz
Algorithm Hash digest
SHA256 884b7a9a741359c7992944f4dc0146cb5097ab9b455d3aae88e59590eab66cf7
MD5 3ff1d21fb95ee39bee042fd6f7ab7021
BLAKE2b-256 920702bebdf9fda76f14ad8eb277b805d4bf54eccc0522b4465b8350eb43755e

See more details on using hashes here.

File details

Details for the file aiovantage-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: aiovantage-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 78.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for aiovantage-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f03fc52974c4d0d7f98371915204f4cf268043199b35d5bbb7f117022b43af90
MD5 c8662a5e6ef74a20dcce457760f4b79f
BLAKE2b-256 ce119279de2852056d3983ddcd6928652d72ed64fdfaa366ea57bfca1e770d67

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page