LIRC Python Package¶
This is a python package that allows you to interact with the daemon in the Linux Infrared Remote Control package. Interacting with the daemon allows you to send IR signals from a computer.
More information on the lircd daemon, socket interface, reply packet format, etc. can be found at https://www.lirc.org/html/lircd.html
This package is hosted on PyPI and can be installed through pip.
$ pip install lirc
However since this is a wrapper around the LIRC daemon, it is expected that LIRC is installed and setup on the given system as well.
More information on that can be found in the installation portion of the documentation.
Using the Lirc Package¶
from lirc import Lirc lirc = Lirc() response = lirc.version() print(response.command) >>> 'VERSION' print(response.success) >>> True print(response.data) >>> ['0.10.1']
To get started with the package, we import
Lirc and can
initialize it with the defaults by passing it no arguments.
This will assume a socket path of
Furthermore, this will also then assume a socket connection
SOCK_STREAM. These are both the defaults
that should work on a Linux system. There are ports of LIRC
to Windows and macOS but using the package there is far less
common. However, both of these are configurable through options
Lirc to allow it to be used on those operating systems
After sending any command to the LIRC daemon, this package will create
LircResponse for us that it returns. That response contains the
command we sent to LIRC, whether it was successful, and any data that
was returned back to us.
More information on how to setup the system installed LIRC, how to use this python library, and a full API specification can be found at https://lirc.readthedocs.io/