Skip to main content

Asyncio PJLink library (Class 1 and Class 2)

Project description

aiopjlink

A modern Python asyncio PJLink library (Class I and Class II).

PyPI PyPI - License PyPI - Python Version

PyPI - Downloads GitHub repo size

What is PJLink?

Most projectors that have RJ45 ports on the back can be controlled via PJLink.

PJLink is a communication protocol and unified standard for operating and controlling data projectors via TCP/IP, regardless of manufacturer.

PJLink consists of Class 1 commands and queries, as well as Class 2 notifications and extensions.

  • Class 1 is the most common type of PJLink, and is used for basic commands such as power on/off, input selection, and adjusting volume.
  • Class 2 is an extended version of the protocol that supports additional commands such as opening and closing the projector's lens cover, and is typically used by more sophisticated devices.

What is aiopjlink?

A Python library that uses asyncio to talk to one or more projectors connected to a network using the PJLink protocol.

It has these advantages:

  • ✅ Clean modern asyncio API
  • ✅ High level API abstraction (eg. lamp.hours)
  • ✅ Pure Python 3 implementation (no dependencies)
  • ✅ Full suite of test cases
  • ✅ Context managers for keeping track of connections and resources
  • ✅ High quality error handling

Usage

Each "connection" to a projector is managed through a PJLink context manager. Once this is connected, you access the different functions through a high level API (e.g. conn.power.turn_off(), conn.lamps.hours(), conn.errors.query(), etc).

For example, create a PJLink connection to the projector and issue commands:

async with PJLink(address="192.168.1.120", password="secretpassword") as link:

    # Turn on the projector.
    await link.power.turn_on()

    # Wait a few seconds, then print out all the error information.
    await asyncio.sleep(5)
    print("errors = ", await link.errors.query())

    # Then wait a few seconds, then turn the projector off.
    await asyncio.sleep(5)
    await link.power.turn_off()

Development

We use the PDM package manager.

pdm install --dev  # install all deps required to run and test the code

pdm run lint  # check code quality
pdm run test  # check all test cases run OK

pdm publish  # Publish the project to PyPI

Other notes:

  • There are more "pdm scripts" in the .toml file.
  • Set the env variable AIOPJLINK_PRINT_DEBUG_COMMS to print debug comms to the console.

Roadmap

Pull requests with test cases are welcome. There are still some things to finish, including:

  • Search Protocol (§3.2)
  • Status Notification Prototol (§3.3)

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

aiopjlink-1.0.5.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

aiopjlink-1.0.5-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

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