matterlab_relays
matterlab_relays provides drivers for the relay boards used in the Matter Lab. It includes relay-specific implementations for several serial and Modbus-controlled boards, along with a small shared base interface for switching channels on and off.
Supported Devices
Relay: shared abstract base classR421B16RelayJYdaqRelayCE221ARelay
Installation
Install the package:
pip install matterlab_relays
For development:
pip install -e .[dev]
The package depends on:
matterlab_serial_devicemodbus_tk
Quick Start
Example with an R421B16 relay:
from matterlab_relays import R421B16Relay
relay = R421B16Relay(com_port="COM5", address=1, channel=1)
print("Current state:", relay.on)
relay.on = True
relay.on = False
Core API
The shared Relay interface exposes:
on
Concrete device classes add protocol-specific helpers:
R421B16Relay:_generate_query_command(...),_generate_execute_command(...),query_relay(...),set_relay(...)JYdaqRelay:_add_rtu_master(),set_multiple_relays(...),query_multiple_relays(...)CE221ARelay: cachedonstate with_generate_execution_command(...)
Testing
Simulation Tests
Simulation tests are the default validation layer and are safe for CI.
One-click run:
python examples/test_sim.py
Direct pytest run:
pytest tests/test_base_relay.py tests/test_r421b16_sim.py tests/test_jydaq_sim.py tests/test_ce221a_sim.py
Hardware Tests
Hardware tests are opt-in because real relay hardware may not be connected in every environment.
Available hardware test files:
tests/test_r421b16_real.pytests/test_jydaq_real.pytests/test_ce221a_real.py
They are marked with @pytest.mark.real and are skipped unless --run-real is supplied.
Examples:
pytest tests/test_r421b16_real.py --run-real --com-port COM5 --address 1 --channel 1
pytest tests/test_jydaq_real.py --run-real --com-port COM5 --address 1 --channel 1
pytest tests/test_ce221a_real.py --run-real --com-port COM5 --channel 1
You can also provide hardware configuration through environment variables:
RELAY_COM_PORTRELAY_ADDRESSRELAY_CHANNEL
Examples
The examples/ directory contains the recommended entry points:
examples/test_sim.py: one-click simulation-only test runnerexamples/real_devices.py: readable examples for all supported relay driversexamples/README.md: short guide to the examples directory
Development
Useful commands:
pytest
ruff check .
ruff format .
The default pytest configuration includes retries, timeouts, coverage output, and uses src as the import root for local development.
Package Layout
src/matterlab_relays/
base_relay.py
cer221a_relay.py
jydao_relay.py
r421b16_relay.py
tests/
examples/
License
This project is distributed under the MIT License. See LICENSE for details.
Metadata
Release files for matterlab-relays 1.2.1
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 |
|---|---|---|---|---|
| matterlab_relays-1.2.1.tar.gz | 14.0 kB | Without provenance | Details for matterlab_relays-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| matterlab_relays-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for matterlab_relays-1.2.1-py3-none-any.whl |
Total release size: 26.2 kB
Release files / matterlab_relays-1.2.1.tar.gz
| Download URL | matterlab_relays-1.2.1.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a846a462bbfb5eecbe2739a9f94be3a0d6326e7714ce5e0df5466f32a1b9c5db
|
|
BLAKE2b-256 checksum How to use checksums |
fb40f3bef2811910e2ac1ba98316742db0b3d9c689396fca9533d8cacba5c624
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.13
|
Release files / matterlab_relays-1.2.1-py3-none-any.whl
| Download URL | matterlab_relays-1.2.1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de6589ce2770aaee06b42fdbb9cf845de88e8b67e89d442b85e659288d8407f7
|
|
BLAKE2b-256 checksum How to use checksums |
9caa3c674d39e6c23bec52975ff4e93832d2804b279e814eeefb6722c9ab6bcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.13
|
Security for matterlab-relays 1.2.1
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.