skillfed

pymysensors

Python API for talking to a MySensors gateway

pymysensors v0.26.0 73.5K downloads/30d#14,980 on PyPI64
Permissive license MIT Active released

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 pymysensors

uv

uv add pymysensors

poetry

poetry add pymysensors

Installing 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

Intended Audience :: DevelopersIntended Audience :: End Users/DesktopNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Home Automation

Tags

mysensors gateway pythoniot sensor network communicationserial gateway protocolmqtt sensor gatewayhome automation sensor apiwireless sensor mesh networkota firmware update
iothome-automationsensor-network

More Home Automation packages