pymysensors
Python API for talking to a MySensors gateway
What it is and what it does
pymysensors is a Python library that acts as a client to MySensors gateways, enabling communication with wireless sensor networks. It abstracts the MySensors serial protocol (versions 1.4–2.2) and provides a callback-driven API to receive sensor updates, query node state, and send commands to individual sensors. The library manages gateway instances (serial, TCP, or MQTT) in separate threads or via asyncio, maintains a hierarchical data structure of nodes and child sensors, and handles over-the-air firmware updates using DualOptiboot or MYSBootloader bootloaders.
Typical use involves instantiating a gateway, registering an event callback to handle sensor messages, and starting the gateway. Once running, you access the sensor network through the gateway's sensors dictionary, querying node metadata, child sensor types, and values. The library also supports persistence (pickle or JSON) to retain network state across restarts, and provides methods to push updates back to nodes—useful for controlling actuators or triggering OTA updates.
Use it for:
- Monitor temperature, humidity, and motion sensors in a home automation setup by registering callbacks and querying sensor values.
- Deploy firmware updates to multiple sensor nodes without manual intervention using the update_fw method.
- Integrate a wireless sensor network with a home automation platform via the Python API.
- Persist sensor network topology and state across gateway restarts using JSON or pickle persistence.
- Control actuators (lights, relays) by sending commands to child sensors via set_child_value.
- Bridge gateways to MQTT brokers for cross-platform IoT integration.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python API for communicating with MySensors gateways over serial, TCP, or MQTT protocols, supporting protocol versions 1.4 through 2.2 with OTA firmware updates and sensor network management.
Yes. pymysensors is actively maintained, has no known vulnerabilities, supports modern Python versions (3.9+), and provides a clean callback-driven API for gateway communication. Install it if you are building a home automation or IoT application around MySensors hardware. The low install friction and permissive MIT license make adoption straightforward. Consider only if you have or plan to deploy MySensors gateway hardware.
Install
pymysensors on PyPI
pip
pip install pymysensorsuv
uv add pymysensorspoetry
poetry add pymysensorsInstalling pymysensors
Before you install
Low install friction; depends on 8 runtime packages including pyserial, click, and voluptuous. Actively maintained with recent commits and Python 3.9+ support across current versions.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal obligations—suitable for both open-source and proprietary projects.
Quickstart
pip install pymysensors
import pymysensors
def event(message):
print('sensor_update ' + str(message.node_id))
gateway = pymysensors.SerialGateway('/dev/ttyACM0', event_callback=event)
gateway.start()
Requires a physical MySensors gateway device connected via serial port, TCP, or MQTT broker; Python 3.9 or later.
Verify before relying
- Extent of v2.x feature coverage beyond smartsleep, MQTT, and OTA updates
- Performance characteristics with large sensor networks (node/child count limits)
- Asyncio gateway implementation maturity and production readiness
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — awesomeversion, click, crcmod, getmac, IntelHex, pyserial, pyserial-asyncio-fast, voluptuous |
| Maintenance | actively maintained — 393 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 73,545/month — #14,980 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pymysensors-0.26.0-py3-none-any.whl
Keywords: sensor, actuator, IoT, DYI
Tags
More Home Automation packages
Represents and manipulates IPv4, IPv6, MAC…
permissive · top 5,000 on PyPI
homeassistantHome Assistant is an open-source home…
permissive · top 5,000 on PyPI
python-statemachineDefines finite state machines and statecharts…
permissive · top 5,000 on PyPI
btsocketA Python library for controlling BlueZ…
permissive · top 15,000 on PyPI
aiohomematicAn async Python library for controlling and…
permissive · top 15,000 on PyPI
hass-web-proxy-libProvides base classes and utilities for Home…
permissive · top 15,000 on PyPI
aioruuvigatewayAn asyncio-native library for fetching data…
unclear · top 15,000 on PyPI
PyCampbellCR1000Communicates with Campbell CR1000-type…
copyleft · top 15,000 on PyPI
tb-mqtt-clientPython client SDK for ThingsBoard IoT platform,…
permissive · top 15,000 on PyPI
pyotgwpyotgw is a Python library that communicates…
copyleft · top 15,000 on PyPI
zigpyzigpy is a hardware-independent Zigbee protocol…
copyleft · top 15,000 on PyPI
rflinkLibrary and command-line interface for…
permissive · top 15,000 on PyPI
tb-paho-mqtt-clientProvides an MQTT client library implementing…
copyleft · top 15,000 on PyPI
meshtasticA Python library and CLI for communicating with…
copyleft · top 15,000 on PyPI
paho-mqttProvides an MQTT client library for connecting…
copyleft · top 5,000 on PyPI
meross-iotA Python library for controlling Meross IoT…
permissive · top 15,000 on PyPI