Skip to main content

vivintpy

PyPI - Version Buy Me A Coffee/Beer Sponsor on GitHub

GitHub License PyPI - Python Version Pepy Total Downloads PyPI - Downloads

Python library for interacting with a Vivint security and smart home system.

This was built to support the Vivint for Home Assistant integration but should work outside of it too. Currently, it can be utilized via HACS and is available as a default integration.

Credit

This was inspired by the great work done by Mike Reibard to reverse engineer the Vivint Sky API and Ovidiu Stateina for the repository from which this is forked and expanded on.

Features

It currently has support for the following device types:

  • alarm panels
  • cameras
  • door locks
  • garage doors
  • switches
    • binary
    • multilevel
  • thermostats
  • wireless sensors
    • carbon monoxide
    • door/window
    • flood
    • glass break
    • motion
    • smoke/fire
    • etc

In addition, it integrates with PubNub to receive real-time updates for devices. This subscription stops receiving notifications around 15-20 minutes unless a call is made to the Vivint Sky API periodically. This might be related to the cookie expiration since it expires 20 minutes after the last API call was received. If another client connects, however, the notifications start to stream again for all currently connected clients.

Installation

Requires Python 3.11 or newer.

pip install vivintpy

Usage

The library is asynchronous. Everything starts from an Account, which holds your systems, and each system has its alarm panels and their devices.

import asyncio

from vivintpy.account import Account
from vivintpy.entity import UPDATE
from vivintpy.exceptions import VivintSkyApiMfaRequiredError


def on_panel_update(event: dict) -> None:
    panel = event["device"]
    print(panel.state.name, panel.changed_by)


async def main() -> None:
    account = Account(username="you@example.com")

    try:
        try:
            await account.connect(
                load_devices=True,
                subscribe_for_realtime_updates=True,
                password="your-password",
            )
        except VivintSkyApiMfaRequiredError:
            await account.verify_mfa(input("Enter MFA code: "))

        for system in account.systems:
            for panel in system.alarm_panels:
                print(f"{panel.name}: {panel.state.name}")

                for device in panel.devices:
                    print(f"  {device.name} ({type(device).__name__})")

                panel.on(UPDATE, on_panel_update)

        while True:
            await asyncio.sleep(300)
            await account.refresh()
    finally:
        await account.disconnect()


asyncio.run(main())

Controlling devices

Each device type has its own methods. For example, an alarm panel:

await panel.arm_stay()
await panel.arm_away()
await panel.disarm()

Listening for changes

on registers a callback for an event and returns a function that removes it. Every device has UPDATE, and some have their own events:

from vivintpy.devices.camera import MOTION_DETECTED

remove_listener = camera.on(MOTION_DETECTED, lambda event: print(event["device"]))

AlarmPanel.changed_by reports what last armed or disarmed a panel, such as a user's name, panel or a rule. It is None until the first change after connecting. It can arrive just before or just after the panel's state changes, so an update can briefly show the previous value. UPDATE also fires on refreshes, when nothing may have changed.

Staying logged in

The password you pass to connect is only used to log in, and vivintpy doesn't keep it. Save the refresh token from that first login, then use it to log in next time:

def save_token(token: str) -> None:
    """Store the token somewhere safe."""


# the first time
account = Account(username="you@example.com", on_refresh_token_changed=save_token)
await account.connect(password="your-password")

# after that
account = Account(
    username="you@example.com",
    refresh_token=saved_token,
    on_refresh_token_changed=save_token,
)
await account.connect()

Vivint's refresh tokens can only be used once. Each refresh returns a new one, and using an old one fails and also invalidates the newest one. So save every new token as soon as on_refresh_token_changed provides it, and don't share a token between running instances.

Passing password to Account still works, and it's kept so that vivintpy can log in with it again, but it's deprecated and will be removed in 2027.1.0.

Errors

Errors from vivintpy inherit from VivintError, in vivintpy.exceptions. Network problems can also raise aiohttp errors and TimeoutError, so catch those too if your program should keep running. VivintSkyApiAuthenticationError means Vivint rejected the login, and VivintSkyApiMfaRequiredError means a code is needed. Pass that code to verify_mfa.

Account.refresh raises VivintSkyApiAuthenticationError if the session can't be renewed or no user data comes back. That usually means Vivint rejected the refresh token, so log in again with await account.connect(password="your-password"), which can also ask for an MFA code. Do this before calling disconnect, which closes the session, or afterward repeat the full setup from the example above with a new Account, including its connect options and listeners. If a lost connection or a VivintSkyApiError stops it getting your list of systems, refresh logs the error and carries on. Anything else is raised, including a server error such as an HTTP 500 and any error from refreshing a system, and that ends a loop like the one above unless you catch it.

See demo.py for a longer example.


❤️ Support Me

I maintain this python project in my spare time and provide it as-is, without guarantees. If you find it useful, consider supporting development:

If you don't already own a Vivint system, please consider using my referral code (35fr23sv) and get a free Doorbell Camera Pro from Vivint (as well as a tip to me in appreciation)! You can also call (855) 747-7199 and mention referral code 35fr23sv.

📈 Star History

Star History Chart

Metadata

Release files for vivintpy 2026.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vivintpy 2026.2.0
File Size Uploaded Provenance Actions
vivintpy-2026.2.0.tar.gz 127.5 kB Without provenance Details for vivintpy-2026.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vivintpy 2026.2.0
File Interpreter ABI Platform Actions
vivintpy-2026.2.0-py3-none-any.whl Python 3 none any Details for vivintpy-2026.2.0-py3-none-any.whl

Total release size: 255.7 kB

Release files / vivintpy-2026.2.0.tar.gz

Download URL vivintpy-2026.2.0.tar.gz
Size 127.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4972abdf6f6ed20329a2a735c10ec293f06891cfd909ab3d17cc46e34a1cacce
BLAKE2b-256 checksum
How to use checksums
ac2458efe096683212194cb1bd43ac413b83434194b522ef73e168330d43d533
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / vivintpy-2026.2.0-py3-none-any.whl

Download URL vivintpy-2026.2.0-py3-none-any.whl
Size 128.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7130e678305375ea1935daa301084b7690b752e66399c16bbb16c877d4558f5d
BLAKE2b-256 checksum
How to use checksums
eecef9ee6ed80718b1ca476b7ae2838c05e569d802be071c3d4d3124d678c0fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for vivintpy 2026.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2026.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page