Giter Site home page Giter Site logo

fantastau / pycontrol4 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lawtancool/pycontrol4

0.0 0.0 0.0 201 KB

Python 3 asyncio package for interacting with Control4 systems

Home Page: https://lawtancool.github.io/pyControl4

License: Apache License 2.0

Python 100.00%

pycontrol4's Introduction

pyControl4

PyPI versionDownloads

CIpdocPyPI Release

An asynchronous library to interact with Control4 systems through their built-in REST API. This is known to work on controllers with OS 2.10.1.544795-res and OS 3.0+.

Auto-generated function documentation can be found at https://lawtancool.github.io/pyControl4

For those who are looking for a pre-built solution for controlling their devices, this library is implemented in the official Home Assistant Control4 integration.

Usage example

from pyControl4.account import C4Account
from pyControl4.director import C4Director
from pyControl4.light import C4Light
import asyncio
import json

username = ""
password = ""

ip = "192.168.1.25"

"""Authenticate with Control4 account"""
account = C4Account(username, password)
asyncio.run(account.getAccountBearerToken())

"""Get and print controller name"""
accountControllers = asyncio.run(account.getAccountControllers())
print(accountControllers["controllerCommonName"])

"""Get bearer token to communicate with controller locally"""
director_bearer_token = asyncio.run(
    account.getDirectorBearerToken(accountControllers["controllerCommonName"])
)["token"]

"""Create new C4Director instance"""
director = C4Director(ip, director_bearer_token)

"""Print all devices on the controller"""
print(asyncio.run(director.getAllItemInfo()))

"""Create new C4Light instance"""
light = C4Light(director, 253)

"""Ramp light level to 10% over 10000ms"""
asyncio.run(light.rampToLevel(10, 10000))

"""Print state of light"""
print(asyncio.run(light.getState()))

Contributing

Pull requests are welcome! Please lint your Python code with flake8 and format it with Black.

Disclaimer

This library is not affiliated with or endorsed by Control4.

pycontrol4's People

Contributors

actions-user avatar alejdg avatar brunchboy avatar dalord7 avatar dependabot[bot] avatar itsimpulsse avatar kdkavanagh avatar lawtancool avatar nalin29 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.