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. However you should add either sensors or controls based on your worker type.

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

If you wish to split sensors to run on multiple workers, simply define another worker configuration that contains the sensor configurations you want it to handle. This way you could adjust sensors you want polled at different intervals or that emit data on different channels.

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

Settings

OptionTypeRequiredDescription
type[String]YesType of worker. Options: sensor, control
sleep_duration[Integer]NoTime in seconds to pause between sensor reading cycles. Minimum is 2 seconds to prevent crashing.
channel[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.
controls[Array]No Control Array of control object configurations to load for the control type worker. See controls configuration.