New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aiovantage

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aiovantage

Interact with and control Vantage InFusion home automation controllers.

  • 0.22.3
  • Source
  • PyPI
  • Socket score

Maintainers
1

aiovantage

Documentation PyPI - Version Discord

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

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.

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

  • Fetch object configuration from your Vantage system.
  • Fetch object state and subscribe to state changes (e.g. load levels, sensor readings).
  • Control devices (turn on lights, set thermostats, etc).
  • Uses asyncio for non-blocking I/O.
  • Uses SSL connections by default, with automatic reconnection.
  • Supports both lazy and eager object fetching.

Installation

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

pip install aiovantage

Supported objects

The following interfaces/controllers are currently supported.

TypeDescriptionController
AnemoSensorWind speed sensorsvantage.anemo_sensors
AreaRooms, etcvantage.areas
BackBoxBackboxesvantage.back_boxes
BlindShades, blindsvantage.blinds
BlindGroupsGroups of blindsvantage.blind_groups
ButtonsKeypad buttonsvantage.buttons
DryContactsMotion sensors, etcvantage.dry_contacts
GMemVantage variablesvantage.gmem
LightSensorLight sensorsvantage.light_sensors
LoadLights, relays, etcvantage.loads
LoadGroupGroups of loadsvantage.load_groups
MasterVantage controllersvantage.masters
ModuleDimmer modulesvantage.modules
OmniSensorPower, current, etcvantage.omni_sensors
PortDevicePort devices (hubs)vantage.port_devices
PowerProfileLoad power profilesvantage.power_profiles
RGBLoadRGB lightsvantage.rgb_loads
StationsKeypads, etcvantage.stations
TasksVantage tasksvantage.tasks
TemperatureTemperature sensorsvantage.temperatures
ThermostatThermostatsvantage.thermostats

If you have an object that you expect to show up in one of these controllers but is missing, please create an issue or submit a pull request.

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

Objects also expose various methods for controlling state. For example, to turn on a load:

async with Vantage("hostname", "username", "password") as vantage:
    load = vantage.loads.aget(name="Study Lights")
    await load.turn_on()

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.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc