mtdx62
Device library for the MTD062-MB (5.8 GHz) and MTD262-MB (24 GHz) human presence sensors, spoken to over Modbus RTU or Modbus TCP.
The library models the sensor's registers as typed Python attributes. It reads the whole measurement block in one Modbus request and keeps the configuration registers separate, so polling the sensor does not drag along parameters that rarely change.
Built on modbus-connection: the
caller owns the connection and hands over a ModbusUnit. The library never opens a socket or a
serial port and has no dependency on Home Assistant.
Install
pip install mtdx62-modbus-library
Use
import asyncio
from modbus_connection import ModbusTcpParams
from modbus_connection.tmodbus import ModbusConnection
from mtdx62_modbus_library import Mtdx62Device
async def main() -> None:
connection = ModbusConnection(ModbusTcpParams(host="192.168.1.50", port=502))
try:
device = Mtdx62Device(connection.for_unit(1))
await device.async_update_readings()
print(device.readings.presence, device.readings.illuminance, device.readings.distance)
await device.async_update_settings()
print(device.settings.detection_distance, device.settings.departure_delay)
finally:
await connection.close()
asyncio.run(main())
What it exposes
| Attribute | Meaning | Unit |
|---|---|---|
readings.presence |
a person is detected, including someone sitting still | — |
readings.illuminance |
ambient light as the sensor sees it | lx |
readings.distance |
distance to the detected target | m, centimetre resolution |
readings.status_code |
raw health code | — |
readings.status |
health code as DeviceStatus, None when unknown |
— |
readings.radar_version |
radar module firmware version | — |
settings.* |
detection range, delays, sensitivities, bus address and speed | see Settings |
Every attribute is None until the first read of its sub-system.
The library only reads: no field is writable, and the sensor's configuration is not changed by
it. Reading the configuration is a separate call (async_update_settings()) precisely so that a
5-second poll costs one request.
Health codes
readings.status is a DeviceStatus member. A running sensor reports OK (1); code 0 is the
transient self-check at power-up, and code 2 and above mean the sensor is broken. is_fault
tells the two groups apart, so consumers do not have to remember the boundary.
| Code | Meaning | is_fault |
|---|---|---|
| 0 | self-check in progress | no |
| 1 | running | no |
| 2 | self-test failed | yes |
| 3 | other fault | yes |
| 4 | radar module fault | yes |
| 5 | RS485 fault | yes |
| 6 | radar and RS485 fault | yes |
An undocumented code decodes to None, while status_code keeps the raw number for diagnostics.
0.2.0 is a breaking release:
OKandSELF_TEST_FAILEDswapped values, because 0.1.0 read the vendor table one row off.
Errors
The library raises whatever modbus-connection raises: a timeout, a protocol error, or a
refusal of the addressed registers. It does not wrap them, so the caller can tell a dead link
from a slow device.
Supported firmware
Written against the vendor documentation for firmware 1.6. The register map is in
openspec/specs/mtdx62-registers/ once the first change is archived, and the raw facts are in
references/mtdx62/DEVICE-FACTS.md in the project workspace.
Tests
Tests run against the in-memory backend of modbus-connection, so they need neither hardware
nor Home Assistant:
pip install -e ".[test]"
pytest
Author
Sergey Astakhov — sergeyastakhov@mail.ru, github.com/sergeyastakhov.
Source and issues: https://github.com/sergeyastakhov/mtdx62-modbus-library. MIT licensed.
Metadata
Release files for mtdx62-modbus-library 0.3.0
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 |
|---|---|---|---|---|
| mtdx62_modbus_library-0.3.0.tar.gz | 25.8 kB | With provenance | Details for mtdx62_modbus_library-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mtdx62_modbus_library-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for mtdx62_modbus_library-0.3.0-py3-none-any.whl |
Total release size: 34.7 kB
Release files / mtdx62_modbus_library-0.3.0.tar.gz
| Download URL | mtdx62_modbus_library-0.3.0.tar.gz |
|---|---|
| Size | 25.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1b23eed66b46bc7c98c989755d28b34baa857d9feb521cda544791b23c9404f
|
|
BLAKE2b-256 checksum How to use checksums |
fb7eed3de55e675b44b85e295a45ceb8ba106b6a04d428d0d4ade7c1f34e744d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logRelease files / mtdx62_modbus_library-0.3.0-py3-none-any.whl
| Download URL | mtdx62_modbus_library-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79b7a6ce0c77d35aedc1931afc062b279a70af83309c0c98d8dcadac5e1fe6e9
|
|
BLAKE2b-256 checksum How to use checksums |
ed2edd405ba48bce87822c161763f790ab58ca0d8886d6fb95783a286cc1881d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logSecurity for mtdx62-modbus-library 0.3.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mtdx62_modbus_library-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logA 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.