Worker Configuration (Raspberry Pi)

MudPi has multiple operations it can perform from toggling relays, taking sensor readings, or listening for input. These operations are all controlled through workers that MudPi runs on multiple threads for better performance. You can read more details on the concepts of workers under the Core Concepts - Workers documentation page.

To add a worker to MudPi put a worker configuration object in the workers array. The minimum required options in a worker configuration is the type. You should add either sensors, controls, i2c or display based on your worker type.

{
    "workers":[{
        "type":"sensor",
        "sleep_duration":30,
        "topic":"sensors",
        "sensors": [
            {...}
        ]
    }]
}

If you wish to split components to run on multiple workers, simply define another worker configuration that contains the other configurations you want it to handle. This way you could adjust components you want polled at different intervals or that emit data on different topics. You can store everything on one worker or multiple workers, the choice is up to you.

{
    "workers":[
        {
            "type":"sensor",
            "sleep_duration":30,
            "topic":"sensors",
            "sensors": [
                {...}
            ]
        },
        {
            "type":"sensor",
            "sleep_duration":10,
            "topic":"sensors",
            "sensors": [
                {...}
            ]
        }
    ]
}

Settings

OptionTypeRequiredDescription
type[String]YesType of worker. Options: sensor, control, i2c, display
sleep_duration[Integer]NoTime in seconds to pause between sensor reading cycles. Minimum is 2 seconds to prevent crashing.
topic[String]NoName of the channel on redis to emit sensor readings data through.

Type Dependant Settings

Since there are several worker types they each have a set of options based on the type. Below are the configuration options each sensor type has specific to it.

OptionTypeRequiredWorker TypeDescription
sensors[Array]No SensorArray of sensor object configurations to load for the sensor type worker. See sensors configuration and i2c configuration.
controls[Array]No Control Array of control object configurations to load for the control type worker. See controls configuration.
displays[Array]No Display Array of control object configurations to load for the display type worker. See displays configuration.