Documentation
Components
Components are the core building blocks of MudPi that have state and can be monitored and managed.
Overview
Components are items in MudPi that have state. Each component is represented by a unique key, can perform actions, and is managed by a worker. Components are the fundamental units that make up your MudPi system.
Component Structure
Every component shares a common structure: a key for identification, a state value, and a set of actions it can perform. Components emit events when their state changes and can be controlled through the event system or the API.
{
"key": "my_sensor",
"interface": "gpio",
"type": "sensor",
"name": "Garden Sensor"
}
Interfaceable Components
MudPi provides several built-in component types that support multiple hardware interfaces. These are the primary components you will work with when building your system:
Sensors
Read data from the environment such as temperature, humidity, and soil moisture
Controls
Manage relays, pumps, valves, and other output devices
Cameras
Capture images and stream video from connected cameras
Triggers
Evaluate conditions and activate actions when thresholds are met
Displays
Output data to LCD screens, LED indicators, and other display hardware
Toggles
Simple on/off components for LEDs, switches, and GPIO output pins
State & Actions
All components maintain their current state and expose actions that can be called to change that state. When a component's state changes, it emits a StateUpdated event that other parts of the system can react to.
Note
Component state is backed up in Redis automatically. See the State documentation for details on how state is managed and persisted.
Creating New Components
MudPi's extension system allows you to create custom component types with new interfaces. If the built-in components don't cover your use case, you can build your own by extending the base component class.
Tip
Ready to build your own component? See the Developers: Components guide for a complete walkthrough.