--- id: pymysensors version: "0.26.0" license: MIT license_treatment: permissive maintenance: active --- # pymysensors — Python API for talking to a MySensors gateway License: permissive · Maintenance: active · Downloads: 73.5K/mo ## 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 above — 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 pip install pymysensors uv add pymysensors 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_current - Install friction: low - Maintenance: active - Downloads: 73.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags mysensors gateway python, iot sensor network communication, serial gateway protocol, mqtt sensor gateway, home automation sensor api, wireless sensor mesh network, ota firmware update, iot, home-automation, sensor-network [View on SkillFed](https://skillfed.io/packages/pymysensors) · [View on PyPI](https://pypi.org/project/pymysensors/)