Documentation

Extending MudPi

Learn how to extend MudPi with custom sensors, components, and functionality.

Overview

MudPi is designed to be extended. Whether you need to support a new sensor type, add a custom component, or integrate with third-party hardware, you can build on MudPi's architecture without modifying the core.

Adding a New Sensor Type

Let's walk through adding a motion sensor to MudPi. We'll create a MotionSensor class that extends the base Sensor component.

motion/sensor.py
Click to expand code…

Loading Your Custom Sensor

Once your sensor class is in place, load it through your MudPi configuration:

mudpi.config.json
{
  "sensor": [
    {
      "key": "front_door_motion",
      "interface": "motion",
      "pin": 23,
      "name": "Front Door Motion Sensor"
    }
  ]
}

Note

The interface value corresponds to the extension namespace that contains your sensor class. MudPi will look for a sensor.py file in the matching extension directory.

Dependency Versions for Extension Authors

As of MudPi v0.11.0, the core requires Python 3.9+ and uses the following key libraries. If your extension imports these directly, be aware of the version requirements:

Library Version Notes
redis 5.x–6.x Upgraded from 3.x. The API is largely compatible, but check the redis-py changelog for details.
paho-mqtt 2.1+ Major upgrade from 1.x. MudPi uses the compatibility layer internally, but extensions importing paho.mqtt.client directly should review the migration guide.
pyyaml 6.0+ No breaking changes for most use cases.

Submit Your Extension

Built something useful? We'd love to include it in MudPi! Submit a pull request to the MudPi repository with your extension and documentation. Check the contributing guide for details on how to submit your work.

Tip

Before building a custom extension from scratch, check the extensions documentation to see if there's an existing extension you can build on or adapt.