remoteprotocols
remoteprotocols is a command line utility and a Python's library to convert between more than 20 encoded IR and 5 RF remote protocols (nec, jvc, RC switch, see full protocol list) and 4 raw formats (pronto, Broadlink, Xiaomi miio, raw durations) and between those. The goal is to be able to use any existing code listing with any transmitter, and to be able to decode raw signal received by any device into the proper encoded format.
Remote command strings
To interact with remoteprotocols you'll be using remote commands to encode/decode/convert using the following syntax:
protocol:<arg 1>:<arg 2>: ... :<arg n>
# Example signatures
sony:<data>:<nbits?=12>
toshiba_ac:<rc_code_1>:<rc_code_2?=0>
# Example usage
nec:0x7A:0x57
You can get a list of all supported protocols and their command signatures here, and from the command line.
Optional arguments can be omitted, with empty :: in the middle or completely omitting the colon at the end.
Command line
You can use remoteprotocols from the command line:
usage: remoteprotocols [-h] [-v] command ...
remoteprotocols v0.0.1
positional arguments:
command Command to run:
validate-protocol
Validate a protocol definition file.
validate-command
Validate a send command string(s).
encode Encodes command string(s) into raw signal (durations).
convert Converts command string(s) to other protocols.
list List supported protocols.
optional arguments:
-h, --help show this help message and exit
-v, --version Show version information.
API usage
To interact with remoteprotocols from your own program you import it and interact with it thru the registry, which has all built-in protocol definitions
from remoteprotocols import ProtocolRegistry
protocols = ProtocolRegistry()
matches = protocols.convert("nec:0x7A:0x57", 0.2, ["durations", "broadlink"])
Main ProtocolRegistry methods:
-
convert(command:str, tolerance: float, codec_filter:list[str]) -> list[DecodeMatch] Converts a given command into other protocols (all or filtered). Returns a list of DecodeMatch objects with the successful conversions, or an empty list if it couldn't convert. The match has the following attributes:
- protocol: the matched protocol as a ProtocolDef object
- args: an array of parsed arguments (including default ones)
- tolerance: the tolerance needed to match this protocol (lower better match)
- uniquematch: boolean indicating if the match is unique for this protocol. It should always be true for well defined protocols. When false, it means that the returned match is one out of multiple results that would encode in the same signal
- missing_bits: array of bitmasks of bits for each argument, that could not be decoded, and thus any value in those bits would be a valid result. If any mask is non zero, then the match is not unique for the protocol
- toggle_bit: state of the toggle bit (internal argument). Only relevant for protocols that use it (like RC5)
-
decode(signal: SignalData, tolerance: float, protocol: Optional[list[str]])-> list[DecodeMatch]
Decodes a signal (optional frequency & array of durations) and returns a list of all matching protocols and corresponding decoded arguments. It decodes into all known protocols or a filtered subset.
-
parse_command(command: str)-> RemoteCommand
Parses and validates a command string into a RemoteCommand object. It raises
voluptuous.Invalidexception if there is any parsing problem.
Example Protocol Definition
Encoded protocols are easily defined using an intuitive declarative syntax in the definitions yaml file, which is then used to both encode and decode.
nec:
desc: NEC IR code (in LSB form)
type: IR
args:
- name: address
max: 16bits
desc: Address to send
print: 04X
- name: command
max: 16bits
desc: NEC command to send
print: 04X
timings:
frequency: 38000
unit: 1
one: [560, -1690]
zero: [560, -560]
header: [9000, -4500]
footer: [560]
pattern: header {address LSB 16} {command LSB 16} footer
Acknowledgments
Thanks to all of the following sites and projects from where I obtained information about different codec definitions:
- ESPHome
- IRremoteESP8266
- IRMP
- MakeHex
- IrScrutinizer
- python-miio for Xiaomi miio raw format
- python-broadlink for Broadlink raw format
- harctoolbox for Pronto
Metadata
Release files for remoteprotocols 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| remoteprotocols-0.0.7.tar.gz | 28.5 kB | Without provenance | Details for remoteprotocols-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| remoteprotocols-0.0.7-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for remoteprotocols-0.0.7-py2.py3-none-any.whl |
Total release size: 61.7 kB
Release files / remoteprotocols-0.0.7.tar.gz
| Download URL | remoteprotocols-0.0.7.tar.gz |
|---|---|
| Size | 28.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7eaa76ff2137f80bfb2e9e80d4ec0cd36a1177365889f5a2181bc889d96269e
|
|
BLAKE2b-256 checksum How to use checksums |
b52e670cbd575ef537c2a5d7740215f94aedb957359fc5d5af437333fe57b5be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.9.5
|
Release files / remoteprotocols-0.0.7-py2.py3-none-any.whl
| Download URL | remoteprotocols-0.0.7-py2.py3-none-any.whl |
|---|---|
| Size | 33.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b5371698397bfa255b755b38f6add113be484072a38ddd7a9d31362cdf1c39fb
|
|
BLAKE2b-256 checksum How to use checksums |
e33596260ee9d8cc65507af844b09545c3bff3d83c52a14483ce6f53162fd161
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.9.5
|
Security for remoteprotocols 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.