API Specification¶
-
class
lirc.
Client
(connection: lirc.connection.lircd_connection.LircdConnection = None)¶ Bases:
object
Communicate with the lircd daemon.
-
close
() → None¶ Close the connection to the socket.
-
driver_option
(key: str, value: str) → None¶ Set driver-specific option named key to given value.
Parameters: - key – The key to set for the driver.
- value – The value for the key to set.
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_once
(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.
-
send_start
(remote: str, key: str) → None¶ Send an lircd SEND_START command.
This will repeat the given key until send_stop 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.
-
send_stop
(remote: str = '', key: str = '') → None¶ Send an lircd SEND_STOP command.
The remote and key default to the remote and key last used with send_start if they are not specified, since the most likely use case is sending a send_start and then a send_stop.
Parameters: - remote – The remote to stop.
- key – The key to stop sending.
Raises: LircdCommandFailure
– If the command fails.
-
set_transmitters
(transmitters: Union[int, List[int]]) → None¶ Set the active transmitters.
Example
import lirc
c = lirc.Client()
c.set_transmitters(1)
c.set_transmitters([1,3,5])
Parameters: transmitters – The transmitters to set active. Raises: LircdCommandFailure
– If the command fails.
-
simulate
(remote: str, key: str, repeat_count: int = 1, keycode: int = 0) → None¶ Simulate an IR event.
The –allow-simulate command line option to lircd must be active for this command not to fail.
- Example Format:
<code> <repeat count> <button name> <remote control name>
- Such as:
- 0000000000f40bf0 00 KEY_UP ANIMAX
Parameters: - remote – The remote to simulate key presses from.
- key – The key on the remote to simulate.
- repeat_count – The number of times to simulate the key press.
- keycode – lircd(8) describes this option as a 16 hexadecimal digit number encoding of the IR signal. However, it says it is depreciated and should be ignored.
Raises: LircdCommandFailure
– If the command fails.
-
start_logging
(path: Union[str, pathlib.Path]) → None¶ Send a lircd SET_INPUTLOG command which sets the path to log all lircd received data to.
Parameters: path – The path to start logging lircd recieved data to. Raises: LircdCommandFailure
– If the command fails.
-
stop_logging
() → None¶ Stop logging to the inputlog path from start_logging.
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] = None, socket: socket.socket = None, timeout: float = 5.0)¶ Bases:
lirc.connection.abstract_connection.AbstractConnection
-
address
¶ Retrieve the address that this lircd connection is connected to.
Returns: The current address being used.
-
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.
Parameters: data – The data to send to the lircd socket. Raises: TypeError
– if data is not a string.
-