API Specification

class lirc.Client(connection: lirc.connection.lircd_connection.LircdConnection = <lirc.connection.lircd_connection.LircdConnection object>)

Bases: object

Communicate with the lircd daemon.

close()

Close the connection to the socket.

driver_option(key: str, value: str) → None

Set driver-specific option named key to given value.

Raises:LircdCommandFailure – If the command fails.
list_remote_keys(remote: str) → List[str]

List all the keys for a specific remote.

Parameters:remote – The remote to list the keys of.
Raises:LircdCommandFailure – If the command fails.
Returns:The list of keys from the remote.
list_remotes() → List[str]

List all the remotes that lirc has in its lircd.conf.d folder.

Raises:LircdCommandFailure – If the command fails.
Returns:The list of all remotes.
send(remote: str, key: str, repeat_count: int = 1) → None

Send an lircd SEND_ONCE command.

Parameters:
  • key – The name of the key to send.
  • remote – The remote to use keys from.
  • repeat_count – The number of times to press this key.
Raises:

LircdCommandFailure – If the command fails.

set_transmitters(transmitters: Union[int, List[int]]) → None
Raises:LircdCommandFailure – If the command fails.
simulate(remote: str, key: str, repeat_count: int = 1, keycode: int = 0) → None

The –allow-simulate command line option to lircd must be active for this command not to fail.

Raises:LircdCommandFailure – If the command fails.
start_logging(path: str) → None

Send a lircd SET_INPUTLOG command which sets the path to log all lircd received data to.

Raises:LircdCommandFailure – If the command fails.
start_repeat(remote: str, key: str) → None

Send an lircd SEND_START command.

This will repeat the given key until stop_repeat() is called.

Parameters:
  • remote – The remote to use keys from.
  • key – The name of the key to start sending.
Raises:

LircdCommandFailure – If the command fails.

stop_logging() → None

Stop logging to the inputlog path from start_logging.

Raises:LircdCommandFailure – If the command fails.
stop_repeat(remote: str = '', key: str = '') → None

Send an lircd SEND_STOP command.

Parameters:
  • remote – The remote to stop.
  • key – The key to stop sending.
  • default to the remote and key (These) –
  • used with send_start if not specified, (last) –
  • the most likely use case is sending a (since) –
  • and then a send_stop. (send_start) –
Raises:

LircdCommandFailure – If the command fails.

version() → str

Retrieve the version of LIRC

Raises:LircdCommandFailure – If the command fails.
Returns:The version of LIRC being used.
class lirc.LircdConnection(address: Union[str, tuple] = '/var/run/lirc/lircd', socket: socket.socket = <socket.socket fd=3, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>, timeout: float = 5.0)

Bases: lirc.connection.abstract_connection.AbstractConnection

address
close()

Closes the socket connection.

connect()

Connect to the socket at the address both specified on init.

Raises:
  • LircdConnectionError – If the address is invalid or lircd
  • is not running.
readline() → str

Read a line of data from the lircd socket.

We read 4096 bytes at a time as the buffer size. Therefore after data is read from the socket, all the lines are stored in a buffer if there is more than 1 and subsequent calls grab a line that stored in that buffer until it is empty. Then, another call to the socket would be made.

Raises:
  • TimeoutError – If we are not able to grab data from
  • the socket in a specified amount of time (the initial
  • timeout time on initialization).
  • LircdSocketError – If some other error happened when
  • trying to read from the socket.
Returns:

A line from the lircd socket.

send(data: str)

Send a commend to the lircd socket connection.

Raises:TypeError – if data is not a string.
socket