Data Storage

Storing data is up to the user to decide a desired method of storage. By default, Mudpi will store the last sensor readings or relay state in temporary memory store (Redis). This value will be overwritten every time a new value is received. This way it is easy for users to pull values from redis as needed and log them in their own method.

Storing Values

MudPi will store sensor values and relay state in redis for you using the "name" you specified for the sensor in the mudpi.config file. Note the "name" will be slugged (converted to lowercase and spaces replaced with underscores) and used in place of "key" if you do not specifically provide one.

So for example a sensor config of:

{
    "pin": "3",
    "type": "Humidity",
    "name": "Weather Station"
}

Would store the reading in redis with a key of weather_station.

If you wanted to specify a key of your own, you can do so in the sensor config with the "key" option. Keep in mind this must be a valid redis key which can be just about anything. However, try to keep this simple but descriptive for your own sake.

{
    "pin": "3",
    "type": "Humidity",
    "name": "Weather Station",
    "key": "your_own_key"
}

This config above would save in redis under the key your_own_key and the "name" would be ignored since a "key" option is present in the config.

Key Values Stored in Redis

Other than the sensor readings and relay state, there are a few other important values MudPi stores into redis for you. These value are listed below with more information.

Note on keys: storing False in redis can be cast as a string which will read truthy in python. Instead we del the key and only store the key if its True

Main Stored Values

KeyTypeDescription
started_at[Timestamp]Timestamp of when MudPi started running. Useful to check uptime.
last_camera_image[String]Full path and file name of the last image saved by the camera worker.