Skip to main content

Asyncio PJLink library (Class 1 and Class 2)

Project description

aiopjlink2

A modern Python asyncio PJLink library (Class I and Class II). This is a fork from HEInventions/aiopjlink and Kwull/aiopjlink.

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.

The main difference from the HEInventions/aiopjlink implementation is that in aiopjlink-kw, each PJLink command is executed over a new TCP/IP connection, including authentication if required. This approach was taken due to the specific PJLink implementation used by AWOL projectors. The additional changes made by aiopjlink2 is the exclusion of the test folder from the package that is published to PyPI. Additionally the context manager has been removed from PJLink because it brings no benefit anymore now, that each command is executed over a new connection.

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 command sent to a projector is creating a new connection. The projector can be initialized with a PJLink instance. Once this is created, 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 instance of the projector and issue commands:

link = PJLink(address="192.168.1.120", password="secretpassword")

# 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

aiopjlink2-1.0.6.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

aiopjlink2-1.0.6-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file aiopjlink2-1.0.6.tar.gz.

File metadata

  • Download URL: aiopjlink2-1.0.6.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.7 CPython/3.13.12 Windows/11

File hashes

Hashes for aiopjlink2-1.0.6.tar.gz
Algorithm Hash digest
SHA256 900d07cd1cb8244da22df2c92017a1f174aa3ebf06c31cb016c2352edab619f1
MD5 88c5be99adb193fde7da5fb528e1f840
BLAKE2b-256 9d2981171774d6d301d091ea9fdf46e1acdc9e40fc658702e11fcb837ee356c5

See more details on using hashes here.

File details

Details for the file aiopjlink2-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: aiopjlink2-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.7 CPython/3.13.12 Windows/11

File hashes

Hashes for aiopjlink2-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ed5d976dc919f40314aa8519f57ddfc80e34744c0d39849255aad9f0f0a41677
MD5 cc4e77a44af5418b3c942e093d6ec068
BLAKE2b-256 ae75d3b0cc3dc8ad60df30027342f69b777d1622e63e365caa744b9a4848cfd8

See more details on using hashes here.

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